+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6,
+ int ID)
+{
+ return AddVolumeWithID(n1->GetID(),
+ n2->GetID(),
+ n3->GetID(),
+ n4->GetID(),
+ n5->GetID(),
+ n6->GetID(),
+ ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6);
+ if(anElem) myScript->AddVolume(anElem->GetID(),
+ n1->GetID(),
+ n2->GetID(),
+ n3->GetID(),
+ n4->GetID(),
+ n5->GetID(),
+ n6->GetID());
+ return anElem;
+}
+
+//=======================================================================
+//function :AddVolume
+//purpose :
+//=======================================================================
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID)
+{
+ SMDS_MeshVolume *anElem= SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, ID);
+ if(anElem) myScript->AddVolume(ID, n1, n2, n3, n4, n5, n6, n7, n8);
+ return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6,
+ const SMDS_MeshNode * n7,
+ const SMDS_MeshNode * n8,
+ int ID)
+{
+ return AddVolumeWithID(n1->GetID(),
+ n2->GetID(),
+ n3->GetID(),
+ n4->GetID(),
+ n5->GetID(),
+ n6->GetID(),
+ n7->GetID(),
+ n8->GetID(),
+ ID);
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
+ const SMDS_MeshNode * n2,
+ const SMDS_MeshNode * n3,
+ const SMDS_MeshNode * n4,
+ const SMDS_MeshNode * n5,
+ const SMDS_MeshNode * n6,
+ const SMDS_MeshNode * n7,
+ const SMDS_MeshNode * n8)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
+ if(anElem) myScript->AddVolume(anElem->GetID(),
+ n1->GetID(),
+ n2->GetID(),
+ n3->GetID(),
+ n4->GetID(),
+ n5->GetID(),
+ n6->GetID(),
+ n7->GetID(),
+ n8->GetID());
+ return anElem;
+}
+//=======================================================================
+//function : removeFromContainers
+//purpose :
+//=======================================================================
+
+static void removeFromContainers (map<int,SMESHDS_SubMesh*> & theSubMeshes,
+ set<SMESHDS_GroupBase*>& theGroups,
+ list<const SMDS_MeshElement *> & theElems,
+ const bool isNode)
+{
+ 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++ ;
+ }
+ }
+ }
+}
+