HDK: FOR_ALL_OPT_GROUP_POINTS

   2534   4   0
User Avatar
Member
66 posts
Joined: Oct. 2008
Offline
I have two groups of points and i want to connect the points from the first group to the points from the second group. But that is not working (the second group is ignored). The code is:


FOR_ALL_OPT_GROUP_POINTS(gdp, sourcePoint_group, current_point1){


FOR_ALL_OPT_GROUP_POINTS(gdp, pointConnectTo_group, current_point2){

dist = distance3d(current_point1->getPos(), current_point2->getPos());

if (dist < 5) SOP_connectPoints::makePolygon(current_point1, current_point2);

}
}

What i'm doing wrong ?
User Avatar
Staff
1072 posts
Joined: July 2005
Offline
I see no reason why those macros shouldn't nest correctly.

I tested the following code and it behaved as expected. Maybe your second group is empty? A non-null empty group will be traversed like any other group by that macro.


GB_PointGroup *pgroup1, *pgroup2;
pgroup1 = gdp->findPointGroup(“group1”);
pgroup2 = gdp->findPointGroup(“group2”);
if (pgroup1 && pgroup2)
{
GEO_Point *p0, *p1;
FOR_ALL_OPT_GROUP_POINTS(gdp, pgroup1, p0)
{
FOR_ALL_OPT_GROUP_POINTS(gdp, pgroup2, p1)
{
fprintf(stderr, “%d,%d\n”, p0->getNum(), p1->getNum());
}
}
}
User Avatar
Member
66 posts
Joined: Oct. 2008
Offline
Ondrej, thank you for the answer. Yep, the problem is in my groups. I guess it rises from using cookInputPointGroups “two times”.



GB_PointGroup *pgroup1, *pgroup2;

OP_ERROR SOP_connectPoints::cookPointGroups(OP_Context &context, int alone){

return cookInputPointGroups(context, pgroup1, myDetailGroupPair, alone);

}

OP_ERROR SOP_connectPoints::cookPointConnectToGroups(OP_Context &context, int alone){

return cookInputPointGroups(context, pgroup2, myDetailGroupPair2, alone);

}


So i wrote the deployed function (e.g. like in SOP_flatten.C) for my second group cooking and all works fine.
User Avatar
Member
1390 posts
Joined: July 2005
Offline
morzh
they can't be nested ?


http://www.sidefx.com/index.php?option=com_mailarchive&Itemid=212&view=WEB&msgid=BANLkTimWXEFp0MBbeq1Cut=3N5AHRVkuRw@mail.gmail.com&perpage=20&revdate=off [sidefx.com]

Hey!
It was a human error in my case. My second loop hadn't a body, as I put a semicolon right after it. Oh, well…
  • Quick Links