Jump to content

vex function for finding neighbour points


Lucavfx

Recommended Posts

Hello,

In VEX, is there a quick way to determine the list of points within a certain distance from the current point P?

This would ideally be a function where, specified a vector P, returned a list of points within a given parameter radius.

I'm iterating the whole point cloud looking for a matching id but it would be much better if I searched for the matching id in the neibourhood of the current point only, so to speed things up a bit.

Thanks for your help

Luca

Edited by Lucavfx
Link to comment
Share on other sites

Hello,

In VEX, is there a quick way to determine the list of points within a certain distance from the current point P?

This would ideally be a function where, specified a vector P, returned a list of points within a given parameter radius.

I'm iterating the whole point cloud looking for a matching id but it would be much better if I searched for the matching id in the neibourhood of the current point only, so to speed things up a bit.

Thanks for your help

Luca

the Radius parameter in the PC Open VOP is the search radius for each point, is that what you mean?

Link to comment
Share on other sites

the Radius parameter in the PC Open VOP is the search radius for each point, is that what you mean?

I'm currently using a vexsop instead, I've got the result of two popnets cached and the bgeo sequences piped in using two file sops in the two vexsop inputs.

I'm iteraing for all points of input1 and looking for any matching IDs for all points of input2.

Since points with similar ids should be nearby, It would be good to limit the search to a given arbitrary radius around each point, so to skim down computations a bit :)

I'm not familiar with pointcloud vop operations, but it seems quite interesting. Unfortunately there's no help for the pointcloud open node, would you mind showing me an example?

I could then have a look at the vex and extrapolate the code to use in the vexsop I guess..

Thanks

Luca

Edited by Lucavfx
Link to comment
Share on other sites

I'm currently using a vexsop instead, I've got the result of two popnets cached and the bgeo sequences piped in using two file sops in the two vexsop inputs.

I'm iteraing for all points of input1 and looking for any matching IDs for all points of input2.

Since points with similar ids should be nearby, It would be good to limit the search to a given arbitrary radius around each point, so to skim down computations a bit :)

I'm not familiar with pointcloud vop operations, but it seems quite interesting. Unfortunately there's no help for the pointcloud open node, would you mind showing me an example?

I could then have a look at the vex and extrapolate the code to use in the vexsop I guess..

Thanks

Luca

I'm not really sure, has never used it, but PointSOP in Houdini 9.5 has a new option to much points in two inputs based on arbitrary attribute, not just $PT. So it seams that anything you can do with Point SOP can be done on ID bases.

As to point cloud method, it is perfect for that:

sop
 findPointByAttribPC(string pointcloud = "";
						   float  distance   = 1;
						   int	maxpoints  = 10;
						   int	ID		  = 0;)
 { 

	 int handle = pcopen(pointcloud, "P", P, distance, maxpoints);  
	  int pcID;

	 while (pciterate(handle) ) {
		 pcimport(handle, "ID", pcID);
			  if ( pcID == ID ) 
			  {
				// place for code to handle match IDs
		   }
	 }			
 }

Of course another consideration is maxpoints and distance variables. Could be custom or computed from geometry (like npt or bounding box)

cheers,

sy.

Link to comment
Share on other sites

Thanks Symek,

I don't have access to 9.5 at the moment so I think I'll take the pc route. Thanks for the example code. I've got a question though:

My vexsop has two inputs. From your example it seems I only need one input and a string parameter pointing to the second input (pointcloud). Is that right?

Thanks

Luca

I'm not really sure, has never used it, but PointSOP in Houdini 9.5 has a new option to much points in two inputs based on arbitrary attribute, not just $PT. So it seams that anything you can do with Point SOP can be done on ID bases.

As to point cloud method, it is perfect for that:

sop
 findPointByAttribPC(string pointcloud = "";
						   float  distance   = 1;
						   int	maxpoints  = 10;
						   int	ID		  = 0;)
 { 

	 int handle = pcopen(pointcloud, "P", P, distance, maxpoints);  
	  int pcID;

	 while (pciterate(handle) ) {
		 pcimport(handle, "ID", pcID);
			  if ( pcID == ID ) 
			  {
				// place for code to handle match IDs
		   }
	 }			
 }

Of course another consideration is maxpoints and distance variables. Could be custom or computed from geometry (like npt or bounding box)

cheers,

sy.

Link to comment
Share on other sites

Ok done!

it works very nicely.

Thanks a lot

Luca

Thanks Symek,

I don't have access to 9.5 at the moment so I think I'll take the pc route. Thanks for the example code. I've got a question though:

My vexsop has two inputs. From your example it seems I only need one input and a string parameter pointing to the second input (pointcloud). Is that right?

Thanks

Luca

Link to comment
Share on other sites

Ok done!

it works very nicely.

Thanks a lot

Luca

Great. This is my example made previously. Maybe someone can answer how to brake a while() loop in points iteration onces proper ID is found... for now save option requires looping through the all points in the map with max distance specified by bounding box, what is sad.

findpointbyID.hip

Edited by SYmek
Link to comment
Share on other sites

That's pretty much what I came up with eheheh.

However a break in the iteration would be nice indeed :)

As for the distance it depends, in my case I'm lucky I can limit it to about 3-4 times the length of the velocity so to look for matching particles in the neighbour area.

Thanks again

Luca

Great. This is my example made previously. Maybe someone can answer how to brake a while() loop in points iteration onces proper ID is found... for now save option requires looping through the all points in the map with max distance specified by bounding box, what is sad.
Link to comment
Share on other sites

Use break...

if(something_happen) break;

getneighbour() could help to find neighbours.

Thanks hoknamahn. Of course break.

Simon.

PS Isn't the getneighbour() for finding connected points? Not terrible useful in case of point clouds ;)

Link to comment
Share on other sites

Thanks hoknamahn. Of course break.

Simon.

PS Isn't the getneighbour() for finding connected points? Not terrible useful in case of point clouds ;)

In point cloud point doesn't have "neighbour" or in other words all points are neighbours. So which function you are looking for guys? Try to describe the rule first :lol:

Edited by hoknamahn
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...