Salome HOME
0022183: EDF SMESH: Error with ConvertToQuadratic
authoreap <eap@opencascade.com>
Fri, 29 Mar 2013 15:22:09 +0000 (15:22 +0000)
committereap <eap@opencascade.com>
Fri, 29 Mar 2013 15:22:09 +0000 (15:22 +0000)
In AddNode(), throw an exception only if a node is already in an other
sub-mesh or its position in myNodes is wrong.

src/SMESHDS/SMESHDS_SubMesh.cxx

index 450c7f5a04a31261ab611995809f904f6fac9fb7..76b131c89fff767bb55c533d616bc04a5cc036b3 100644 (file)
@@ -155,25 +155,28 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele
 //function : AddNode
 //purpose  : 
 //=======================================================================
+
 void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
 {
   if ( !IsComplexSubmesh() )
+  {
+    int idInSubShape = N->getIdInShape();
+    int shapeId = N->getshapeId();
+    if ((shapeId > 0) && (idInSubShape >= 0))
     {
-      int idInSubShape = N->getIdInShape();
-      int shapeId = N->getshapeId();
-      if ((shapeId > 0) && (idInSubShape >= 0))
-        {
-//           MESSAGE("========== AddNode already belonging to other subShape " << N->GetID());
-          // OK for vertex nodes
-          throw SALOME_Exception(LOCALIZED("add node in subshape already belonging to a subshape"));
-        }
-      SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
-      node->setShapeId(myIndex);
-      node->setIdInShape(myNodes.size());
-      myNodes.push_back(N);
-      //MESSAGE("in "<< myIndex << " AddNode " << node->GetID());
+      if ( shapeId != myIndex )
+        throw SALOME_Exception
+          (LOCALIZED("a node being in sub-mesh is added to another sub-mesh"));
+      if ( idInSubShape >= NbNodes() || myNodes[ idInSubShape ] != N )
+        throw SALOME_Exception
+          (LOCALIZED("a node with wrong idInSubShape is re-added to the same sub-mesh"));
+      return; // already in
     }
-  //MESSAGE("try to add node in a complex submesh " << N->GetID());
+    SMDS_MeshNode* node = (SMDS_MeshNode*)(N);
+    node->setShapeId(myIndex);
+    node->setIdInShape(myNodes.size());
+    myNodes.push_back(N);
+  }
 }
 
 //=======================================================================