Some common (unanswered) quiestions

Hi everybody,

I've checked the forum and found no solutions for some common questions. Please notify me if anyone anywhere has ever found anything usefull in these topics:

OCAF is a too complex and oversized datastruct for most of us, but additional attributes are required for the Topos. (Ex. a material for the faces)
1. Hashcode and the TopTools_DataMapOfShape*** can be used till no save/load is required.

2. Someone suggested to rewrite the BRepTools::Write. Has anyone done so?

3. How can be the attributes maintained during a complex operations (like Fuse) ?

4. Is there a well defined ordering for the TopExp_Explorer ? That's if I create a solid and save it. The TopExp_Explorer will create the same sequence of TopDS_Shape for both the generated and loaded solid, or not?

These topics were mentioned far back in 2002 but no good solutions were given (actually none). I doubt if there were no solutions - or is it such a huge secret?

Thanks.

Francois Lauzon's picture

To answer point 2. have a look at thread http://www.opencascade.org/org/forum/thread_6309/

Rob Bachrach's picture

1. Yes, that works fine.

2. I ended up creating my own BRep_ShapeSet. It involves creating your own copies of BRepTools_ShapeSet, TopTools_ShapeSet, TopTools_LocationSet, GeomTools_Curve2dSet, GeomTools_CurveSet, and GeomTools_SurfaceSet. It required a decent amount of work up front, but gave me a lot of flexibility later.

3. After performing a boolean operation, you can use the Generated, IsDeleted, and Modified functions to analyze the completed shape. Those in the Modified list should still map OK. You would have to set the appropriate properties on the Generated items. Likewise, you would have to remove deleted items from your map.

4. No, the ordering from the explorer is not guaranteed to be the same between generating and loading (and often is not). But, if you use the BRepTools_ShapeSet used to write the geometry and then write the shape references using shapeSet.Write(shape, stream) and read them with the corresponding read function, it works pretty well. I did have to modify these functions in my copies to maintain the correct location and orientation on the references.

I hope this helps. Sorry, I can not provide code examples, but company confidentiality information prevents it.

Roman Lygin's picture

Rob, Ernest,

4. TopExp_Explorer does guarantee the determenistic (repeatable) iteration sequence, since it works on list of shapes (field of TopoDS_TShape). I'd be interested to see the example where it does not.
Save/load don't change the sequence as they also operate with lists.

HTH.
Roman

Rob Bachrach's picture

Roman,

I am only speaking from personal experience as I tried the same way of tracking selected items in my data file. Granted, once a file has been saved, the TopExp_Explorer works the same after every load. It does not, however, work the same between the initial generation and the first load. I believe that this occurs because the ShapeSet creates the file by writing the shape and then recursing through all its subshapes. This stores the file in a definite tree structure. TopExp_Explorer, however, simply iterates through the shapes using a TopoDS_Iterator that works based on the order in which the shapes were created.

At least I believe this is the case.

Rob

Roman Lygin's picture

Hi Rob,

What is certain is that as soon as you have a TopoDS_Shape instance (in memory) then saving – loading will always produce the same TopoDS_Shape.
That means you might loose determinism *before* you have initial TopoDS_Shape. For example selected items you refer to can be explored in a different way, if they are stored in a map-like collector, which does not ensure the order (except IndexedMap).
Anyway, if you encounter something next time do post it here.

Roman

P.S. Explorer does use Iterator inside - that's correct, and the order is respected.

Ernest's picture

Thanks a lot to everybody. We've started to rewrite the mentioned classes and most of our problems seems to be solved by this.

I must admit that it really takes a decent amount of time/work, but doing it I've learned a lot of the representation of the topo shapes.