Hi everyone!
This is my first post, I have been this script for several time. Basically this script does is to join a set of Polys consecutively(join poly 1 with 2,3,4,5). The problem now is that I need to modify this script to join the poly 1,3,5.Someone can help me with this please
Thank you in advence
The Script:
Procedure TheProcedure;
{debug}
VAR
x,y,d: REAL;
r, g, b :LONGINT;
h,h1: HANDLE;
s: STRING;
i,j,n,vtx,m,ii,i2: INTEGER;
p1,p2: POINT;
Myp,Myp2: DYNARRAY OF POINT3D;
{----------------------------------------------------------------------}
Procedure DrawPol(Myp: DYNARRAY of POINt3D;i:INTEGER);
VAR
h1,h:HANDLE;
j:INTEGER;
BEGIN
layer ('new Lines');
OpenPoly;
BeginPoly;
For j:=1 To i do BEGIN
IF Myp[j].z=0 Then Addpoint(Myp[j].x,Myp[j].y);
IF Myp[j].z=1 Then CurveTo(Myp[j].x,Myp[j].y);
IF Myp[j].z=2 Then CurveThrough(Myp[j].x,Myp[j].y);
END;
EndPoly;
h1:=LNewObj;
ColorIndexToRGB(7, r, g, b);
SetPenFore(h1, r, g, b);
SetFPat(h1,0);
layer(s);
END;
{----------------------------------------------------------------------}
{----------------------------------------------------------------------}
Procedure Del_Points(Myp: DYNARRAY of POINt3D;i:INTEGER; Dist: REAL; Dist2: REAL; VAR Myp2: DYNARRAY of POINt3D; VAR jj: INTEGER );
VAR
d: REAL;
j: INTEGER;
BEGIN
jj:=1;
FOR j:=1 TO i-1 DO BEGIN
d:= Sqrt (Sqr((Myp[j+1].x-Myp[j].x))+Sqr((Myp[j+1].y-Myp[j].y)));
IF MyP[j].z>0 THEN BEGIN
IF d>dist THEN BEGIN
MyP2[jj]:=MyP[j];
jj:=jj+1;
END;
END
ELSE BEGIN
IF d>dist2 THEN BEGIN
MyP2[jj]:=MyP[j];
jj:=jj+1;
END;
END;
END;
MyP2[jj]:=MyP;
END;
{----------------------------------------------------------------------}
Procedure FindP(x,y : REAL;h: HANDLE; VAR ii: INTEGER; VAR xp,yp : REAL);
VAR
x1,x2,y1,y2,dst1,dst2: REAL;
i: INTEGER;
BEGIN
i:=GetVertNum(h);
GetPolylineVertex(h,1,x1,y1,vtx,d);
dst1:= Sqrt( Sqr(x1-x) + sqr(y1-y) );
GetPolylineVertex(h,i,x2,y2,vtx,d);
dst2:= Sqrt( Sqr(x2-x) + sqr(y2-y) );
IF dst1>dst2 THEN BEGIN
xp:=x2;
yp:=y2;
ii:=i;
END;
IF dst1
xp:=x1;
yp:=y1;
ii:=1;
END;
END;
{----------------------------------------------------------------------}
BEGIN
h:=ActLayer;
s:=GetLName(h);
n:=NumSObj(h);
h:=FSActLayer;
GetPt(x,y);
ii:=1;
FindP(x,y,h,ii,x,y);
FOR m:=1 TO n DO BEGIN
i:=GetVertNum(h);
ALLOCATE Myp[1..i+1];
ALLOCATE Myp2[1..i+1];
IF ii=1 THEN BEGIN
FOR j:=1 TO i DO BEGIN
GetPolylineVertex(h,j,Myp[j].x,Myp[j].y,Myp[j].z,d);
END;
END;
IF ii=i THEN BEGIN
FOR j:=1 TO i DO BEGIN
GetPolylineVertex(h,i+1-j,Myp[j].x,Myp[j].y,Myp[j].z,d);
END;
END;
h1:=NextSObj(h);
IF h1<>NIL THEN BEGIN
i:=i+1;
FindP(Myp[i-1].x,Myp[i-1].y,h1,ii,Myp.x,Myp.y);
Myp.z:=0;
END;
Del_Points (Myp,i,.2,.2,MyP2,i2);
DrawPol(Myp2,i2);
h:=NextSObj(h);
END;
layer ('new Lines');
END;
RUN (TheProcedure);