For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Number of subshapes

Simon Bulman's picture

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.


Stephane Routelous's picture

In the package TopExp, you will find methods you can use : MapShapes or MapShapesAndAncestors.


Boulcourt Jean-Michel's picture

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.


Stephane Routelous's picture

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.


Simon Bulman's picture

Thank you for all your speedy replies.


Pavel Durandin's picture

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,


Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.