-
Notifications
You must be signed in to change notification settings - Fork 2
/
RemoveSplit.vfl
32 lines (32 loc) · 963 Bytes
/
RemoveSplit.vfl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
int currentPrim;
int pass;
for(int p = 0; p<nprimitives(1);p++){//for each primitive:
int pointArray[] = primpoints(1,p);//get an array of all points
//Conditions to create new primitive?
// Rising edge, going from bad point to good point.
int prev_flip = 0;
int flip = 0;
foreach(int pnt; pointArray){ //for each point in each primitive:
//what is a bad point?
//inside + !intersection
int pnt_Id = point(1,"id",pnt);
int pnt_In = point(1,"in",pnt);
vector loc;
if(pnt_In==-1 && pnt_Id==-1){ //point is bad!
flip = 0;
}else{ //else: point is good!
flip = 1;
loc = point(1,"P",pnt);
if(flip!=prev_flip){
//rising edge, create new prim.
currentPrim = addprim(0,"polyline");
}
//if good, add point
int new_point = addpoint(0,loc);
pass = setpointattrib(0, "id", new_point, pnt_Id, "set");
//printf("pass: %f\\n",pass);
int new_vert = addvertex(0,currentPrim,new_point);
}
prev_flip=flip;
}
}