From 110067df8c5d7f002d054d7e5ae42a3621a39303 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 21 Aug 2012 14:13:23 +0000 Subject: [PATCH] 0021801: EDF 2143 SMESH: random order of groups returned by ExtrusionSweepObject2D + SMESH_Group* AddGroup (SMESHDS_GroupBase* groupDS) --- src/SMESH/SMESH_Mesh.cxx | 29 +++++++++++++++++++++++++++++ src/SMESH/SMESH_Mesh.hxx | 4 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 1057d3dee..2b41f59a3 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1651,6 +1651,35 @@ SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType, return aGroup; } +//================================================================================ +/*! + * \brief Creates a group based on an existing SMESHDS group. Group ID should be unique + */ +//================================================================================ + +SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exception) +{ + if ( !groupDS ) + throw SALOME_Exception(LOCALIZED ("SMESH_Mesh::AddGroup(): NULL SMESHDS_GroupBase")); + + map ::iterator i_g = _mapGroup.find( groupDS->GetID() ); + if ( i_g != _mapGroup.end() && i_g->second ) + { + if ( i_g->second->GetGroupDS() == groupDS ) + return i_g->second; + else + throw SALOME_Exception(LOCALIZED ("SMESH_Mesh::AddGroup() wrong ID of SMESHDS_GroupBase")); + } + SMESH_Group* aGroup = new SMESH_Group (groupDS); + _mapGroup[ groupDS->GetID() ] = aGroup; + GetMeshDS()->AddGroup( aGroup->GetGroupDS() ); + + _groupId = 1 + _mapGroup.rbegin()->first; + + return aGroup; +} + + //================================================================================ /*! * \brief Creates SMESH_Groups for not wrapped SMESHDS_Groups diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 5ae3cc61c..3f719496f 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -287,7 +287,9 @@ public: int& theId, const TopoDS_Shape& theShape=TopoDS_Shape(), const SMESH_PredicatePtr& thePredicate=SMESH_PredicatePtr()); - + + SMESH_Group* AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exception); + typedef boost::shared_ptr< SMDS_Iterator > GroupIteratorPtr; GroupIteratorPtr GetGroups() const; -- 2.39.2