From 45ed5d9a931bf24187e627f41e04baae23e7ffc4 Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 1 Dec 2010 22:56:36 +0000 Subject: [PATCH] PR: fix Transform method with orphan nodes --- src/SMESH/SMESH_MeshEditor.cxx | 55 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 828f83db4..b5c2af386 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -5345,38 +5345,29 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, // source elements for each generated one SMESH_SequenceOfElemPtr srcElems, srcNodes; -// // issue 021015: EDF 1578 SMESH: Free nodes are removed when translating a mesh -// list orphanCopy; // copies of orphan nodes -// vector orphanNode; // original orphan nodes -// -// if ( theElems.empty() ) // transform the whole mesh -// { -// // add all elements -// SMDS_ElemIteratorPtr eIt = aMesh->elementsIterator(); -// while ( eIt->more() ) theElems.insert( eIt->next() ); -// // add orphan nodes -// SMDS_MeshElementIDFactory idFactory; -// SMDS_NodeIteratorPtr nIt = aMesh->nodesIterator(); -// while ( nIt->more() ) -// { -// const SMDS_MeshNode* node = nIt->next(); -// if ( node->NbInverseElements() == 0 && !theElems.insert( node ).second ) -// { -// // node was not inserted into theElems because an element with the same ID -// // is already there. As a work around we insert a copy of node with -// // an ID = - -// orphanCopy.push_back( *node ); // copy node -// SMDS_MeshNode* nodeCopy = &orphanCopy.back(); -// int uniqueID = -orphanNode.size(); -// orphanNode.push_back( node ); -// idFactory.BindID( uniqueID, nodeCopy ); -// theElems.insert( nodeCopy ); -// } -// } -// } - // loop on theElems to transorm nodes + // issue 021015: EDF 1578 SMESH: Free nodes are removed when translating a mesh + TIDSortedElemSet orphanNode; + + if ( theElems.empty() ) // transform the whole mesh + { + // add all elements + SMDS_ElemIteratorPtr eIt = aMesh->elementsIterator(); + while ( eIt->more() ) theElems.insert( eIt->next() ); + // add orphan nodes + SMDS_NodeIteratorPtr nIt = aMesh->nodesIterator(); + while ( nIt->more() ) + { + const SMDS_MeshNode* node = nIt->next(); + if ( node->NbInverseElements() == 0) + orphanNode.insert( node ); + } + } + + // loop on elements to transform nodes : first orphan nodes then elems TIDSortedElemSet::iterator itElem; - for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) { + TIDSortedElemSet *elements[] = {&orphanNode, &theElems }; + for (int i=0; i<2; i++) + for ( itElem = elements[i]->begin(); itElem != elements[i]->end(); itElem++ ) { const SMDS_MeshElement* elem = *itElem; if ( !elem ) continue; @@ -5386,8 +5377,6 @@ SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems, while ( itN->more() ) { const SMDS_MeshNode* node = cast2Node( itN->next() ); -// if ( node->GetID() < 0 ) -// node = orphanNode[ -node->GetID() ]; // check if a node has been already transformed pair n2n_isnew = nodeMap.insert( make_pair ( node, node )); -- 2.39.2