Testing a TopoDS_Shape

I must be missing something simple here. How do I test a TopoDS_Shape for a specific shape (like a sphere)?

TopoDS_Shape aShape;

// test if shape is a sphere
if (????aShape.isSphere()????) // What goes here?
{
//perform operations on sphere
}

Thanks,

David

Hugues's picture

You can try this(retrieve the underlying geometry and test if it describes a sphere) :

TopoDS_Shape shape;
TopoDS_Face face = TopoDS::Face (shape);
if (not face.IsNull ())
{
Handle_Geom_Surface surface = BRep_Tool::Surface (face);
if (surface->IsKind (STANDARD_TYPE (Geom_SphericalSurface)))
// You have a sphere.
}

It may not work it most of the cases.