From 0de9672b5e88f94ad17a57163089d46f135d8f06 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 29 Mar 2013 15:22:09 +0000 Subject: [PATCH] 0022183: EDF SMESH: Error with ConvertToQuadratic 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 | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 450c7f5a0..76b131c89 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -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); + } } //======================================================================= -- 2.39.2