* Get a <VAR>shape_type</VAR> of the object value.
*/
shape_type GetShapeType();
+
+ /*!
+ * Get the topology type of the object value.
+ * In contrast to the shape type, this function returns type of the most
+ * top-level sub-shape of the COMPOUND or COMPSOLID, if there is only one
+ * sub-shape there.
+ * \sa GetShapeType()
+ */
+ shape_type GetTopologyType();
/*!
* Set name of the object.
#include <BRepTools_ShapeSet.hxx>
#include <BRepTools.hxx>
#include <TopAbs.hxx>
+#include <TopoDS_Iterator.hxx>
#ifdef WNT
#pragma warning( disable:4786 )
return (GEOM::shape_type)_geom.ShapeType();
}
+//=============================================================================
+/*!
+ * GetTopologyType
+ */
+//=============================================================================
+GEOM::shape_type GEOM_Object_i::GetTopologyType()
+{
+ TopoDS_Shape shape = _impl->GetValue();
+ if(shape.IsNull()) return GEOM::SHAPE;
+
+ if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) {
+ TopoDS_Shape shape_i;
+ TopoDS_Iterator It (shape, Standard_True, Standard_False);
+ for (; It.More(); It.Next()) {
+ if ( !shape_i.IsNull() ) return (GEOM::shape_type)shape.ShapeType();
+ shape_i = It.Value();
+ }
+ if ( !shape_i.IsNull() )
+ return (GEOM::shape_type) shape_i.ShapeType();
+ }
+
+ return (GEOM::shape_type)shape.ShapeType();
+}
+
//=============================================================================
/*!
* SetName