Jump to content

How can I create an id attribute from this intersect attribute?


canevar

Recommended Posts

image.thumb.png.d84f84b59a2232b4cb517fdbdf703587.png

// 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

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...