Jump to content
Sign in to follow this  
Macha

Point groups

Recommended Posts

Does anybody know how to loop over points and get the pointgroup each point belongs to?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 by Macha

Share this post


Link to post
Share on other sites

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  :unsure:.

 

Anyhow I hope someone else will show you the missing piece.

 

GL Macha!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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;
            }
          
        }
      
    }

}

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×