Jump to content

Method similar to Neighbour, but with unconnected points


Recommended Posts

Hey guys,

 

I have scattered points on arbitrary geometry and I am trying to connect them by doing a random walk.  I will start with one point, pick a random next point from neighbours, etc. etc.

 

Currently, I am using a point cloud in vops to find the nearest neighbour counts in a given radius.  I am basing some of my thinking process on this implementation of Dijkstra's algorithm

His basic process is:

1. create a hi-res grid (quads) and count each point's neighbours (using neighbourCount in vops)

2. use forEach to count up first N neighbours and save each neighbour number as attribute ( neighbour1, neighbour2, neighbour3, etc.)

3. uses these neighbour ID attributes in a python sop later for easy lookup of nearby points.

 

In it, he is using the fact that all points are connected to find a path on a surface.  Unfortunately, don't have the luxury of working with already connected points (from using the scatter sop) and I don't have much experience with the point cloud nodes.  Is there a way to retrieve the nearby point ids from unconnected points?  I know the radius and number of points.

 

Any suggestions to point me in the right direction would be great.

 

Thanks!!

Link to comment
Share on other sites

you have several options

1. if your points are more or less on planar surface (like terrain or something) you can just:

create rest attribute (rest SOP)

Triangulate 2D SOP

move points to original positions (AttribWrangle SOP: v@P = v@rest)

that will connect your points with lines that don't cross each other

 

2. you can connect neighbour points with lines (H13):

AttribWrangle SOP:

int nbrs = 5;
float radius = 1;
int nbrid;
string nbrids = "";

void line(int point1; int point2)
{
    int prim = addprim(0, "polyline");
    addvertex(0, prim, point1);
    addvertex(0, prim, point2);
}

int handle = pcopen(@OpInput1, "P",@P,radius, nbrs+1);
for(int i=1;i<pcnumfound(handle);i++)
{
    nbrid = pcimportbyidxi(handle, "point.number", i);   
    line(@ptnum, nbrid);
}

then append Clean SOP (Fix Overlaps but uncheck Delete Overlap Pairs )

to remove duplicate lines

 

3. similarly you can use Connect Adjacent Pieces (Adjacent Points mode)

but you would need to copy primitive (like sphere) on each point

then Assemble SOP so you'll get primitives with name attribute that Connect Adjacent Pieces recognizes

 

4. you can gather neighbour points as a string attribute with space separated ids for further Python processing as you wanted (h12.5)

AttribWrangle SOP:

int nbrs = 5;
float radius = .5;
int nbrid;
string nbrids = "";

int handle = pcopen(@OpInput1, "P",@P,radius, nbrs+1);

for(int i=1;i<pcnumfound(handle);i++)
{
    nbrid = pcimportbyidxi(handle, "point.number", i);   
    nbrids += itoa(nbrid) + " ";
}
s@neighbour_ids = nbrids;

 

 

  • Thanks 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...