Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FUNCTIONS
- void removedups(int pts[])
- {
- int end=len(pts);
- int ct1=0, ct2;
- while(ct1<end)
- {
- ct2=ct1+1;
- while(ct2<end)
- {
- if (pts[ct2]==pts[ct1])
- {
- removeindex(pts,ct2);
- end--;
- }
- ct2++;
- }
- ct1++;
- }
- }
- // START
- int pts[];
- int prims=nprimitives(0);
- int pt=0;
- for(int i=0;i<npoints(0);i++)
- if (neighbourcount(0,i)==1) pt=i;
- int temp[]=pointprims(0,pt);
- int prim=temp[0];
- push(pts,pt);
- // Create an array of points
- for (int j=0;j<prims;j++)
- {
- int nepts[]=primpoints(0,prim);
- removedups(nepts);
- if (pt!=nepts[0]) nepts=reverse(nepts);
- removeindex(nepts,0);
- append(pts,nepts);
- pt=nepts[len(nepts)-1];
- int prs[]=pointprims(0,pt);
- int is=1;
- while (is)
- is=removevalue(prs,prim);
- prim=prs[0]; // Next primitive to use
- }
- //Delete all geo except points
- for (int i=0;i<prims;i++)
- removeprim(geoself(),i,0);
- // Create new polygon and wire points
- int newprim=addprim(geoself(),"polyline");
- for (int i=0;i<len(pts);i++)
- {
- addvertex(geoself(),newprim,pts[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment