In the package TopExp, you will find methods you can use : MapShapes or MapShapesAndAncestors.
Commenter-1
Archived discussion
Hi All,
What is the correct procedure for finding the number of sub-shapes of a shape. For example the number of edges defining a wire, or the number of wires trimming a surface.
Thanks in advance.
Simon
Discussion
Posts are displayed in their archived order.
In the package TopExp, you will find methods you can use : MapShapes or MapShapesAndAncestors.
Commenter-1
You can use an explorer object like TopExp_Explorer. Initialize it with the kind of sub-shape (TopAbs_EDGE for example) and then use a counter inside a loop.
Regards.
Take care with TopExp_Explorer , the entities are not unique. For example , if you have 2 contiguous edges , with 1 vertex in common , topExp_Explorer will say that you have 4 vertices, and TopExp::MapShapes will say 3 vertices , because 1 is the same.
Commenter-1
Thank you for all your speedy replies.
Simon
Dear Simon,
If you want to find the number of sub-shapes on the first level (wires in face or edges in wire) you can use TopoDS_Iterator class which provide the better performance than TopExp_Explorer. If you need to obtain a number of unique sub-shapes, please use maps with TopoDS_Iterator. (for example TopTools_MapOfShape).
If you need to obtain all statistic on shape (the number of vertices, edges, etc...) please use ShapeAnalysisStd_ShapeContents class.
Best regards,
Commenter-3.