Salome HOME
0021153: [CEA] non regression test fails
[modules/smesh.git] / src / SMESHDS / SMESHDS_SubMesh.cxx
index ada454b9c051bce9b780e5ec9baf4674e8484655..78fcd528203f64424f54e7763632e606a3d2304e 100644 (file)
 
 using namespace std;
 
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
 SMESHDS_SubMesh::SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index)
 {
   myParent = parent;
@@ -46,6 +53,16 @@ SMESHDS_SubMesh::SMESHDS_SubMesh(SMESHDS_Mesh *parent, int index)
   myUnusedIdElements = 0;
 }
 
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+
+SMESHDS_SubMesh::~SMESHDS_SubMesh()
+{
+}
+
 //=======================================================================
 //function : AddElement
 //purpose  : 
@@ -67,18 +84,23 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
           else
             {
               int idInSubShape = ME->getIdInShape();
-              MESSAGE("add element in subshape already belonging to that subshape "
-                << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
-              // check if ok: do nothing if ok
-              if ((idInSubShape == -1) || (idInSubShape >= myElements.size()))
+              if (idInSubShape >= 0)
                 {
-                  MESSAGE("out of bounds");
-                  throw SALOME_Exception(LOCALIZED("out of bounds"));
-                }
-              if (ME != myElements[idInSubShape])
-                {
-                  MESSAGE("not the same element");
-                  throw SALOME_Exception(LOCALIZED("not the same element"));
+                  MESSAGE("add element in subshape already belonging to that subshape "
+                      << ME->GetID() << " " << oldShapeId << " " << idInSubShape);
+                  // check if ok: do nothing if ok
+                  if (idInSubShape >= myElements.size())
+                    {
+                      MESSAGE("out of bounds " << idInSubShape << " " << myElements.size());
+                      throw SALOME_Exception(LOCALIZED("out of bounds"));
+                    }
+                  if (ME != myElements[idInSubShape])
+                    {
+                      MESSAGE("not the same element");
+                      throw SALOME_Exception(LOCALIZED("not the same element"));
+                    }
+                  MESSAGE("already done, OK, nothing to do");
+                  return;
                 }
             }
         }
@@ -104,8 +126,8 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele
   //MESSAGE("-----------------> RemoveElement "<< ME->GetID() << " " << isElemDeleted);
   if (!IsComplexSubmesh())
     {
-      //      if (!isElemDeleted) // alive element has valid ID and can be found
-      //  {
+      if ( ME->getshapeId() != myIndex )
+        return false;
       int idInSubShape = ME->getIdInShape();
       //MESSAGE("in "<< myIndex << " RemoveElement " << ME->GetID() << " " << idInSubShape << " " << myUnusedIdElements);
       SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
@@ -160,6 +182,8 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
     {
       // if (!isNodeDeleted) // alive node has valid ID and can be found
       // {
+      if ( N->getshapeId() != myIndex )
+        return false;
       int idInSubShape = N->getIdInShape();
       //int shapeId = N->getshapeId();
       //MESSAGE("in "<< myIndex << " RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
@@ -400,6 +424,16 @@ bool SMESHDS_SubMesh::RemoveSubMesh( const SMESHDS_SubMesh* theSubMesh )
   return mySubMeshes.erase( theSubMesh );
 }
 
+//=======================================================================
+//function : RemoveAllSubmeshes
+//purpose  : 
+//=======================================================================
+
+void SMESHDS_SubMesh::RemoveAllSubmeshes()
+{
+  mySubMeshes.clear();
+}
+
 //=======================================================================
 //function : ContainsSubMesh
 //purpose  :