From 7d73daf12325caf79f52f0e77c9af358ef973971 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 10 Feb 2011 13:30:00 +0000 Subject: [PATCH] 0021153: [CEA] non regression test fails Improve removeFromContainers() by taking into account that now mesh element knows the sub-mesh it belongs to --- src/SMESHDS/SMESHDS_Mesh.cxx | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index 57274da28..9727f5fc6 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -714,35 +714,23 @@ static void removeFromContainers (map& theSubMeshes, // Rm from sub-meshes // Element should belong to only one sub-mesh - map::iterator SubIt = theSubMeshes.begin(); - for ( ; SubIt != theSubMeshes.end(); SubIt++ ) + if ( !theSubMeshes.empty() ) { - int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements(); - if ( size == 0 ) continue; - + SMESHDS_Mesh* mesh = theSubMeshes.begin()->second->getParent(); list::iterator elIt = theElems.begin(); - while ( elIt != theElems.end() ) - { - bool removed = false; - if ( isNode ) - removed = (*SubIt).second->RemoveNode( static_cast (*elIt), deleted ); - else - removed = (*SubIt).second->RemoveElement( *elIt, deleted ); - - if (removed) - { - elIt = theElems.erase( elIt ); - if ( theElems.empty() ) - return; // all elements are found and removed - } - else - { - elIt++ ; - } + if ( isNode ) { + for ( ; elIt != theElems.end(); ++elIt ) + if ( SMESHDS_SubMesh* sm = mesh->MeshElements( (*elIt)->getshapeId() )) + sm->RemoveNode( static_cast (*elIt), deleted ); + } + else { + for ( ; elIt != theElems.end(); ++elIt ) + if ( SMESHDS_SubMesh* sm = mesh->MeshElements( (*elIt)->getshapeId() )) + sm->RemoveElement( *elIt, deleted ); } } } - + //======================================================================= //function : RemoveNode //purpose : -- 2.39.2