dyei nightmare Posted August 19, 2017 Share Posted August 19, 2017 (edited) i have this in a wrangle, and i want to asign the Cd value only to the points returned by the point cloud, what is the correct way to do it? i have this atm, but whats then the apropiate syntaxis to do it? edit: setpointattrib doesnt work in this case i dont know why... it just assign Cd to everything int hnd = pcopen(0, "P", @P, 1, 3); int sourceGoals[]; int valor[]; vector valorcd = {1,0,0}; while(pciterate(hnd)){ int sourceGoal; pcimport(hnd,"Pnum",sourceGoal); push(valor,sourceGoal); push(sourceGoals,sourceGoal); } foreach (int i; valor){ @Cd = valorcd; } i[]@ptvalor = valor; Edited August 19, 2017 by dyei nightmare Quote Link to comment Share on other sites More sharing options...
jujoje Posted August 19, 2017 Share Posted August 19, 2017 Use pcfind and a foreach? So something like: //Set color to black @Cd = 0; // Pc find float radius = ch("radius"); int maxpoints = ch("max_points"); int pointcloud[] = pcfind(1, "P", @P, radius, maxpoints); foreach( int point ; pointcloud){ @Cd = {0,1,0} ; } I think that's what you were looking for... pcfind_example.hiplc 1 Quote Link to comment Share on other sites More sharing options...
dyei nightmare Posted August 19, 2017 Author Share Posted August 19, 2017 thanks a lot, whats the diference with pcopen? i dont see in reference which cases are better to use pcfind or pcopen Quote Link to comment Share on other sites More sharing options...
jujoje Posted August 19, 2017 Share Posted August 19, 2017 From my understanding the Pc find is a convenient way to iterate over a point cloud; it returns an array of the points and then, typically, you run those points through a foreach. This is roughly equivalent to doing a pc open and using a while loop to iterate over the points. Which makes your code/vop network much shorter and cleaner Quote Link to comment Share on other sites More sharing options...
jujoje Posted August 19, 2017 Share Posted August 19, 2017 Also it takes point groups / expressions. E.g.: // Set Cd @Cd=0; // pcfind float radius = ch("radius"); int maxpoints = ch("max_points"); // Mask string string mask = "@P[0]>0.5"; int pointcloud[] = pcfind(1, mask, "P", @P, radius, maxpoints); foreach( int point ; pointcloud){ @Cd = {0,1,0} ; } Will only look at the points whose x position is greater than 0.5 pcfind_mask.hiplc 2 Quote Link to comment Share on other sites More sharing options...
dyei nightmare Posted August 20, 2017 Author Share Posted August 20, 2017 thanks a lot thats great, is pcfind able to retrieve another channels besides position? if so, there is no need anymore to have pcopen Quote Link to comment Share on other sites More sharing options...
dyei nightmare Posted October 18, 2017 Author Share Posted October 18, 2017 this is weird, i dont remember when i asked this, but ive found that pcfind is a lot faster. 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.