+//================================================================================
+/*!
+ * \brief Return in dist2Nodes nodes mapped to their square distance from Node
+ * \param node - node to find nodes closest to
+ * \param dist2Nodes - map of found nodes and their distances
+ * \param precision - radius of a sphere to check nodes inside
+ * \retval bool - true if an exact overlapping found
+ */
+//================================================================================
+
+bool SMESH_OctreeNode::NodesAround(const gp_XYZ &node,
+ map<double, const SMDS_MeshNode*>& dist2Nodes,
+ double precision)
+{
+ if ( !dist2Nodes.empty() )
+ precision = min ( precision, sqrt( dist2Nodes.begin()->first ));
+ else if ( precision == 0. )
+ precision = maxSize() / 2;
+
+ //gp_XYZ p(node->X(), node->Y(), node->Z());
+ if (isInside(node, precision))
+ {
+ if (!isLeaf())
+ {
+ // first check a child containing node
+ gp_XYZ mid = (getBox().CornerMin() + getBox().CornerMax()) / 2.;
+ int nodeChild = getChildIndex( node.X(), node.Y(), node.Z(), mid );
+ if ( ((SMESH_OctreeNode*) myChildren[nodeChild])->NodesAround(node, dist2Nodes, precision))
+ return true;
+
+ for (int i = 0; i < 8; i++)
+ if ( i != nodeChild )
+ if (((SMESH_OctreeNode*) myChildren[i])->NodesAround(node, dist2Nodes, precision))
+ return true;
+ }
+ else if ( NbNodes() > 0 )
+ {
+ double minDist = precision * precision;
+ gp_Pnt p1 ( node.X(), node.Y(), node.Z() );
+ set<const SMDS_MeshNode*>::iterator nIt = myNodes.begin();
+ for ( ; nIt != myNodes.end(); ++nIt )
+ {
+ gp_Pnt p2 ( (*nIt)->X(), (*nIt)->Y(), (*nIt)->Z() );
+ double dist2 = p1.SquareDistance( p2 );
+ if ( dist2 < minDist )
+ dist2Nodes.insert( make_pair( minDist = dist2, *nIt ));
+ }
+// if ( dist2Nodes.size() > 1 ) // leave only closest node in dist2Nodes
+// dist2Nodes.erase( ++dist2Nodes.begin(), dist2Nodes.end());
+
+ return ( sqrt( minDist) <= precision * 1e-12 );
+ }
+ }
+ return false;
+}
+