How do I create points on the line

   3257   6   1
User Avatar
Member
3 posts
Joined: Aug. 2023
Offline
Hi,I want to programmatically add points on line at a specified location. But the point I created with the add node does not belong to the specified line. Can anyone tell me which node I should use? Or how do i create points on the line with VEX

Attachments:
Snipaste_2024-06-20_15-08-48.png (495.5 KB)
Snipaste_2024-06-20_15-10-01.png (553.4 KB)

User Avatar
Member
34 posts
Joined: July 2022
Offline
delete the original line, add points and reconnect in order
User Avatar
Member
3 posts
Joined: Aug. 2023
Offline
juejuezi
delete the original line, add points and reconnect in order
Thank you for your reply!

I have to deal with a lot of complicated road vector lines. Each line goes in a different direction, how do I sequence it so that it successfully connects to the original direction.

Another method I tried was to calculate the length of a line and then use the refine node to add points,but there are too many segments on a broken line,I think the calculation is a little bit tedious and multiple points may be added to a line. I don't know if there are other efficient ways to do it.

One of the lines is shown here.

Thank you!

Attachments:
Snipaste_2024-06-21_10-05-56.png (391.1 KB)

User Avatar
Member
34 posts
Joined: July 2022
Offline
feishikath
juejuezi
delete the original line, add points and reconnect in order
Thank you for your reply!

I have to deal with a lot of complicated road vector lines. Each line goes in a different direction, how do I sequence it so that it successfully connects to the original direction.

Another method I tried was to calculate the length of a line and then use the refine node to add points,but there are too many segments on a broken line,I think the calculation is a little bit tedious and multiple points may be added to a line. I don't know if there are other efficient ways to do it.

One of the lines is shown here.

Thank you!

Since there are so many lines, what are the rules for adding points to each line?

My question is, which line to add how many points to, and based on what rules, such as length. Otherwise, I won't be able to write Vex
User Avatar
Member
84 posts
Joined: July 2018
Offline
I think what @juejeuzi is getting at is that a little more info on what you are trying to accomplish in the big picture would be helpful. There's different ways to approach this and I might suggest one over another depending on why you want add these points, how many you need to add, and how you are determining where they should go.

You could add and use a curveu attribute to give you positions along the line so that you can add new points while maintaining the vertex order and direction of the rebuilt primitives.

But if what you're trying to ultimately do is create some kind of road builder and add branching off points for new roads that branch off from the main trunk, my mind starts going somewhere completely different. I might even start thinking about L-systems, or growth systems to create your road network.

There's lots of ways to skin a cat...
madebygeoff.com
User Avatar
Member
3 posts
Joined: Aug. 2023
Offline
In general, I need to merge multiple lines of road into one line. The road vector line data comes from OpenStreetMap. It may be drawn manually on the map, so it seems that there is no fixed rule.

For example, for a two-lane road, I need to first determine whether it is a two-lane road, and then I am asked to merge the corresponding points of the two-lane road.
This means that if one line has a point but the other corresponding position does not have a point, I need to add a point at that position and then merge it.
I can programmatically calculate the coordinates of where to add the point, but I can't programmatically add it to the line.

I was asked to do this, but I actually think this might not be a good idea.

As shown in the figure, the red dots are where the points need to be added, and there is also an actual road map with the lines that need to be merged marked.

Attachments:
Snipaste_2024-06-24_17-58-04.png (607.3 KB)
Snipaste_2024-06-24_17-57-55.png (607.6 KB)
Snipaste_2024-06-24_18-18-21.png (882.9 KB)

User Avatar
Member
5104 posts
Joined: Feb. 2012
Offline
Hi,

If you want to do this in VEX, you would have to recreate each primitive i.e. line. First you would find the adjacent points to the point to be added and then insert this point position to the list of existing point positions. Make sure to do this for all the new points first so that you don't have to recreate the same line multiple times, but only once.

If you need to preserve point, primitive, vertex attributes and groups, it gets a lot more involved since you will have to store the appropriate weight values to pass to multiple Attribute Interpolate nodes.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
  • Quick Links