SRL Archive - Research & Development Lounge

DTMlib


nielsie95

2008-10-17 17:14:08

Hey,

This is a plugin which contains 2 functions: DTMtoDDTM and DDTMtoDTM. DTMtoDDTM converts a DTM (string) to a DDTM (TDTMPointDef). As you already might have guessed: DDTMtoDTM does the opposite.


DTMtoDDTM might be useful to turn a static DTM into a Dynamic one (less lines needed to load a DDTM).
DDTMtoDTM might be used for some functions I have seen around (the ones that create a DDTM from an item).


I'm sure there are many other possibilities. Use your imagination.

Used like this:

program New;
var
c: TDDTMarray;
begin
c := DTMtoDDTM('78DA638C666660D8CB00074C40FCFFFF7F309B112A06005105041D');
WriteLn(IntToStr(Length(c))+' point[s].');
WriteLn('');
if (Length(c) > 0) then
begin
WriteLn('x: '+IntToStr(c[0].x));
WriteLn('y: '+IntToStr(c[0].y));
WriteLn('Size: '+IntToStr(c[0].AreaSize));
WriteLn('Shape: '+IntToStr(c[0].AreaShape));
WriteLn('Tol: '+IntToStr(c[0].Tolerance));
WriteLn('Col: '+IntToStr(c[0].Color));
end;
WriteLn(DDTMtoDTM(c));
end.

~Nielsie95

Wizzup?

2008-10-17 18:36:40

Ah, cool. You posted it. ;)

mastaraymond

2008-10-17 19:42:26

From: Wizzup?
Ah, cool. You posted it. ;)

No he didn't…

MylesMadness

2008-10-17 20:53:47

I LOVE YOU! This is want I need for my dtm database, use my itemdtm function then turn it into a dtm! Perfect

Naum

2008-10-19 11:27:24

OMFG, Yay niels you did it again!!!!!! I really need that - really cool if this could be reintegrated into SCAR then you can have thoose functions :)

mixster

2008-10-20 02:31:27

Love you nielsie!
Though shouldn't you have set up the TDDTMArray to follow the Scar method of a record of a TDDTMPointDef (main point) and an array of TDDTMPointDef (subpoints)?
Aside from that, I'll assume the first point is used as the main point, with the others as sub points and pretty awesome plugin that was long awaited from me :)

Lee Lok Hin

2008-10-24 02:49:47

Yeah! Thanks Wizzup (?) And Niels

/me immediately takes a look at tara's DTMs

nielsie95

2008-10-24 04:26:12

From: mixster
Love you nielsie!
Though shouldn't you have set up the TDDTMArray to follow the Scar method of a record of a TDDTMPointDef (main point) and an array of TDDTMPointDef (subpoints)?
Aside from that, I'll assume the first point is used as the main point, with the others as sub points and pretty awesome plugin that was long awaited from me :)


If you convert a DDTM to DTM, the first point is used as the MainPoint. DTM to DDTM is just in order of the DTM Editor, because I can't pass the parent (a DTM can have a different parent for each point).

Sandstorm

2008-10-24 20:59:29

Question on how this would be used.

Can you use it directly into a script to turn a dtm to a ddtm, so that you can call a ddtm without actually making one?

nielsie95

2008-10-25 11:31:48

If you want to call the dtm, you can load them like this:


program New;
var
c: TDDTMarray;
dtm: Integer;
begin
c := DTMtoDDTM('78DA634C606060E066644006152E720CCA401A24FA1F081803800C7E543510591809A46380041F0135E9404280809A3420C146404D1C90E0C0AF0600D6AB078E');
//Make changes to your DDTM here
dtm := DTMFromString(DDTMtoDTM(c));
FreeDTM(dtm);
end.

or like this:


program New;
var
c: TDDTMarray;
dtm: Integer;
t: TDTM;
begin
c := DTMtoDDTM('78DA634C606060E066644006152E720CCA401A24FA1F081803800C7E543510591809A46380041F0135E9404280809A3420C146404D1C90E0C0AF0600D6AB078E');
//Make changes to your DDTM here

t.MainPoint := c[0];
Swap(c[0], c[High(c)]);
SetLength(c, High(c));
t.SubPoints := c;
dtm := AddDTM(t);

FreeDTM(dtm);
end.