0020744: EDF 1272 GEOM : Get(Real?)type of an object

This commit is contained in:
dmv 2010-06-18 11:43:58 +00:00
parent f2f21ff294
commit b26abc1ab5
3 changed files with 36 additions and 0 deletions

View File

@ -166,6 +166,15 @@ module GEOM
* 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.

View File

@ -39,6 +39,7 @@
#include <BRepTools_ShapeSet.hxx>
#include <BRepTools.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Iterator.hxx>
#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

View File

@ -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();