Is it possible to split a complex Solid into elementary solids?

I have a complex TopoDS_Solid geometry. It consists of several elementary geometries. Is there any way to split the complex solid into some elementary shapes?

additional comments:
When I do shp.ShapeType(), it gives me TopoDs_Solid
Also, NbChildren() is 1, so I dont think TopoDS_Iterator will work.

Mikhail Sazonov's picture

Hi Ying Zhang,
CompSolid is a shape consisting of Solids. So, the simplest and the most natural way is to use TopoDS_Iterator on Comsolid to get access to its direct children.
To know shared faces you may use the method TopExp::MapShapesAndAncestors, which will allow you to iterate by faces and see in which solids each face is contained.
Mikhail

Ying Zhang's picture

Thank you for your answers. But I feel I made some mistakes. My part is actually recognized as a solid, not compsolid, but the geometry is pretty complex. Is there any way to split it into some elementary shapes?

Ying Zhang's picture

For example, I have a geometry like the one in the figure. I want to split it into two cylinders. Is it possible?
Right now, the shape type is TopoDS_Solid.

Mikhail Sazonov's picture

If your shape is a solid then it contains a shell composed of faces. You can only explore it on faces and recognize if the underlying surface is a cylindrical one.

Ying Zhang's picture

Hi, Mikhail, thanks for your response. In this case, is it possible to determine if two faces are connected? like connected with face and edge? Any suggestion on what function should I looking for? Thanks a lot!!!

Mikhail Sazonov's picture

Connected faces have at least one common edge.