+ if ( theElems.empty() )
+ return;
+
+ // Rm from group
+ // Element can belong to several groups
+ if ( !theGroups.empty() )
+ {
+ set<SMESHDS_GroupBase*>::iterator GrIt = theGroups.begin();
+ for ( ; GrIt != theGroups.end(); GrIt++ )
+ {
+ SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *GrIt );
+ if ( !group || group->IsEmpty() ) continue;
+
+ list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
+ for ( ; elIt != theElems.end(); elIt++ )
+ {
+ group->SMDSGroup().Remove( *elIt );
+ if ( group->IsEmpty() ) break;
+ }
+ }
+ }
+
+ // Rm from sub-meshes
+ // Element should belong to only one sub-mesh
+ map<int,SMESHDS_SubMesh*>::iterator SubIt = theSubMeshes.begin();
+ for ( ; SubIt != theSubMeshes.end(); SubIt++ )
+ {
+ int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
+ if ( size == 0 ) continue;
+
+ list<const SMDS_MeshElement *>::iterator elIt = theElems.begin();
+ while ( elIt != theElems.end() )
+ {
+ bool removed = false;
+ if ( isNode )
+ removed = (*SubIt).second->RemoveNode( static_cast<const SMDS_MeshNode*> (*elIt) );
+ else
+ removed = (*SubIt).second->RemoveElement( *elIt );
+
+ if (removed)
+ {
+ elIt = theElems.erase( elIt );
+ if ( theElems.empty() )
+ return; // all elements are found and removed
+ }
+ else
+ {
+ elIt++ ;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : RemoveNode
+//purpose :
+//=======================================================================
+void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n)
+{
+ myScript->RemoveNode(n->GetID());
+
+ list<const SMDS_MeshElement *> removedElems;
+ list<const SMDS_MeshElement *> removedNodes;