Number of subshapes

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

Stephane Routelous's picture

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

Stephane

Jean Michel Boulcourt'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.

Regards.

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.

Stephane

s-bulman's picture

Thank you for all your speedy replies.

Simon

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,

Pavel.