X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_MeshAlgos.cxx;h=91f6984a343f8054b23bce2d3587a8fdf90d475d;hb=560f8b2d0c2a7fdb4047f981cfac56ed3629bc1a;hp=1de6ba82abaa93a2a382ff47f04b82e043308354;hpb=3a821b48ba986795abde72f524fa1a62a5802df2;p=modules%2Fsmesh.git diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 1de6ba82a..91f6984a3 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -28,6 +28,7 @@ #include "SMESH_MeshAlgos.hxx" +#include "ObjectPool.hxx" #include "SMDS_FaceOfNodes.hxx" #include "SMDS_LinearEdge.hxx" #include "SMDS_Mesh.hxx" @@ -69,7 +70,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher TIDSortedNodeSet nodes; if ( theMesh ) { - SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator(/*idInceasingOrder=*/true); + SMDS_NodeIteratorPtr nIt = theMesh->nodesIterator(); while ( nIt->more() ) nodes.insert( nodes.end(), nIt->next() ); } @@ -114,14 +115,15 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher myOctreeNode->NodesAround( thePnt.Coord(), dist2Nodes, myHalfLeafSize ); if ( !dist2Nodes.empty() ) return dist2Nodes.begin()->second; - std::list nodes; + + std::vector nodes; //myOctreeNode->NodesAround( &tgtNode, &nodes, myHalfLeafSize ); double minSqDist = DBL_MAX; if ( nodes.empty() ) // get all nodes of OctreeNode's closest to thePnt { // sort leafs by their distance from thePnt - typedef std::map< double, SMESH_OctreeNode* > TDistTreeMap; + typedef std::multimap< double, SMESH_OctreeNode* > TDistTreeMap; TDistTreeMap treeMap; std::list< SMESH_OctreeNode* > treeList; std::list< SMESH_OctreeNode* >::iterator trIt; @@ -143,10 +145,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher { const Bnd_B3d& box = *tree->getBox(); double sqDist = thePnt.SquareDistance( 0.5 * ( box.CornerMin() + box.CornerMax() )); - std::pair it_in = - treeMap.insert( std::make_pair( sqDist, tree )); - if ( !it_in.second ) // not unique distance to box center - treeMap.insert( it_in.first, std::make_pair( sqDist + 1e-13*treeMap.size(), tree )); + treeMap.insert( std::make_pair( sqDist, tree )); } } // find distance after which there is no sense to check tree's @@ -163,17 +162,17 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher if ( sqDist_tree->first > sqLimit ) break; SMESH_OctreeNode* tree = sqDist_tree->second; - tree->NodesAround( tree->GetNodeIterator()->next(), &nodes ); + tree->AllNodesAround( tree->GetNodeIterator()->next(), &nodes ); } } // find closest among nodes minSqDist = DBL_MAX; const SMDS_MeshNode* closestNode = 0; - std::list::iterator nIt = nodes.begin(); - for ( ; nIt != nodes.end(); ++nIt ) { - double sqDist = thePnt.SquareDistance( SMESH_TNodeXYZ( *nIt ) ); + for ( size_t i = 0; i < nodes.size(); ++i ) + { + double sqDist = thePnt.SquareDistance( SMESH_NodeXYZ( nodes[ i ])); if ( minSqDist > sqDist ) { - closestNode = *nIt; + closestNode = nodes[ i ]; minSqDist = sqDist; } } @@ -182,7 +181,7 @@ struct SMESH_NodeSearcherImpl: public SMESH_NodeSearcher //--------------------------------------------------------------------- /*! - * \brief Finds nodes located within a tolerance near a point + * \brief Finds nodes located within a tolerance near a point */ int FindNearPoint(const gp_Pnt& point, const double tolerance, @@ -227,7 +226,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() { public: - typedef boost::container::flat_set< const SMDS_MeshElement* > TElemSeq; + typedef boost::container::flat_set< const SMDS_MeshElement*, TIDCompare > TElemSeq; ElementBndBoxTree(const SMDS_Mesh& mesh, SMDSAbs_ElementType elemType, @@ -258,7 +257,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() //!< allocator of ElementBox's and SMESH_TreeLimit struct LimitAndPool : public SMESH_TreeLimit { - TElementBoxPool _elBoPool; + TElementBoxPool _elBoPool; LimitAndPool():SMESH_TreeLimit( MaxLevel, /*minSize=*/0. ) {} }; LimitAndPool* getLimitAndPool() const @@ -1294,7 +1293,7 @@ bool SMESH_MeshAlgos::IsOut( const SMDS_MeshElement* element, const gp_Pnt& poin std::vector< SMESH_TNodeXYZ > xyz; xyz.reserve( element->NbNodes()+1 ); - SMDS_ElemIteratorPtr nodeIt = element->interlacedNodesElemIterator(); + SMDS_NodeIteratorPtr nodeIt = element->interlacedNodesIterator(); for ( int i = 0; nodeIt->more(); ++i ) xyz.push_back( SMESH_TNodeXYZ( nodeIt->next() )); @@ -1530,11 +1529,11 @@ double SMESH_MeshAlgos::GetDistance( const SMDS_MeshElement* elem, switch ( elem->GetType() ) { case SMDSAbs_Volume: - return GetDistance( dynamic_cast( elem ), point, closestPnt ); + return GetDistance( static_cast( elem ), point, closestPnt ); case SMDSAbs_Face: - return GetDistance( dynamic_cast( elem ), point, closestPnt ); + return GetDistance( static_cast( elem ), point, closestPnt ); case SMDSAbs_Edge: - return GetDistance( dynamic_cast( elem ), point, closestPnt ); + return GetDistance( static_cast( elem ), point, closestPnt ); case SMDSAbs_Node: if ( closestPnt ) *closestPnt = SMESH_TNodeXYZ( elem ); return point.Distance( SMESH_TNodeXYZ( elem )); @@ -1666,9 +1665,8 @@ double SMESH_MeshAlgos::GetDistance( const SMDS_MeshEdge* seg, int i = 0, nbNodes = seg->NbNodes(); std::vector< SMESH_TNodeXYZ > xyz( nbNodes ); - SMDS_ElemIteratorPtr nodeIt = seg->interlacedNodesElemIterator(); - while ( nodeIt->more() ) - xyz[ i++ ].Set( nodeIt->next() ); + for ( SMDS_NodeIteratorPtr nodeIt = seg->interlacedNodesIterator(); nodeIt->more(); i++ ) + xyz[ i ].Set( nodeIt->next() ); for ( i = 1; i < nbNodes; ++i ) { @@ -1792,7 +1790,7 @@ void SMESH_MeshAlgos::GetBarycentricCoords( const gp_XY& p, const double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11; // vector const double r11 = p.X()-t2.X(), r12 = p.Y()-t2.Y(); - // barycentric coordinates: mutiply matrix by vector + // barycentric coordinates: multiply matrix by vector bc0 = (t11 * r11 + t12 * r12)/Tdet; bc1 = (t21 * r11 + t22 * r12)/Tdet; } @@ -1838,7 +1836,7 @@ SMESH_MeshAlgos::FindFaceInSet(const SMDS_MeshNode* n1, if ( !face && elem->IsQuadratic()) { // analysis for quadratic elements using all nodes - SMDS_ElemIteratorPtr anIter = elem->interlacedNodesElemIterator(); + SMDS_NodeIteratorPtr anIter = elem->interlacedNodesIterator(); const SMDS_MeshNode* prevN = static_cast( anIter->next() ); for ( i1 = -1, i2 = 0; anIter->more() && !face; i1++, i2++ ) {