Jump to content

Updating Gb_pointrefarray


Recommended Posts

Ok, so I got the trivial case working and I thought I'd try something a bit cleverer. But ran into this problem. I'm now looping through the gdp selecting an edge, removing it, then looping through the gdp again to find the next edge, and so on. This is so I don't end up removing too many edges and thus destroying the original completely.

The problem is this: I think when I loop back over the gdp the current GB_PointRefArray (prefarr) is then no longer valid and on anything other than a grid Houdini seg faults. So what is the way to update the GB_PointRefArray? I don't think I can just redeclare it, so how to tell it the gdp has changed?

:blink:

Any pointers....

Link to comment
Share on other sites

I think you're right, if you delete some points or merge some primitives (which the edge deletion code may be doing), the older point ref array will now point to deleted memory and crash.

You could always create the point ref array dynamically (new GB_PointRefArray(gdp)) and then delete it and re-create it after each block of changes. However, that is extremely inefficient. There is some code in GB_PointRefArray that allows you to remove point references or change vertex references. In GEO_PointRefArray, there is a way to add primitives. But I don't see a nice way to remove primitives.

The contents of a point ref array are not opaque, so you can go in and loop through all the point-refs and find the ones with the deleted primitives and get rid of them. But that seems a bit tedious. Another common approach is that instead of actually deleting the edges, simply gather them in a 'trash' group and then delete them all at once at the end. That might work well for you if your algorithm is easy to adapt so that it can handle these edges that are 'pending deletion'.

Those are my first thoughts. If I come up with something else, I'll post.

Hope that helps.

George.

Link to comment
Share on other sites

Yeah, maybe the idea of marking them as pending deletion is the best way to go. That was how I started out, creating a group of edges then just zapping them all at once. I guess if the point ref array is so fiddly to update it might be better to do some recursive checks before adding the edge rather than removing them one at a time.

Might try the inefficient dynamic method just to see if the algorithm is effective first though.

ta for your thoughts very helpful.

:)

Link to comment
Share on other sites

Got it working by just adding to the edge list and checking to see if a connected prim already has an edge in the list.

For another part of the algorithm I'd like to use the dynamic adjustment of the prefarr if I can. I tried this

    delete prefarr; //line 322
    prefarr = new GB_PointRefArray(gdp,0); //line 323

but the compiler throws an error.

SOP_TriToQuad.C(322) : error C2064: term does not evaluate to a function taking 0 arguments class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments

SOP_TriToQuad.C(323) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'GB_PointRefArray *' (or there is no acceptable conversion)

At this point I'm a bit lost, my C++ isn't up to this yet, any pointers (excuse the pun)

Link to comment
Share on other sites

I've actually got round this now a different way. I ended up just extending what I already had, by making this part of the code add to the edge group ready for deletion at the end. I don't have the code that was broken anymore so I can't remember how it was declared. I think I know what the answer is now though. If I need to do this again and run into problems I'll post it up.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...