Salome HOME
Remove message
[modules/smesh.git] / src / SMESHDS / SMESHDS_SubMesh.cxx
index b56397d97dcbebb94685be3c8a18b46fc1b1433d..e73301dd953c92d3aeb31120e679cd7998e495e5 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH SMESHDS : management of mesh data and SMESH document
 
 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  : 
@@ -109,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);
@@ -141,7 +158,7 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
       int shapeId = N->getshapeId();
       if ((shapeId > 0) && (idInSubShape >= 0))
         {
-          MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
+//           MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
           // OK for vertex nodes
           //this->getParent()->UnSetNodeOnShape(N);
         }
@@ -165,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());
@@ -405,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  :