morzh
Jan. 24, 2012 16:39:31
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 ?
Ondrej
Jan. 25, 2012 16:47:56
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());
}
}
}
morzh
Jan. 26, 2012 08:56:46
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.
symek
Jan. 26, 2012 09:00:09