Salome HOME
PAL 14158 Add the Octree and OctreeNode classes to accelerate detection of close...
[modules/smesh.git] / src / SMESH / SMESH_OctreeNode.hxx
1 //  SMESH SMESH_OctreeNode : Octree with Nodes set
2 //  inherites global class SMESH_Octree
3 //
4 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 //  This library is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU Lesser General Public
9 //  License as published by the Free Software Foundation; either
10 //  version 2.1 of the License.
11 //
12 //  This library is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  Lesser General Public License for more details.
16 //
17 //  You should have received a copy of the GNU Lesser General Public
18 //  License along with this library; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 //
21 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 //
23 //
24 //
25 // File      : SMESH_OctreeNode.hxx
26 // Created   : Tue Jan 16 16:00:00 2007
27 // Author    : Nicolas Geimer & AurĂ©lien Motteux  (OCC)
28 // Module    : SMESH
29
30 #ifndef _SMESH_OCTREENODE_HXX_
31 #define _SMESH_OCTREENODE_HXX_
32
33 #include "SMESH_Octree.hxx"
34
35 //forward declaration
36 class SMDS_MeshNode;
37
38 #include <list>
39 #include <set>
40
41 class SMESH_OctreeNode : public SMESH_Octree{
42
43 public:
44
45   // Constructor
46   SMESH_OctreeNode (set<const SMDS_MeshNode*>  theNodes, const int maxLevel = -1,
47                     const int maxNbNodes = 5 , const double minBoxSize = 0.);
48
49 //=============================
50 /*!
51  * \brief Empty destructor
52  */
53 //=============================
54   virtual ~SMESH_OctreeNode () {};
55
56   // Tells us if SMESH_OctreeNode is a leaf or not (-1 = not initialiazed)
57   virtual const bool isLeaf();
58
59   // Tells us if Node is inside the current box with the precision "precision"
60   virtual const bool isInside(const SMDS_MeshNode * Node, const double precision = 0. );
61
62   // Return in Result a list of Nodes potentials to be near Node
63   void               NodesAround( const SMDS_MeshNode * Node , list<const SMDS_MeshNode*>* Result,
64                                   const double precision = 0. );
65
66   // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
67   // Search for all the nodes in nodes
68   void               FindCoincidentNodes ( set<const SMDS_MeshNode*>* nodes,
69                                            const double                theTolerance,
70                                            list< list< const SMDS_MeshNode*> >* theGroupsOfNodes);
71
72   // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
73   // theTolerance search for all the nodes in nodes
74   static void        FindCoincidentNodes ( set<const SMDS_MeshNode*> nodes,
75                                            list< list< const SMDS_MeshNode*> >* theGroupsOfNodes,
76                                            const double theTolerance = 0.00001, const int maxLevel = -1,
77                                            const int maxNbNodes = 5);
78
79   protected:
80
81 //=============================
82 /*!
83  * \brief Empty constructor
84  */
85 //=============================
86   SMESH_OctreeNode (){};
87
88   // Shares the father's data with each of his child
89   virtual void          buildChildrenData();
90
91   // Compute the bounding box of the whole set of nodes myNodes (only used for OctreeNode level 0)
92   void                  computeBoxForFather();
93
94   // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
95   virtual SMESH_Octree* allocateOctreeChild();
96
97   // Return in result a list of nodes closed to Node and remove it from SetOfNodes
98   void                  FindCoincidentNodes( const SMDS_MeshNode * Node,
99                                              set<const SMDS_MeshNode*>* SetOfNodes,
100                                              list<const SMDS_MeshNode*>* Result,
101                                              const double precision);
102
103   // The max number of nodes a leaf box can contain
104   int                         myMaxNbNodes;
105
106   // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
107   set<const SMDS_MeshNode*>   myNodes;
108
109   // The number of nodes I have inside the box
110   int                         myNbNodes;
111 };
112 #endif