Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/smesh.git] / src / SMESH / SMESH_OctreeNode.cxx
index 52f1e3071799bb048975583044fe08ad98c4b7b5..48e8c5a793a50ef886c5d802e7460500b2609c72 100644 (file)
@@ -1,7 +1,6 @@
-//  SMESH SMESH_OctreeNode : Octree with Nodes set
-//  inherites global class SMESH_Octree
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  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
 //  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)
 // Module    : SMESH
-
+//
 #include "SMESH_OctreeNode.hxx"
+
+#include "SMDS_MeshNode.hxx"
+#include "SMDS_SetIterator.hxx"
 #include <gp_Pnt.hxx>
-#include <SMDS_MeshNode.hxx>
 
 using namespace std;
 
@@ -42,7 +43,7 @@ using namespace std;
  * \param minBoxSize - Minimal size of the Octree Box
  */
 //================================================================
-SMESH_OctreeNode::SMESH_OctreeNode (set<const SMDS_MeshNode*> theNodes, const int maxLevel,
+SMESH_OctreeNode::SMESH_OctreeNode (const set<const SMDS_MeshNode*> & theNodes, const int maxLevel,
                                     const int maxNbNodes , const double minBoxSize )
   :SMESH_Octree(maxLevel,minBoxSize),
   myMaxNbNodes(maxNbNodes),
@@ -119,11 +120,10 @@ const bool SMESH_OctreeNode::isInside(const SMDS_MeshNode * Node, const double p
   bool Out = 1 ;
   if (precision<=0.)
      return !(myBox->IsOut(gp_XYZ(X,Y,Z)));
-  Bnd_B3d * BoxWithPrecision = new Bnd_B3d();
+  Bnd_B3d BoxWithPrecision;
   getBox(BoxWithPrecision);
-  BoxWithPrecision->Enlarge(precision);
-  Out=BoxWithPrecision->IsOut(gp_XYZ(X,Y,Z));
-  delete BoxWithPrecision;
+  BoxWithPrecision.Enlarge(precision);
+  Out=BoxWithPrecision.IsOut(gp_XYZ(X,Y,Z));
   return !(Out);
 }
 
@@ -325,3 +325,28 @@ void SMESH_OctreeNode::FindCoincidentNodes( const SMDS_MeshNode * Node,
   }
 }
 
+//================================================================================
+/*!
+ * \brief Return iterator over children
+ */
+//================================================================================
+
+SMESH_OctreeNodeIteratorPtr SMESH_OctreeNode::GetChildrenIterator()
+{
+  return SMESH_OctreeNodeIteratorPtr
+    ( new SMDS_SetIterator< SMESH_OctreeNode*, SMESH_Octree** >
+      ( myChildren, ( isLeaf() ? myChildren : &myChildren[ 8 ] )));
+}
+
+//================================================================================
+/*!
+ * \brief Return nodes iterator
+ */
+//================================================================================
+
+SMDS_NodeIteratorPtr SMESH_OctreeNode::GetNodeIterator()
+{
+  return SMDS_NodeIteratorPtr
+    ( new SMDS_SetIterator< SMDS_pNode, set< SMDS_pNode >::const_iterator >
+      ( myNodes.begin(), myNodes.end() ));
+}