Lucavfx Posted July 19, 2008 Share Posted July 19, 2008 (edited) 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 July 19, 2008 by Lucavfx Quote Link to comment Share on other sites More sharing options...
SpencerL Posted July 19, 2008 Share Posted July 19, 2008 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? Quote Link to comment Share on other sites More sharing options...
Lucavfx Posted July 19, 2008 Author Share Posted July 19, 2008 (edited) 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 July 19, 2008 by Lucavfx Quote Link to comment Share on other sites More sharing options...
symek Posted July 20, 2008 Share Posted July 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
Lucavfx Posted July 20, 2008 Author Share Posted July 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
Lucavfx Posted July 20, 2008 Author Share Posted July 20, 2008 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 Quote Link to comment Share on other sites More sharing options...
symek Posted July 20, 2008 Share Posted July 20, 2008 (edited) 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 July 20, 2008 by SYmek Quote Link to comment Share on other sites More sharing options...
Lucavfx Posted July 20, 2008 Author Share Posted July 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted July 25, 2008 Share Posted July 25, 2008 (edited) Use break... if(something_happen) break; getneighbour() could help to find neighbours. Edited July 25, 2008 by hoknamahn Quote Link to comment Share on other sites More sharing options...
symek Posted July 25, 2008 Share Posted July 25, 2008 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 Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted July 26, 2008 Share Posted July 26, 2008 (edited) 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 Edited July 26, 2008 by hoknamahn Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.