X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_SubMesh.cxx;h=b27ea7b4f520c237d70566a1ab0b241ec2a0132c;hb=2cbc0e004d9802964be66ecb762c58c126cbb023;hp=32073bb50bb9e179eca45bf9f615772fc798acc3;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 32073bb50..b27ea7b4f 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 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 @@ -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() ) + { + const int idInSubShape = N->getIdInShape(); + const 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 >= myNodes.size() || 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); + } } //======================================================================= @@ -469,8 +472,8 @@ SMESHDS_SubMeshIteratorPtr SMESHDS_SubMesh::GetSubMeshIterator() const void SMESHDS_SubMesh::Clear() { - myElements.clear(); - myNodes.clear(); + clearVector( myElements ); + clearVector( myNodes ); myUnusedIdNodes = 0; myUnusedIdElements = 0; SMESHDS_SubMeshIteratorPtr sub = GetSubMeshIterator();