Salome HOME
PR: double nodes and flat elements for ASTER calculations in progress
[modules/smesh.git] / src / SMESHDS / SMESHDS_Mesh.cxx
index 4d522b5d770ed3bc0ccc4308533175fd12ca7333..7d2986ffefbd513e7c02a9c33782d3616e84dcf2 100644 (file)
@@ -714,35 +714,23 @@ static void removeFromContainers (map<int,SMESHDS_SubMesh*>&     theSubMeshes,
 
   // 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++ )
+  if ( !theSubMeshes.empty() )
   {
-    int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements();
-    if ( size == 0 ) continue;
-
+    SMESHDS_Mesh* mesh = theSubMeshes.begin()->second->getParent();
     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), 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<const SMDS_MeshNode*> (*elIt), deleted );
+    }
+    else {
+      for ( ; elIt != theElems.end(); ++elIt )
+        if ( SMESHDS_SubMesh* sm = mesh->MeshElements( (*elIt)->getshapeId() ))
+          sm->RemoveElement( *elIt, deleted );
     }
   }
 }
-  
+
 //=======================================================================
 //function : RemoveNode
 //purpose  : 
@@ -1117,7 +1105,7 @@ SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
 ///////////////////////////////////////////////////////////////////////////////
 /// Return the sub mesh by Id of shape it is linked to
 ///////////////////////////////////////////////////////////////////////////////
-SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
+SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index) const
 {
   TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
   if (anIter != myShapeIndexToSubMesh.end())
@@ -1130,10 +1118,10 @@ SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const int Index)
 //function : SubMeshIndices
 //purpose  : 
 //=======================================================================
-list<int> SMESHDS_Mesh::SubMeshIndices()
+list<int> SMESHDS_Mesh::SubMeshIndices() const
 {
   list<int> anIndices;
-  std::map<int,SMESHDS_SubMesh*>::iterator anIter = myShapeIndexToSubMesh.begin();
+  std::map<int,SMESHDS_SubMesh*>::const_iterator anIter = myShapeIndexToSubMesh.begin();
   for (; anIter != myShapeIndexToSubMesh.end(); anIter++) {
     anIndices.push_back((*anIter).first);
   }
@@ -1177,7 +1165,7 @@ void SMESHDS_Mesh::ClearScript()
 //function : HasMeshElements
 //purpose  : 
 //=======================================================================
-bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S)
+bool SMESHDS_Mesh::HasMeshElements(const TopoDS_Shape & S) const
 {
         if (myShape.IsNull()) MESSAGE("myShape is NULL");
         int Index = myIndexToShape.FindIndex(S);
@@ -1987,27 +1975,3 @@ bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map<int,int> localClonedNo
   myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds);
   return true;
 }
-
-/*! Create a volume (prism or hexahedron) by duplication of a face.
- * the nodes of the new face are already created.
- * @param vtkVolId vtk id of a volume containing the face, to get an orientation for the face.
- * @param localClonedNodeIds map old node id to new node id. The old nodes define the face in the volume.
- * @return ok if success.
- */
-bool SMESHDS_Mesh::extrudeVolumeFromFace(int vtkVolId, std::map<int,int>& localClonedNodeIds)
-{
-  //MESSAGE("extrudeVolumeFromFace " << vtkVolId);
-  vector<int> orderedNodes;
-  orderedNodes.clear();
-  map<int, int>::const_iterator it = localClonedNodeIds.begin();
-  for (; it != localClonedNodeIds.end(); ++it)
-    orderedNodes.push_back(it->first);
-
-  int nbNodes = myGrid->getOrderedNodesOfFace(vtkVolId, orderedNodes);
-  for (int i=0; i<nbNodes; i++)
-    orderedNodes.push_back(localClonedNodeIds[orderedNodes[i]]);
-  SMDS_MeshVolume *vol = this->AddVolumeFromVtkIds(orderedNodes);
-
-  // TODO update subshape list of elements and nodes
-  return vol;
-}