mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-11 11:55:02 -05:00
df029c2fd7
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@104 3f818213-9676-44b0-a9b4-5e4c4e03d09d
95 lines
2.5 KiB
ObjectPascal
95 lines
2.5 KiB
ObjectPascal
unit dtmutil;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils, MufasaTypes;
|
|
|
|
|
|
Function pDTMToTDTM(Const DTM: pDTM): TDTM;
|
|
Function tDTMTopDTM(Const DTM: TDTM): pDTM;
|
|
Procedure PrintpDTM(tDTM : pDTM);
|
|
|
|
implementation
|
|
|
|
Procedure PrintpDTM(tDTM : pDTM);
|
|
var
|
|
i : integer;
|
|
begin;
|
|
i := 0;
|
|
WriteLn('MainPoint ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i]));
|
|
for I := 1 to High(tDTM.p) do
|
|
WriteLn('SubPoint['+IntToStr(I) + '] ' + inttostr(tDTM.p[i].x) + ', ' + inttostr(tDTM.p[i].y) + ' col: ' + inttostr(tDTM.c[i]) + ', tol: ' + inttostr(tDTM.t[i]) + '; ashape ' + inttostr(tdtm.ash[i]) + ' asize ' + inttostr(tdtm.asz[i]));
|
|
end;
|
|
Function pDTMToTDTM(Const DTM: pDTM): TDTM;
|
|
|
|
Var
|
|
Temp: TDTMPointDef;
|
|
I: Integer;
|
|
|
|
Begin
|
|
For I := 0 To 0 Do
|
|
Begin
|
|
Temp.X := DTM.p[i].x;
|
|
Temp.Y := DTM.p[i].y;
|
|
Temp.AreaSize := DTM.asz[i];
|
|
Temp.AreaShape := DTM.ash[i];
|
|
Temp.Color := DTM.c[i];
|
|
Temp.Tolerance := DTM.t[i];
|
|
End;
|
|
Result.MainPoint := Temp;
|
|
SetLength(Result.SubPoints, Length(DTM.p) - 1);
|
|
|
|
For I := 1 To High(DTM.p) Do
|
|
Begin
|
|
Temp.X := 0; Temp.Y := 0; Temp.AreaSize := 0; Temp.AreaShape := 0; Temp.Color := 0; Temp.Tolerance := 0;
|
|
Temp.X := DTM.p[i].x;
|
|
Temp.Y := DTM.p[i].y;
|
|
Temp.AreaSize := DTM.asz[i];
|
|
Temp.AreaShape := DTM.ash[i];
|
|
Temp.Color := DTM.c[i];
|
|
Temp.Tolerance := DTM.t[i];
|
|
Result.SubPoints[I - 1] := Temp;
|
|
End;
|
|
End;
|
|
|
|
{/\
|
|
Converts a TDTM to a pDTM.
|
|
/\}
|
|
|
|
Function tDTMTopDTM(Const DTM: TDTM): pDTM;
|
|
|
|
Var
|
|
//Temp: TDTMPointDef;
|
|
I: Integer;
|
|
|
|
Begin
|
|
SetLength(Result.p, Length(DTM.SubPoints) + 1);
|
|
SetLength(Result.c, Length(DTM.SubPoints) + 1);
|
|
SetLength(Result.t, Length(DTM.SubPoints) + 1);
|
|
SetLength(Result.asz, Length(DTM.SubPoints) + 1);
|
|
SetLength(Result.ash, Length(DTM.SubPoints) + 1);
|
|
|
|
Result.p[0].x := DTM.MainPoint.x;
|
|
Result.p[0].y := DTM.MainPoint.y;
|
|
Result.c[0] := DTM.MainPoint.Color;
|
|
Result.t[0] := DTM.MainPoint.Tolerance;
|
|
Result.asz[0] := DTM.MainPoint.AreaSize;
|
|
Result.ash[0] := DTM.MainPoint.AreaShape;
|
|
|
|
For I := 1 To Length(DTM.SubPoints) Do // High + 1 = Length
|
|
Begin
|
|
Result.p[I].x := DTM.SubPoints[I - 1].x;
|
|
Result.p[I].y := DTM.SubPoints[I - 1].y;
|
|
Result.c[I] := DTM.SubPoints[I - 1].Color;
|
|
Result.t[I] := DTM.SubPoints[I - 1].Tolerance;
|
|
Result.asz[I] := DTM.SubPoints[I - 1].AreaSize;
|
|
Result.ash[I] := DTM.SubPoints[I - 1].AreaShape;
|
|
End;
|
|
End;
|
|
|
|
end.
|
|
|