Salome HOME
desactive traces
[modules/hydro.git] / src / HYDROData / HYDROData_OctreeNode.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  HYDROData HYDROData_OctreeNode : Octree with Nodes set (from SMESH module)
24 //  inherites global class HYDROData_Octree
25 //  File      : HYDROData_OctreeNode.hxx
26 //  Created   : Tue Jan 16 16:00:00 2007
27 //  Author    : Nicolas Geimer & Aurelien Motteux  (OCC)
28 //  Module    : HYDROData
29 //
30 #ifndef _HYDROData_OCTREENODE_HXX_
31 #define _HYDROData_OCTREENODE_HXX_
32
33 #include <Standard.hxx>
34 #include <Standard_Macro.hxx>
35
36 #include "HYDROData_Octree.hxx"
37 #include <gp_Pnt.hxx>
38
39 #include <list>
40 #include <set>
41 #include <vector>
42 #include <map>
43
44 //forward declaration
45 class HYDROData_OctreeNode;
46 class gp_XYZ;
47
48 typedef gp_XYZ Node3D;
49 //typedef NCollection_Sequence<Node3D> Nodes3D;
50 typedef std::list<const Node3D*> Nodes3D;
51
52 class Standard_EXPORT HYDROData_OctreeNode : public HYDROData_Octree {
53
54 public:
55
56   // Constructor
57   HYDROData_OctreeNode (const Nodes3D& theNodes,  const int maxLevel = 8,
58                         const int maxNbNodes = 5, const double minBoxSize = 0.);
59
60 //=============================
61 /*!
62  * \brief Empty destructor
63  */
64 //=============================
65   virtual ~HYDROData_OctreeNode () {};
66
67   // Tells us if Node is inside the current box with the precision "precision"
68   virtual const bool isInside(const gp_XYZ& p, const double precision = 0.);
69
70   // Return in Result a list of Nodes potentials to be near Node
71   void               NodesAround(const Node3D *            Node,
72                                  std::list<const Node3D*>* Result,
73                                  const double              precision = 0.);
74
75   // Return in dist2Nodes nodes mapped to their square distance from Node
76   bool               NodesAround(const gp_XYZ&                    node,
77                                  std::map<double, const Node3D*>& dist2Nodes,
78                                  double                           precision);
79
80   // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
81   // Search for all the nodes in nodes
82 //  void               FindCoincidentNodes ( TIDSortedNodeSet*           nodes,
83 //                                           const double                theTolerance,
84 //                                           std::list< std::list< const Node3D*> >* theGroupsOfNodes);
85
86   // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
87   // theTolerance search for all the nodes in nodes
88 //  static void        FindCoincidentNodes ( TIDSortedNodeSet&                              nodes,
89 //                                           std::list< std::list< const Node3D*> >* theGroupsOfNodes,
90 //                                           const double theTolerance = 0.00001,
91 //                                           const int maxLevel = -1,
92 //                                           const int maxNbNodes = 5);
93   /*!
94    * \brief Update data according to node movement
95    */
96   void                        UpdateByMoveNode( const Node3D* node, const gp_Pnt& toPnt );
97   /*!
98    * \brief Return iterator over children
99    */
100 //  HYDROData_OctreeNodeIteratorPtr GetChildrenIterator();
101   /*!
102    * \brief Return nodes iterator
103    */
104   //SMDS_NodeIteratorPtr        GetNodeIterator();
105   /*!
106    * \brief Return nb nodes in a tree
107    */
108   int                         NbNodes() const { return myNodes.size(); }
109
110 protected:
111
112   struct Limit : public HYDROData_TreeLimit
113   {
114     int myMaxNbNodes;
115     Limit(int maxLevel, double minSize, int maxNbNodes)
116       :HYDROData_TreeLimit(maxLevel, minSize), myMaxNbNodes(maxNbNodes) {}
117   };
118
119   int                   getMaxNbNodes() const;
120
121   HYDROData_OctreeNode();
122
123   // Compute the bounding box of the whole set of nodes myNodes
124   virtual Bnd_B3d*      buildRootBox();
125
126   // Shares the father's data with each of his child
127   virtual void          buildChildrenData();
128
129   // Construct an empty HYDROData_OctreeNode used by HYDROData_Octree::buildChildren()
130   virtual HYDROData_Octree* newChild() const;
131
132 //  // Return in result a list of nodes closed to Node and remove it from SetOfNodes
133 //  void                  FindCoincidentNodes( const Node3D *            Node,
134 //                                             TIDSortedNodeSet*                SetOfNodes,
135 //                                             std::list<const Node3D*>* Result,
136 //                                             const double                     precision);
137
138   // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
139   Nodes3D   myNodes;
140
141 };
142
143 #endif