diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 969ffb613..bf5bc2ba6 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -2206,6 +2206,21 @@ SMESH::long_array* ::Filter_i::GetMeshInfo() return aRes._retn(); } +//================================================================================ +/*! + * \brief Return GetElementType() within an array + * Implement SMESH_IDSource interface + */ +//================================================================================ + +SMESH::array_of_ElementType* Filter_i::GetTypes() +{ + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + types->length( 1 ); + types[0] = GetElementType(); + return types._retn(); +} + //======================================================================= // name : getCriteria // Purpose : Retrieve criterions from predicate diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 057c7693b..5451f821f 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -790,6 +790,10 @@ namespace SMESH SMESH::long_array* GetMeshInfo(); + virtual + SMESH::array_of_ElementType* + GetTypes(); + static void GetElementsId( Predicate_i*, diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index d6f2d4ee4..e600c37f0 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -426,17 +426,6 @@ SMESH::SMESH_Mesh_ptr SMESH_GroupBase_i::GetMesh() return aMesh._retn(); } -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::long_array* SMESH_GroupBase_i::GetIDs() -{ - SMESH::long_array_var aResult = GetListOfID(); - return aResult._retn(); -} - //======================================================================= //function : GetShape //purpose : @@ -543,3 +532,28 @@ SMESH::long_array* SMESH_GroupBase_i::GetMeshInfo() SMESH_Mesh_i::CollectMeshInfo( aGrpDS->GetElements(), aRes); return aRes._retn(); } + +//======================================================================= +//function : GetIDs +//purpose : Returns ids of members +//======================================================================= + +SMESH::long_array* SMESH_GroupBase_i::GetIDs() +{ + SMESH::long_array_var aResult = GetListOfID(); + return aResult._retn(); +} + +//======================================================================= +//function : GetTypes +//purpose : Returns types of elements it contains +//======================================================================= + +SMESH::array_of_ElementType* SMESH_GroupBase_i::GetTypes() +{ + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + types->length( 1 ); + types[0] = GetType(); + return types._retn(); +} + diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 0dffef1e8..60d61f6c0 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -75,6 +75,12 @@ class SMESH_I_EXPORT SMESH_GroupBase_i: // Inherited from SMESH_IDSource interface virtual SMESH::long_array* GetIDs(); + /*! + * Returns types of elements it contains + * Inherited from SMESH_IDSource interface + */ + virtual SMESH::array_of_ElementType* GetTypes(); + // Internal C++ interface int GetLocalID() const { return myLocalID; } SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; } diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 1d631cfce..a38a8f9ba 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -655,6 +655,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap //Get or Create the SMESH_subMesh object implementation int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape ); + if ( !subMeshId ) + THROW_SALOME_CORBA_EXCEPTION("not sub-shape of the main shape", SALOME::BAD_PARAM); subMesh = getSubMesh( subMeshId ); // create a new subMesh object servant if there is none for the shape @@ -3548,6 +3550,30 @@ SMESH::string_array* SMESH_Mesh_i::GetLastParameters() return aResult._retn(); } +//======================================================================= +//function : GetTypes +//purpose : Returns types of elements it contains +//======================================================================= + +SMESH::array_of_ElementType* SMESH_Mesh_i::GetTypes() +{ + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + + types->length( 4 ); + int nbTypes = 0; + if (_impl->NbEdges()) + types[nbTypes++] = SMESH::EDGE; + if (_impl->NbFaces()) + types[nbTypes++] = SMESH::FACE; + if (_impl->NbVolumes()) + types[nbTypes++] = SMESH::VOLUME; + if (_impl->Nb0DElements()) + types[nbTypes++] = SMESH::ELEM0D; + types->length( nbTypes ); + + return types._retn(); +} + //============================================================================= /*! * \brief Returns statistic of mesh elements diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 92cf410b5..d3f550ecd 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -373,8 +373,6 @@ public: */ void CheckGeomGroupModif(); - virtual SMESH::long_array* GetIDs(); - CORBA::LongLong GetMeshPtr(); /*! @@ -502,14 +500,6 @@ public: */ SMESH::string_array* GetLastParameters(); - - /*! - * Returns statistic of mesh elements - * Result array of number enityties - * Inherited from SMESH_IDSource - */ - virtual SMESH::long_array* GetMeshInfo(); - /*! * Collect statistic of mesh elements given by iterator */ @@ -526,6 +516,25 @@ public: virtual ::CORBA::Boolean SetMeshOrder(const SMESH::submesh_array_array& theSubMeshArray); + // ========================= + // SMESH_IDSource interface + // ========================= + + virtual SMESH::long_array* GetIDs(); + + /*! + * Returns statistic of mesh elements + * Result array of number enityties + * Inherited from SMESH_IDSource + */ + virtual SMESH::long_array* GetMeshInfo(); + + /*! + * Returns types of elements it contains + */ + virtual SMESH::array_of_ElementType* GetTypes(); + + std::map _mapSubMesh_i; //NRI std::map _mapSubMesh; //NRI diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index 301f1a972..8401ce775 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -545,3 +545,26 @@ SMESH::long_array* SMESH_subMesh_i::GetMeshInfo() return aRes._retn(); } + + +//======================================================================= +//function : GetTypes +//purpose : Returns types of elements it contains +//======================================================================= + +SMESH::array_of_ElementType* SMESH_subMesh_i::GetTypes() +{ + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + types->length( 1 ); + ::SMESH_subMesh* aSubMesh = _mesh_i->_mapSubMesh[_localId]; + switch ( ::SMESH_Gen::GetShapeDim( aSubMesh->GetSubShape() )) + { + case 0: types[0] = SMESH::ELEM0D; break; + case 1: types[0] = SMESH::EDGE; break; + case 2: types[0] = SMESH::FACE; break; + case 3: types[0] = SMESH::VOLUME; break; + default: + types->length(0); + } + return types._retn(); +} diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index bd53171ae..3f90a8cb8 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -94,6 +94,12 @@ public: */ virtual SMESH::long_array* GetMeshInfo(); + /*! + * Returns types of elements it contains + */ + virtual SMESH::array_of_ElementType* GetTypes(); + + SMESH_Mesh_i* _mesh_i; //NRI protected: