GlennimusPrime Posted March 13, 2022 Share Posted March 13, 2022 This is my first time diving into arrays. I'm using the pccone function to search for points in a particular direction, then colour them red. This is working fine until I bring an if statement into play.. I'm asking if the points in the array are white, then change their colour to red. This seems to change all white points to red, not just the ones in the array. I don't think I'm understanding arrays, or possibly even if statements correctly. File attached Array_Problems.hipnc Quote Link to comment Share on other sites More sharing options...
Librarian Posted March 13, 2022 Share Posted March 13, 2022 @GlennimusPrime Just download Fe-Elf from GitHUb.. you have FeE point Cloud Open that have 100000 Possibility ...with many examples.. Quote Link to comment Share on other sites More sharing options...
Atom Posted March 13, 2022 Share Posted March 13, 2022 Try something like this. int x[] = pccone(0, "P", {0,0,0}, {0,1,0}, 0.25, 1, 1000); foreach(int point; x){ vector candidate_Cd = point(0,"Cd", point); if(candidate_Cd=={1,1,1}) setpointattrib(0, "Cd", point, {1,0,0}); } Quote Link to comment Share on other sites More sharing options...
GlennimusPrime Posted March 13, 2022 Author Share Posted March 13, 2022 @LibrarianThanks for the heads up on Fe-Elf, there looks to be a lot of handy tools in there! I'll take a bigger dive into this sometime soon. @Atom Thank you so much for this example, it's helping me better understand what's going on here. Probably just because I'm new to this, but it seems strange to first declare a new vector attribute called 'candidate_Cd' rather than using Cd that is already on those points. Is that what's going on here? Anyhow, this is working for me. Cheers for the help! 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted March 13, 2022 Share Posted March 13, 2022 (edited) It's because pccone returns a list of point numbers. Those points contain the Cd value you want to evaluate, not the point you are running over. Remember, you're evaluating that loop for every single point, which might be a little redundant. Edited March 13, 2022 by Atom Quote Link to comment Share on other sites More sharing options...
GlennimusPrime Posted March 14, 2022 Author Share Posted March 14, 2022 @Atom Hmmm, maybe I'm not doing this the most efficient way then. I'll explain what I've been trying to do: I'm wanting to search only upwards and to detect if the point above is white - and if so, change its colour to red. I was using the pccone formula, as I thought this was the only way to search in a specific direction, rather than something like pcfind which searches out in all directions. Or, were you saying it is not the best idea to run this over every single point, as it will end up being pretty slow? Quote Link to comment Share on other sites More sharing options...
GlennimusPrime Posted March 15, 2022 Author Share Posted March 15, 2022 Maybe I'm asking about this wrong.. Is there a way to run an if statement ONLY on the points found in the array? As @Atom pointed out, it seems I am evaluating the if statement on all points. Quote Link to comment Share on other sites More sharing options...
bunker Posted March 16, 2022 Share Posted March 16, 2022 you should be running this code over "Detail (only once)" 1 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.