Topo Explorer: iterate over _any_ shape

I would like to iterate over whatever is contained in a compound shape. The first guess - to use TopAbs_SHAPE for ToFind - was not successful and the thread http://www.opencascade.org/org/forum/thread_12197/ confirmed my bad feeling.
Question: Did anything change since 2007 or is there a clever way to iterate without filtering for a special shape type?
There is a quite ugly work around:
for(int e(TopAbs_COMPOUND); e {
TopExp_Explorer explo(shape, (TopAbs_ShapeEnum)e);
...
}
This code will break as soon as TopAbs_ShapeEnum is modified and it is actually not one single iteration but eight separate loops thereby mixing up the sequence in which you encounter the sub-shapes.
Any ideas highly appreciated.

Mark Blome's picture

Hi Dietmar Kieslinger,
you could just use TopoDS_Iterator instead of TopExp_Explorer for that. For example:
it = TopoDS_Iterator(aShape, True, True) # options: compose subshapes with orientation and location of aShape
while it.More():
shapes.append(it.Value())
it.Next()
Sorry, for the python code, I'm working with OCC through PythonOCC ...,
hope this helps,
Mark

stryga42_88589's picture

Hi Mark!
Great hint. You are right, in most situation I want to iterate over the sub-shapes and not explore the constituent parts of a shape.
Question answered.
Thansks, Dietmar