Macha Posted February 13, 2014 Share Posted February 13, 2014 Does anybody know how to loop over points and get the pointgroup each point belongs to? Quote Link to comment Share on other sites More sharing options...
Hudson Posted February 13, 2014 Share Posted February 13, 2014 Hey Macha, Can't provide the hip atm but try this: 1- pipe your points into a VOPSOP, 2- create a for/while loop inside the vopsop that iterates as many times as the number of point groups (using the pointgrouplist() ).2- Inside the while or for loop you can use an ingroup-VOP and check if the point belongs to the specified group being iterated. You can then apply those to an array and convert to a list of strings or whatever you want I will take a look at this solution. But it should work Cheers, Huds Quote Link to comment Share on other sites More sharing options...
Macha Posted February 13, 2014 Author Share Posted February 13, 2014 (edited) Hey, thanks but I wanted to do this with the HDK. So far, this is my attempt, but I think it just gives me all the groups, and how many are in each group but now what? const GA_ElementGroupTable & grpTable = gdp->getElementGroupTable(GA_ATTRIB_POINT); for (GA_GroupTable::iterator<GA_ElementGroup> it=grpTable.beginTraverse(); !it.atEnd(); ++it) { GA_PointGroup *group = static_cast<GA_PointGroup*>( it.group() ); cout << "groups?" << group->entries() << endl; } Edited February 13, 2014 by Macha Quote Link to comment Share on other sites More sharing options...
Hudson Posted February 13, 2014 Share Posted February 13, 2014 Oh you want to do it in HDK. Then I can't help you sir. Still noobing around with vex, hehe. But if it helps, the vex code to check if the point belongs to a group is: ingroup( "group" , ptnum ); If you find out how to write that vex-function in HDK then you are settlet I think. If the case is that your loop goes through all point groups. Man I feel ashamed I haven't written anything in HDK . Anyhow I hope someone else will show you the missing piece. GL Macha! Quote Link to comment Share on other sites More sharing options...
graham Posted February 13, 2014 Share Posted February 13, 2014 There isn't a direct mapping between a point and it's group since the points can definitely be in 0 or more groups. You'd probably just want to iterate over every point and for each point iterate over all the point groups and see which, if any, the point belongs too. Quote Link to comment Share on other sites More sharing options...
Macha Posted February 13, 2014 Author Share Posted February 13, 2014 Would this be OK? It seems to work. void inGroup(const GU_Detail *gdp) { using namespace std; GA_PointGroup* grp; GA_FOR_ALL_POINTGROUPS(gdp, grp){ GA_Offset ptOff; GA_FOR_ALL_PTOFF(gdp, ptOff){ if (grp->containsOffset(ptOff)){ cout << "Point[" <<ptOff<<"] in group: " << grp->getName() << endl; } } } } Quote Link to comment Share on other sites More sharing options...
Macha Posted February 14, 2014 Author Share Posted February 14, 2014 I've actually got a really annoying problem with inlinecpp. Very often I get a compile error: GeometryPermissionError: Geometry is read-only. You cannot pass a read-only hou.Geometry object to a function expecting a non-const GU_Detail * But the code all looks fine. I then have to exit Houdini, close the shell, reopen, restart and the whole thing works again. Has anybody experienced this? Quote Link to comment Share on other sites More sharing options...
graham Posted February 14, 2014 Share Posted February 14, 2014 Don't think I've seen that one before. Assuming the function is the same as the previous post (with a const GU_Detail *) I don't see why Houdini would ever complain about with that error. Are you on Windows by chance? I seem to recall inlinecpp being more difficult there. 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.