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"
46 class HYDROData_QuadtreeNode;
49 class Standard_EXPORT gpi_XYZ: public gp_XYZ
54 gpi_XYZ(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, int i): gp_XYZ(X, Y, Z), myIndex(i) {}
56 int getIndex() const {return myIndex; }
61 typedef std::list<gpi_XYZ*> Nodes_3D;
63 class Standard_EXPORT HYDROData_QuadtreeNode: public HYDROData_Quadtree
68 //! public constructor: when theNodes is non null, compute the quadtree
69 HYDROData_QuadtreeNode(Nodes_3D* theNodes,
70 const int maxLevel = 8,
71 const int maxNbNodes = 5,
72 const double minBoxSize = 0.);
75 virtual ~HYDROData_QuadtreeNode();
77 //! tu use when no nodes where given to the public constructor
78 virtual void setNodesAndCompute(Nodes_3D* theNodes);
80 //! Tells us if Node is inside the current box with the precision "precision"
81 virtual const bool isInside(const gp_XY& p, const double precision = 0.);
83 //! Return in Result a list of Nodes potentials to be near Node
84 void NodesAround(const gp_XY& Node,
85 std::list<const gpi_XYZ*>* Result,
86 const double precision = 0.);
88 //! Return in dist2Nodes nodes mapped to their square distance from Node
89 bool NodesAround(const gp_XY& node,
90 std::map<double, const gpi_XYZ*>& dist2Nodes,
93 //! Update data according to node movement
94 void UpdateByMoveNode(const gpi_XYZ* node, const gp_Pnt& toPnt);
96 //! Return nb nodes in a tree
100 return myNodes->size();
105 //! tells us if the tree as already bin computed
106 bool isEmpty() const { return myChildren == 0; }
108 inline double getPrecision() {return myPrecision; }
109 inline void setPrecision(double precision) {myPrecision = precision; }
113 struct Limit: public HYDROData_TreeLimit
116 Limit(int maxLevel, double minSize, int maxNbNodes) :
117 HYDROData_TreeLimit(maxLevel, minSize), myMaxNbNodes(maxNbNodes) {}
120 int getMaxNbNodes() const;
122 HYDROData_QuadtreeNode();
124 //! Compute the bounding box of the whole set of nodes myNodes
125 virtual Bnd_B2d* buildRootBox();
127 //! Shares the father's data with each of his child
128 virtual void buildChildrenData();
130 //! Construct an empty HYDROData_QuadtreeNode used by HYDROData_Quadtree::buildChildren()
131 virtual HYDROData_Quadtree* newChild() const;
133 //! The set of nodes inside the box of the Quadtree (Empty if Quadtree is not a leaf)
136 //! distance to look for nearest nodes