canevar Posted Wednesday at 05:16 PM Share Posted Wednesday at 05:16 PM I want to create segments from the non intersecting parts of a curve. First value that is not -1 is the end of first segment, second value is the beginning of 2nd segment. Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted Wednesday at 11:59 PM Share Posted Wednesday at 11:59 PM // Wrangle set to Run Over Detail int current_segment = 0; int end_of_segment = 0; for(int pt=0; pt<npoints(0); pt++) { setpointattrib(0, "id", pt, current_segment); int intersect = point(0, "intersect", pt); if(intersect >= 0) { if(!end_of_segment) { end_of_segment = 1; current_segment++; } } else end_of_segment = 0; } In the scene, I noted that it's a bit easier to do this if you do not have the "doubled intersect" around each segments, so there's a second method that's a bit easier to follow. Basically, it's a sequential algorithm. For each point.. We assign current_segment to the current point. Is the current point the end of a segment ? If yes, we increment current_segment by one. There's some logic to handle the "doubled intersect", otherwise current_segment would increase by 2 at the end and start. Does that work for you ? intersect segment id.hiplc 1 Quote Link to comment Share on other sites More sharing options...
canevar Posted Thursday at 07:10 AM Author Share Posted Thursday at 07:10 AM Thanks Alain! That works beatifully. You saved me from falling into desperation. So simple problem and yet I could not come up with a solution. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.