Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / SMESH / SMESH_OctreeNode.cxx
index 7cfe10d1125448f18e4c5e12ff5fed4a33e6a038..31d609756b1e4ff344f5d03313f795bf0ccd960d 100644 (file)
@@ -1,30 +1,30 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH SMESH_OctreeNode : Octree with Nodes set
 //  inherites global class SMESH_Octree
 //  File      : SMESH_OctreeNode.cxx
 //  Created   : Tue Jan 16 16:00:00 2007
-//  Author    : Nicolas Geimer & Aurélien Motteux (OCC)
+//  Author    : Nicolas Geimer & Aurelien Motteux (OCC)
 //  Module    : SMESH
 //
 #include "SMESH_OctreeNode.hxx"
@@ -106,9 +106,8 @@ Bnd_B3d* SMESH_OctreeNode::buildRootBox()
  */
 //====================================================================================
 
-const bool SMESH_OctreeNode::isInside (const SMDS_MeshNode * Node, const double precision)
+const bool SMESH_OctreeNode::isInside (const gp_XYZ& p, const double precision)
 {
-  gp_XYZ p (Node->X(),Node->Y(),Node->Z());
   if (precision <= 0.)
     return !(getBox().IsOut(p));
   Bnd_B3d BoxWithPrecision = getBox();
@@ -158,7 +157,8 @@ void SMESH_OctreeNode::NodesAround (const SMDS_MeshNode * Node,
                                     list<const SMDS_MeshNode*>* Result,
                                     const double precision)
 {
-  if (isInside(Node,precision))
+  gp_XYZ p(Node->X(), Node->Y(), Node->Z());
+  if (isInside(p, precision))
   {
     if (isLeaf())
     {
@@ -185,7 +185,7 @@ void SMESH_OctreeNode::NodesAround (const SMDS_MeshNode * Node,
  */
 //================================================================================
 
-bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode *              node,
+bool SMESH_OctreeNode::NodesAround(const gp_XYZ &node,
                                    map<double, const SMDS_MeshNode*>& dist2Nodes,
                                    double                             precision)
 {
@@ -194,13 +194,14 @@ bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode *              node,
   else if ( precision == 0. )
     precision = maxSize() / 2;
 
-  if (isInside(node,precision))
+  //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 );
+      int nodeChild  = getChildIndex( node.X(), node.Y(), node.Z(), mid );
       if ( ((SMESH_OctreeNode*) myChildren[nodeChild])->NodesAround(node, dist2Nodes, precision))
         return true;
       
@@ -212,8 +213,8 @@ bool SMESH_OctreeNode::NodesAround(const SMDS_MeshNode *              node,
     else if ( NbNodes() > 0 )
     {
       double minDist = precision * precision;
-      gp_Pnt p1 ( node->X(), node->Y(), node->Z() );
-      TIDSortedNodeSet::iterator nIt = myNodes.begin();
+      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() );
@@ -319,7 +320,8 @@ void SMESH_OctreeNode::FindCoincidentNodes (const SMDS_MeshNode * Node,
                                             list<const SMDS_MeshNode*>* Result,
                                             const double precision)
 {
-  bool isInsideBool = isInside(Node,precision);
+  gp_XYZ p(Node->X(), Node->Y(), Node->Z());
+  bool isInsideBool = isInside(p, precision);
 
   if (isInsideBool)
   {
@@ -385,8 +387,7 @@ void SMESH_OctreeNode::UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt
     TIDSortedNodeSet::iterator pNode = myNodes.find( node );
     bool nodeInMe = ( pNode != myNodes.end() );
 
-    SMDS_MeshNode pointNode( toPnt.X(), toPnt.Y(), toPnt.Z() );
-    bool pointInMe = isInside( &pointNode, 1e-10 );
+    bool pointInMe = isInside( toPnt.Coord(), 1e-10 );
 
     if ( pointInMe != nodeInMe )
     {