Jump to content

whats the correct way to asign Cd to an array?


Recommended Posts

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 by dyei nightmare
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 :) 

 

Link to comment
Share on other sites

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

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

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