PAL 14158 : substitute the old algo (n²) to the Octree one (n) in the FindCoincidentNode method.

This commit is contained in:
nge 2007-01-22 15:29:01 +00:00
parent 9944389aa9
commit a5ee60b544

View File

@ -42,6 +42,7 @@
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include "SMESH_OctreeNode.hxx"
#include "utilities.h" #include "utilities.h"
@ -4194,7 +4195,8 @@ void SMESH_MeshEditor::Transform (TIDSortedElemSet & theElems,
//======================================================================= //=======================================================================
//function : FindCoincidentNodes //function : FindCoincidentNodes
//purpose : Return list of group of nodes close to each other within theTolerance //purpose : Return list of group of nodes close to each other within theTolerance
// Search among theNodes or in the whole mesh if theNodes is empty. // Search among theNodes or in the whole mesh if theNodes is empty using
// an Octree algorithm
//======================================================================= //=======================================================================
void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes, void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes,
@ -4204,48 +4206,17 @@ void SMESH_MeshEditor::FindCoincidentNodes (set<const SMDS_MeshNode*> & theNodes
myLastCreatedElems.Clear(); myLastCreatedElems.Clear();
myLastCreatedNodes.Clear(); myLastCreatedNodes.Clear();
double tol2 = theTolerance * theTolerance; set<const SMDS_MeshNode*> nodes;
list<const SMDS_MeshNode*> nodes;
if ( theNodes.empty() ) if ( theNodes.empty() )
{ // get all nodes in the mesh { // get all nodes in the mesh
SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator(); SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator();
while ( nIt->more() ) while ( nIt->more() )
nodes.push_back( nIt->next() ); nodes.insert( nodes.end(),nIt->next());
} }
else else
{ nodes=theNodes;
nodes.insert( nodes.end(), theNodes.begin(), theNodes.end() ); SMESH_OctreeNode::FindCoincidentNodes ( nodes, &theGroupsOfNodes, theTolerance);
}
list<const SMDS_MeshNode*>::iterator it2, it1 = nodes.begin();
for ( ; it1 != nodes.end(); it1++ )
{
const SMDS_MeshNode* n1 = *it1;
gp_Pnt p1( n1->X(), n1->Y(), n1->Z() );
list<const SMDS_MeshNode*> * groupPtr = 0;
it2 = it1;
for ( it2++; it2 != nodes.end(); it2++ )
{
const SMDS_MeshNode* n2 = *it2;
gp_Pnt p2( n2->X(), n2->Y(), n2->Z() );
if ( p1.SquareDistance( p2 ) <= tol2 )
{
if ( !groupPtr ) {
theGroupsOfNodes.push_back( list<const SMDS_MeshNode*>() );
groupPtr = & theGroupsOfNodes.back();
groupPtr->push_back( n1 );
}
if(groupPtr->front()>n2)
groupPtr->push_front( n2 );
else
groupPtr->push_back( n2 );
it2 = nodes.erase( it2 );
it2--;
}
}
}
} }
//======================================================================= //=======================================================================