Primnum Confusion

   7477   4   2
User Avatar
Member
50 posts
Joined: Nov. 2016
Offline
Hello, I am having a bit of trouble understanding primnum in the code bellow. I read the documentation and around forums but I am still stuck. Just to note I do not have a programming background of any kind.

Looking at the code it makes it look as if it will always be right for the first “if”. I understand it, as if primnum will always be equal to max_nm in the case bellow. From what I could find for primnum, it's the id of the current primitive.

neighs_pcheck_all[]- the array contains all primitives more than once
int max_nm = max(neighs_pcheck_all) ;
for (int nm=0; nm<=max_nm; nm++)
{
        if (nm != @primnum)
        {
                found=0;
                foreach (int n; neighs_pcheck_all) 
                {
                        if (n == nm)
                        {
                                found++;
                        }
                }

                if (found>1 & found%2==0)
                {
                        append(neighs_prims ,nm);                }
        }
}
Edited by malexander - June 6, 2017 15:10:11
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
for (int nm=0; nm<=max_nm; nm++)
nm counts up until max_nm is reached

if (nm != @primnum)
only execute the following code inside {} if the current, up counting nm value is not equal != to the current primitive number.
Edited by Konstantin Magnus - June 6, 2017 16:38:55
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
50 posts
Joined: Nov. 2016
Offline
I don't have an issue with understanding the for loop, but rather from where does the current primitive number come from. Isn't it the one that its being currently worked one, which from my understanding (most likely wrong) is the same as the value of “nm” per loop.
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
the whole wrangle can be seen as a loop itself that runs over all points, prims, vertices or elements (at least if you leave the group field empty).
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
50 posts
Joined: Nov. 2016
Offline
Yeah, now I understood it. For a moment I got stuck at the code logic again but then I remembered that the wrangle sop loops over the whole code rather than parts of it. Silly I know…
Thanks Konstantin
  • Quick Links