1 // SMESH SMESH_OctreeNode : Octree with Nodes set
2 // inherites global class SMESH_Octree
4 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
21 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 // File : SMESH_OctreeNode.hxx
26 // Created : Tue Jan 16 16:00:00 2007
27 // Author : Nicolas Geimer & Aurélien Motteux (OCC)
30 #ifndef _SMESH_OCTREENODE_HXX_
31 #define _SMESH_OCTREENODE_HXX_
33 #include "SMESH_Octree.hxx"
38 #include "SMDS_ElemIterator.hxx"
42 class SMESH_OctreeNode;
44 typedef SMDS_Iterator<SMESH_OctreeNode*> SMESH_OctreeNodeIterator;
45 typedef boost::shared_ptr<SMESH_OctreeNodeIterator> SMESH_OctreeNodeIteratorPtr;
47 class SMESH_OctreeNode : public SMESH_Octree{
52 SMESH_OctreeNode (const std::set<const SMDS_MeshNode*>& theNodes, const int maxLevel = -1,
53 const int maxNbNodes = 5 , const double minBoxSize = 0.);
55 //=============================
57 * \brief Empty destructor
59 //=============================
60 virtual ~SMESH_OctreeNode () {};
62 // Tells us if SMESH_OctreeNode is a leaf or not (-1 = not initialiazed)
63 virtual const bool isLeaf();
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. );
68 // Return in Result a list of Nodes potentials to be near Node
69 void NodesAround( const SMDS_MeshNode * Node , std::list<const SMDS_MeshNode*>* Result,
70 const double precision = 0. );
72 // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
73 // Search for all the nodes in nodes
74 void FindCoincidentNodes ( std::set<const SMDS_MeshNode*>* nodes,
75 const double theTolerance,
76 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes);
78 // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
79 // theTolerance search for all the nodes in nodes
80 static void FindCoincidentNodes ( std::set<const SMDS_MeshNode*> nodes,
81 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes,
82 const double theTolerance = 0.00001, const int maxLevel = -1,
83 const int maxNbNodes = 5);
85 * \brief Return iterator over children
87 SMESH_OctreeNodeIteratorPtr GetChildrenIterator();
89 * \brief Return nodes iterator
91 SMDS_NodeIteratorPtr GetNodeIterator();
93 * \brief Return nb nodes in a tree
95 int NbNodes() const { return myNbNodes; }
99 //=============================
101 * \brief Empty constructor
103 //=============================
104 SMESH_OctreeNode (){};
106 // Shares the father's data with each of his child
107 virtual void buildChildrenData();
109 // Compute the bounding box of the whole set of nodes myNodes (only used for OctreeNode level 0)
110 void computeBoxForFather();
112 // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
113 virtual SMESH_Octree* allocateOctreeChild();
115 // Return in result a list of nodes closed to Node and remove it from SetOfNodes
116 void FindCoincidentNodes( const SMDS_MeshNode * Node,
117 std::set<const SMDS_MeshNode*>* SetOfNodes,
118 std::list<const SMDS_MeshNode*>* Result,
119 const double precision);
121 // The max number of nodes a leaf box can contain
124 // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
125 std::set<const SMDS_MeshNode*> myNodes;
127 // The number of nodes I have inside the box