Jump to content

Looping Through Edges


Recommended Posts

Hi,

Anyone know the quickest way to loop through all the edges in a gdp?

I have a way to do it but it's totally inefficient because I loop through all the primitives and all the edges in all the primitives, which means you end up visiting the edges more than once.

I could also do with a quick way to invert an edge group. At the moment I add all the edges in the gdp and then loop through removing the ones I don't want, again this is really slow.

cheers

Link to comment
Share on other sites

Hi Simon,

For looping through edges you could try the GQ library. It can build a quad-edge representation of your gdp. It has limitations though. The other thing you could try is a GEO_PointRefArray. The PointRefArray gives you, for each point, the list of primitives using that point. So instead of looping through primitives, you could loop through points and therefore visit each edge only once. Also, have a look at GEO_Closure. There are helper methods in there that make use of a PointRefArray to do edge-related things. Both GQ and PointRef need to scan your entire gdp to get started, so it could be slow to build those structures -- though it is supposed to be a one time cost.

Hope that helps.

George.

Link to comment
Share on other sites

Hi George,

I using GEO_Closure already, I'm using findPolysUsingEdge for each edge in each gdp poly.

I thought about looping through points, but I'm confused as to how that would work. If am at a point it might be connected to many edges, then when I get around to one of those points at the other end of an edge it will be connected back to the original point so I'll still end up visiting the edge twice. Or are there quick methods in GEO_PointRefArray to remove points that have been used already?

thanks

Link to comment
Share on other sites

Hi Simon,

I don't think there are any methods in GEO_PointRefArray that will allow you to remove points, you'd have to setup your own data structure for that (maybe as simple as a UT_BitArray to mark visited points)?

The other method I forgot to mention is GEO_Primitive::edgeApply() which maybe helpful also. You can loop through all the primitives and call edgeApply() and keep track of the points -- it might simplify some code.

Hope that helps,

George.

Link to comment
Share on other sites

  • 7 months later...

Just looking at this again for a different reason and coming from another direction is there a quick way to change a prim group into an edge group? or do you have to loop through all the edges in the prim group and add them one at a time.

What I'm actually after is an edge group that contains all the edges in the gdp.

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