- const SMDS_MeshNode* n2 = *it2;
- 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 );
+ // We build a list {n1 + his neigbours} and add this list in theGroupsOfNodes
+ if ( idLess( n1, ListOfCoincidentNodes.front() )) ListOfCoincidentNodes.push_front( n1 );
+ else ListOfCoincidentNodes.push_back ( n1 );
+ ListOfCoincidentNodes.sort( idLess );
+ theGroupsOfNodes->push_back( list<const SMDS_MeshNode*>() );
+ theGroupsOfNodes->back().splice( theGroupsOfNodes->back().end(), ListOfCoincidentNodes );