X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=eb0f0392df127cf163d191336af218de0d2e3ea9;hb=455afe36e4542c56ad944b1c01b4c63c4316d1e9;hp=0c05113cf685d51b73c737d8a702e69d9d58edda;hpb=ed456586bfb1411c5bff73b221658766689a6253;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 0c05113cf..eb0f0392d 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -33,6 +33,7 @@ #include "SMESH_Group.hxx" #include "SMESHDS_Group.hxx" #include "SMESHDS_Script.hxx" +#include "SMESHDS_GroupOnGeom.hxx" #include "SMDS_MeshVolume.hxx" #include "utilities.h" @@ -110,15 +111,39 @@ SMESH_Mesh::~SMESH_Mesh() */ //============================================================================= -void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){ +void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) +{ if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh"); - if (_isShapeToMesh) - throw - SALOME_Exception(LOCALIZED - ("a shape to mesh as already been defined")); + + if ( !_myMeshDS->ShapeToMesh().IsNull() && aShape.IsNull() ) + { + // removal of a shape to mesh, delete objects referring to sub-shapes: + // - sub-meshes + map ::iterator i_sm = _mapSubMesh.begin(); + for ( ; i_sm != _mapSubMesh.end(); ++i_sm ) + delete i_sm->second; + _mapSubMesh.clear(); + // - groups on geometry + map ::iterator i_gr = _mapGroup.begin(); + while ( i_gr != _mapGroup.end() ) { + if ( dynamic_cast( i_gr->second->GetGroupDS() )) { + _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() ); + delete i_gr->second; + _mapGroup.erase( i_gr++ ); + } + else + i_gr++; + } + _mapAncestors.Clear(); + _mapPropagationChains.Clear(); + } + else + { + if (_isShapeToMesh) + throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined")); + } _isShapeToMesh = true; _myMeshDS->ShapeToMesh(aShape); - // NRI : 24/02/03 //EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS } @@ -132,7 +157,7 @@ int SMESH_Mesh::UNVToMesh(const char* theFileName) { if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<