A question about the order of sub-shapes

Greetings!

In OCC, we may use TopExp_Explorer to obtain sub-shapes of a given shape. However, I want to know that whether the order of the sub-shape list follows a real topological order. If not, I also want to know whether there is a method to output sub-shapes in such a topological order.

For example,

for (TopExp_Explorer exp (aFace, TopAbs_EDGE); exp .More(); exp .Next())
Will the output edges follow an end-to-end manner?

or

for (TopExp_Explorer exp (aEdge, TopAbs_VERTEX); exp .More(); exp .Next())
Will it ouput the start vertex first, and the end vertex next?

I would be very grateful if you are willing to generously answer me. Thank you very much!

gkv311 n's picture

What do you mean by 'real topological order'?

The first thing to realize about B-Rep definition, is that order of subshapes defines nothing. Edges in a valid topological Wire should share common topological Vertices, and their order could be arbitrary in the list of subshapes. If you would like to iterate over Edges in their connection order - there are auxiliary tools like BRepTools_WireExplorer.

As such, a proper topological algorithm shouldn't rely on the order of subshapes.

If you are asking about TopoDS_Shape, then internally it stores subshapes in a list (which could be interated via TopoDS_Iterator, and the order will be preserved while saving/reading a shape into BREP or XBF file.

Eric Tang's picture

Thank you very much for your detailed answer! Your answer has fully resolved my problem.

BTW, the mentioned 'real topological order' refers to like: in an edge, start vertex first, and end vertex second; in a wire, edges are listed end-to-end. Now I know that the order of subshapes does not follow this rule. Thanks again!