Finding the next nearest point along edge

   10334   12   4
User Avatar
Member
41 posts
Joined:
Offline
I have a jagged line with oddly ordered points, that Sort SOP is incapable of fixing.

Is there an expression or some method to start with one end of the line and find each next point?

Since the line is jagged, using nearpoint() finds points that are not the next one along the edge.

I can see the points connected by edges, but can't seem to find any info on how to use what I see.

Any one else run into this problem and find a way around it??
~adam
User Avatar
Member
1390 posts
Joined: July 2005
Offline
What about sorting “By Vertex Order” in SortSOP? Doesn't help also? If your points belong to the curve it should work. Post a hip file in case of trouble.

cheers,
sy.
User Avatar
Member
41 posts
Joined:
Offline
Sorting by vertex using the Sort SOP doesn't work. It reorders the points, but not in the expected way. See the attached example.

Attachments:
sort_vertex_error_1.hip (45.5 KB)

~adam
User Avatar
Member
1390 posts
Joined: July 2005
Offline
I have no idea how to deal with such cases in general. This is not a curve, there are several polygons in that edge. Sorting with Z-axes worked fine here, but I'm not sure for what purpose you need this reordering, so hard to judge if this is what you want.

There is an expression returning nearest point belonging to the same polygon as I remember (?) (or you can search for a nearest point with additional expression conditioning polygon membership). But this wouldn't work with “messy” issues also I suspect.
User Avatar
Member
537 posts
Joined: Dec. 2005
Offline
Maybe this will help .. I've needed to do this in the past, so I've been meaning to make an easy solution for it.

This method finds 1st,2nd, up to 10th nearest pts. I used mainly CHOPs, but I don't think this solution is near as elegant as it could be with a python CHOP.

I made the basic method into a digital asset and should be pretty easy to use. I think this would be best implemented with copy-stamping attributes though, and dealing only (at the user level) with geometry and not CHOPs. Let me know if you can get this to work for your application

Attachments:
get_next_nearest_pt.zip (27.4 KB)

User Avatar
Member
41 posts
Joined:
Offline
It's really neat to see the way you used CHOPs to do all that. I never thought of using it that way. Very creative.

Just like the expression nearpoint(), it works for finding the nearest point in space. I can't get it to find the next point on the line though. …which is what I'm trying to do. Does it do that?
~adam
User Avatar
Member
537 posts
Joined: Dec. 2005
Offline
No, I haven't tried that out yet .. but if you look inside the DA, it was necessary to do an “exclusion” as soon as the resulting tests were already performed. Perhaps you could use a silmiar technique to do the exlusion based on non-connected polys?
User Avatar
Member
41 posts
Joined:
Offline
I guess the burning question is…
Does Houdini provide a way to tell if two points are connected by an edge?

If this is possible, the we could use a method like yours andrewlowell to find the next point and store it in an array to prevent it from being looked up again…thus finding the true next point regardless of it's point number or position.
~adam
User Avatar
Member
41 posts
Joined:
Offline
After looking at it further, your right SYmek. Sorting by vertex would work on a single line like I want, but the error I am experiencing is caused by multiple primitives making up what looks like a single line.

Now, I feel like a shmuck going on and on about finding the next point on a line. I'm also stumped at how to deal with these types of errors produced by a Cookie SOP (see error example attached).

Attachments:
sort_vertex_error_1.hip (45.5 KB)

~adam
User Avatar
Member
2199 posts
Joined: July 2005
Online
Try turning off consolidate edges in the cookie sop and then use a divide sop with remove shared edges turned on…

Alternatively, just use the crease option on the cookie sop.
The trick is finding just the right hammer for every screw
User Avatar
Member
41 posts
Joined:
Offline
Thanks for the tip Simon, it works!

It's good to know that this can be solved with the Divide SOP, because I run into this problem with operations outside a Cookie SOP.

Attached are the the two approaches you outlined.

Attachments:
sort_vertex_error_fixed.hip (81.3 KB)

~adam
User Avatar
Member
2199 posts
Joined: July 2005
Online
By the way, if you only ever do straight cuts you should concider the clip sop, its way more stable…
The trick is finding just the right hammer for every screw
User Avatar
Member
41 posts
Joined:
Offline
Good to know, I've never even used it :?
~adam
  • Quick Links