Jump to content

Creating a Subway network in VEX


konstantin magnus

Recommended Posts

I am trying to create a subway network with VEX.

In order to define individual end stations I assigned all points to sectors according to their radial position. Now I am looking for a way to find the bluest/greenest point for each sector.

 

subway_end_stations.jpeg

i@result shows me the best match for all the points, but how can I loop through groups (i.e. "sector_0", "sector_1" and so on) and put all matching points into one array?

vector seek_clr = {0,1,1};

//Finds points with a similar color
int pcloud = pcopen(0, "P", @P, 0.4, 6);
int closecolor[] = pcfind(0, "sector_0", "Cd", seek_clr, 2, 5);
i@result_0 = closecolor[1];

 

vex_subway_sectors.hipnc

Edited by konstantin magnus
Link to comment
Share on other sites

22 minutes ago, konstantin magnus said:

No, thats not it. I think I just need to know how to use point clouds inside for loops.

i dont get it why you are using closestpoint, 

you want to find the bluest/greenest color value for each sector and store the bluest/greenest from each sector to a list right ? 

Link to comment
Share on other sites

colors and positions are interchangeable I hope. thats why pcfind should also be able to look for colors in points.

Maybe I have to

  • iterate through point groups
  • use separate arrays for each sector
  • to finally assign the first entries of each array to one big array

Or is there an easier solution?

Edited by konstantin magnus
Link to comment
Share on other sites

I found a solution:

vector seek_clr = {0,1,1};
int sectors = detail(0, "sectors", 0);
i[]@result[sectors];

int pcloud = pcopen(0, "P", @P, 0.4, 6);
for(int i = 0; i < sectors; i++) {
    string group = s[]@groups[i];
    int closecolor[] = pcfind(0, group, "Cd", seek_clr, 2, 5);
    if(closecolor[1] == @ptnum) setpointgroup(0, "in", @ptnum, 1, "set");
    @result[i] = closecolor[1];
}

 

 

find_color_per_group.jpeg

Edited by konstantin magnus
Link to comment
Share on other sites

for something like this it´s most probably faster to just interate over the points instead of using pcfind. when you rely on pointcloud functions houdini needs to build a kdtree and in your case it has to rebuild the tree for every "sector". since accessing the tree is fast but building it is relatively slow you loose the advantage of using pointclouds.  this becomes even more apparant when you have a high number of "sectors".
anyway, both versions are attached ...

hth.
petz

 

vex_subway_sectors1.hipnc

Edited by petz
  • Like 2
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...