1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // HYDROData HYDROData_QuadtreeNode : Quadtree with Nodes set (from SMESH module)
24 // inherits global class HYDROData_Quadtree
25 // File : HYDROData_QuadtreeNode.hxx
26 // Created : Tue Jan 16 16:00:00 2007
27 // Author : Nicolas Geimer & Aurelien Motteux (OCC)
30 #ifndef _HYDROData_QUADTREENODE_HXX_
31 #define _HYDROData_QUADTREENODE_HXX_
33 #include <Standard.hxx>
34 #include <Standard_Macro.hxx>
36 #include "HYDROData_Quadtree.hxx"
45 class HYDROData_QuadtreeNode;
49 typedef std::list<gp_XYZ*> Nodes_3D;
51 class Standard_EXPORT HYDROData_QuadtreeNode: public HYDROData_Quadtree
56 //! public constructor: when theNodes is non null, compute the quadtree
57 HYDROData_QuadtreeNode(Nodes_3D* theNodes,
58 const int maxLevel = 8,
59 const int maxNbNodes = 5,
60 const double minBoxSize = 0.);
63 virtual ~HYDROData_QuadtreeNode();
65 //! tu use when no nodes where given to the public constructor
66 virtual void setNodesAndCompute(Nodes_3D* theNodes);
68 //! Tells us if Node is inside the current box with the precision "precision"
69 virtual const bool isInside(const gp_XY& p, const double precision = 0.);
71 //! Return in Result a list of Nodes potentials to be near Node
72 void NodesAround(const gp_XY& Node,
73 std::list<const gp_XYZ*>* Result,
74 const double precision = 0.);
76 //! Return in dist2Nodes nodes mapped to their square distance from Node
77 bool NodesAround(const gp_XY& node,
78 std::map<double, const gp_XYZ*>& dist2Nodes,
81 //! Update data according to node movement
82 void UpdateByMoveNode(const gp_XYZ* node, const gp_Pnt& toPnt);
84 //! Return nb nodes in a tree
88 return myNodes->size();
93 //! tells us if the tree as already bin computed
94 bool isEmpty() const { return myChildren == 0; }
96 inline double getPrecision() {return myPrecision; }
97 inline double setPrecision(double precision) {myPrecision = precision; }
101 struct Limit: public HYDROData_TreeLimit
104 Limit(int maxLevel, double minSize, int maxNbNodes) :
105 HYDROData_TreeLimit(maxLevel, minSize), myMaxNbNodes(maxNbNodes) {}
108 int getMaxNbNodes() const;
110 HYDROData_QuadtreeNode();
112 //! Compute the bounding box of the whole set of nodes myNodes
113 virtual Bnd_B2d* buildRootBox();
115 //! Shares the father's data with each of his child
116 virtual void buildChildrenData();
118 //! Construct an empty HYDROData_QuadtreeNode used by HYDROData_Quadtree::buildChildren()
119 virtual HYDROData_Quadtree* newChild() const;
121 //! The set of nodes inside the box of the Quadtree (Empty if Quadtree is not a leaf)
124 //! distance to look for nearest nodes