SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SMESH_OctreeNode.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 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.
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 // SMESH SMESH_OctreeNode : Octree with Nodes set
23 // inherites global class SMESH_Octree
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 #include <list>
36 #include <set>
37 
38 #include "SMDS_ElemIterator.hxx"
39 
40 //forward declaration
41 class SMDS_MeshNode;
43 
45 typedef boost::shared_ptr<SMESH_OctreeNodeIterator> SMESH_OctreeNodeIteratorPtr;
46 
48 
49 public:
50 
51  // Constructor
52  SMESH_OctreeNode (const std::set<const SMDS_MeshNode*>& theNodes, const int maxLevel = -1,
53  const int maxNbNodes = 5, const double minBoxSize = 0.);
54 
55 //=============================
59 //=============================
60  virtual ~SMESH_OctreeNode () {};
61 
62  // Tells us if SMESH_OctreeNode is a leaf or not (-1 = not initialiazed)
63  virtual const bool isLeaf();
64 
65  // Tells us if Node is inside the current box with the precision "precision"
66  virtual const bool isInside(const SMDS_MeshNode * Node, const double precision = 0.);
67 
68  // Return in Result a list of Nodes potentials to be near Node
69  void NodesAround(const SMDS_MeshNode * Node,
70  std::list<const SMDS_MeshNode*>* Result,
71  const double precision = 0.);
72 
73  // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
74  // Search for all the nodes in nodes
75  void FindCoincidentNodes ( std::set<const SMDS_MeshNode*>* nodes,
76  const double theTolerance,
77  std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes);
78 
79  // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
80  // theTolerance search for all the nodes in nodes
81  static void FindCoincidentNodes ( std::set<const SMDS_MeshNode*> nodes,
82  std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes,
83  const double theTolerance = 0.00001, const int maxLevel = -1,
84  const int maxNbNodes = 5);
96  int NbNodes() const { return myNbNodes; }
97 
98 protected:
99 
100 //=============================
104 //=============================
106 
107  // Shares the father's data with each of his child
108  virtual void buildChildrenData();
109 
110  // Compute the bounding box of the whole set of nodes myNodes (only used for OctreeNode level 0)
111  void computeBoxForFather();
112 
113  // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
115 
116  // Return in result a list of nodes closed to Node and remove it from SetOfNodes
117  void FindCoincidentNodes( const SMDS_MeshNode * Node,
118  std::set<const SMDS_MeshNode*>* SetOfNodes,
119  std::list<const SMDS_MeshNode*>* Result,
120  const double precision);
121 
122  // The max number of nodes a leaf box can contain
124 
125  // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
126  std::set<const SMDS_MeshNode*> myNodes;
127 
128  // The number of nodes I have inside the box
130 };
131 
132 #endif
SMESH_OctreeNode()
Empty constructor.
SMDS_Iterator< SMESH_OctreeNode * > SMESH_OctreeNodeIterator
void FindCoincidentNodes(std::set< const SMDS_MeshNode * > *nodes, const double theTolerance, std::list< std::list< const SMDS_MeshNode * > > *theGroupsOfNodes)
virtual SMESH_Octree * allocateOctreeChild()
SMDS_NodeIteratorPtr GetNodeIterator()
Return nodes iterator.
virtual const bool isLeaf()
std::set< const SMDS_MeshNode * > myNodes
int NbNodes() const
Return nb nodes in a tree.
virtual void buildChildrenData()
boost::shared_ptr< SMDS_Iterator< const SMDS_MeshNode * > > SMDS_NodeIteratorPtr
Abstract class for iterators.
virtual ~SMESH_OctreeNode()
Empty destructor.
virtual const bool isInside(const SMDS_MeshNode *Node, const double precision=0.)
boost::shared_ptr< SMESH_OctreeNodeIterator > SMESH_OctreeNodeIteratorPtr
void computeBoxForFather()
SMESH_OctreeNodeIteratorPtr GetChildrenIterator()
Return iterator over children.
void NodesAround(const SMDS_MeshNode *Node, std::list< const SMDS_MeshNode * > *Result, const double precision=0.)