+//=======================================================================
+//function : AddPolyhedralVolume
+//purpose :
+//=======================================================================
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
+ std::vector<int> quantities,
+ const int ID)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
+ if (anElem) {
+ myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
+ }
+ return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities,
+ const int ID)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
+ }
+ return anElem;
+}
+
+SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
+ (std::vector<const SMDS_MeshNode*> nodes,
+ std::vector<int> quantities)
+{
+ SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
+ if (anElem) {
+ int i, len = nodes.size();
+ std::vector<int> nodes_ids (len);
+ for (i = 0; i < len; i++) {
+ nodes_ids[i] = nodes[i]->GetID();
+ }
+ myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
+ }
+ 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++ ;
+ }
+ }
+ }
+}
+