021300: EDF SMESH: Smoothing by selecting elements IDs seems not effective

Fix a bug in Smooth()
This commit is contained in:
eap 2011-06-15 11:36:47 +00:00
parent 4352740230
commit 170b99e7d4

View File

@ -3091,35 +3091,27 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems,
// fix nodes on mesh boundary // fix nodes on mesh boundary
if ( checkBoundaryNodes ) { if ( checkBoundaryNodes ) {
map< NLink, int > linkNbMap; // how many times a link encounters in elemsOnFace map< SMESH_TLink, int > linkNbMap; // how many times a link encounters in elemsOnFace
map< NLink, int >::iterator link_nb; map< SMESH_TLink, int >::iterator link_nb;
// put all elements links to linkNbMap // put all elements links to linkNbMap
list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin(); list< const SMDS_MeshElement* >::iterator elemIt = elemsOnFace.begin();
for ( ; elemIt != elemsOnFace.end(); ++elemIt ) { for ( ; elemIt != elemsOnFace.end(); ++elemIt ) {
const SMDS_MeshElement* elem = (*elemIt); const SMDS_MeshElement* elem = (*elemIt);
int nbn = elem->NbNodes(); int nbn = elem->NbCornerNodes();
if(elem->IsQuadratic())
nbn = nbn/2;
// loop on elem links: insert them in linkNbMap // loop on elem links: insert them in linkNbMap
const SMDS_MeshNode* curNode, *prevNode = elem->GetNodeWrap( nbn );
for ( int iN = 0; iN < nbn; ++iN ) { for ( int iN = 0; iN < nbn; ++iN ) {
curNode = elem->GetNode( iN ); const SMDS_MeshNode* n1 = elem->GetNode( iN );
NLink link; const SMDS_MeshNode* n2 = elem->GetNode(( iN+1 ) % nbn);
if ( curNode < prevNode ) link = make_pair( curNode , prevNode ); SMESH_TLink link( n1, n2 );
else link = make_pair( prevNode , curNode ); link_nb = linkNbMap.insert( make_pair( link, 0 )).first;
prevNode = curNode;
link_nb = linkNbMap.find( link );
if ( link_nb == linkNbMap.end() )
linkNbMap.insert( make_pair ( link, 1 ));
else
link_nb->second++; link_nb->second++;
} }
} }
// remove nodes that are in links encountered only once from setMovableNodes // remove nodes that are in links encountered only once from setMovableNodes
for ( link_nb = linkNbMap.begin(); link_nb != linkNbMap.end(); ++link_nb ) { for ( link_nb = linkNbMap.begin(); link_nb != linkNbMap.end(); ++link_nb ) {
if ( link_nb->second == 1 ) { if ( link_nb->second == 1 ) {
setMovableNodes.erase( link_nb->first.first ); setMovableNodes.erase( link_nb->first.node1() );
setMovableNodes.erase( link_nb->first.second ); setMovableNodes.erase( link_nb->first.node2() );
} }
} }
} }