From b26abc1ab585048a33e0e9d81baf749cd6cb593b Mon Sep 17 00:00:00 2001 From: dmv Date: Fri, 18 Jun 2010 11:43:58 +0000 Subject: [PATCH] 0020744: EDF 1272 GEOM : Get(Real?)type of an object --- idl/GEOM_Gen.idl | 9 +++++++++ src/GEOM_I/GEOM_Object_i.cc | 25 +++++++++++++++++++++++++ src/GEOM_I/GEOM_Object_i.hh | 2 ++ 3 files changed, 36 insertions(+) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 61aa8caeb..eb8f389d6 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -166,6 +166,15 @@ module GEOM * Get a shape_type 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. diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 355ad32c8..6b9d7ea00 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef WNT #pragma warning( disable:4786 ) @@ -116,6 +117,30 @@ GEOM::shape_type GEOM_Object_i::GetShapeType() 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 diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh index 46a7ae2c0..7b56a603c 100644 --- a/src/GEOM_I/GEOM_Object_i.hh +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -51,6 +51,8 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual GEOM::shape_type GetShapeType(); + virtual GEOM::shape_type GetTopologyType(); + virtual void SetName(const char* theName); virtual char* GetName(); -- 2.39.2