Home
Reply
Regular Contributor
sawarsi
Posts: 53

strange coedge traversal

i have a WIRE * acis_wire and i get its coedge = acis_wire->coedge();

 

now if i do something like:

 

do {

     printf("%p\n",coedge);

 

     DO_SOMETHING_WITH_COEDGE;

 

     coedge = coedge->next();

 

     if(!coedge || coedge == acis_wire->coedge) break;

} while(1)

 

i notice that for one particular SAT file i get different pointers for a while and then i get a situation where it then begins to bounce between two different coedge pointers. is this some special type of WIRE or coedge that i can detect to avoid an infinite loop?

 

Spatial Employee
asdf
Posts: 93

Re: strange coedge traversal

Hi Sawarsi

 

There are two issues here.  For wires traversing coedges is different then traversing coedges in a loop.  I think sometimes wires are terminated by the condition coedge == coedge->next(); adding this as a termination condition in your loop might fix the issue.

 

Rather than getting into low level details of traversing coedges, you might also consider using api_get_coedges which should correctly find all the coedges in any wire.

 

If neither of these works there could be problems with the model.  One thing you could do is have a loop counter and throw and error if it gets ridiculously high (e.g., 10k coedges in one loop).  This is better than hanging and has very little overhead.  Another approach that could work is to keep an ENTITY_LIST of coedges you have already seen and change the second termination criterion from coedge == acis_wire->coedge to coedges_already_seen.lookup(coedge) != -1.

 

hope this helps.

 

Eric

Regular Contributor
sawarsi
Posts: 53

Re: strange coedge traversal

than Eric, the api_get_coedges did the trick.