1 // Copyright (C) 2007-2010 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.
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 // SMESH SMESH_OctreeNode : Octree with Nodes set
24 // inherites global class SMESH_Octree
25 // File : SMESH_OctreeNode.hxx
26 // Created : Tue Jan 16 16:00:00 2007
27 // Author : Nicolas Geimer & Aurelien Motteux (OCC)
30 #ifndef _SMESH_OCTREENODE_HXX_
31 #define _SMESH_OCTREENODE_HXX_
33 #include "SMESH_Octree.hxx"
35 #include "SMDS_MeshNode.hxx"
41 #include "SMDS_ElemIterator.hxx"
45 class SMESH_OctreeNode;
47 typedef SMDS_Iterator<SMESH_OctreeNode*> SMESH_OctreeNodeIterator;
48 typedef boost::shared_ptr<SMESH_OctreeNodeIterator> SMESH_OctreeNodeIteratorPtr;
49 typedef std::set< const SMDS_MeshNode*, TIDCompare > TIDSortedNodeSet;
51 class SMESH_OctreeNode : public SMESH_Octree {
56 SMESH_OctreeNode (const TIDSortedNodeSet& theNodes, const int maxLevel = 8,
57 const int maxNbNodes = 5, const double minBoxSize = 0.);
59 //=============================
61 * \brief Empty destructor
63 //=============================
64 virtual ~SMESH_OctreeNode () {};
66 // Tells us if Node is inside the current box with the precision "precision"
67 virtual const bool isInside(const gp_XYZ& p, const double precision = 0.);
69 // Return in Result a list of Nodes potentials to be near Node
70 void NodesAround(const SMDS_MeshNode * Node,
71 std::list<const SMDS_MeshNode*>* Result,
72 const double precision = 0.);
74 // Return in dist2Nodes nodes mapped to their square distance from Node
75 bool NodesAround(const gp_XYZ& node,
76 std::map<double, const SMDS_MeshNode*>& dist2Nodes,
79 // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
80 // Search for all the nodes in nodes
81 void FindCoincidentNodes ( TIDSortedNodeSet* nodes,
82 const double theTolerance,
83 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes);
85 // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
86 // theTolerance search for all the nodes in nodes
87 static void FindCoincidentNodes ( TIDSortedNodeSet& nodes,
88 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes,
89 const double theTolerance = 0.00001,
90 const int maxLevel = -1,
91 const int maxNbNodes = 5);
93 * \brief Update data according to node movement
95 void UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt );
97 * \brief Return iterator over children
99 SMESH_OctreeNodeIteratorPtr GetChildrenIterator();
101 * \brief Return nodes iterator
103 SMDS_NodeIteratorPtr GetNodeIterator();
105 * \brief Return nb nodes in a tree
107 int NbNodes() const { return myNodes.size(); }
111 SMESH_OctreeNode (int maxNbNodes );
113 // Compute the bounding box of the whole set of nodes myNodes
114 virtual Bnd_B3d* buildRootBox();
116 // Shares the father's data with each of his child
117 virtual void buildChildrenData();
119 // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
120 virtual SMESH_Octree* allocateOctreeChild() const;
122 // Return in result a list of nodes closed to Node and remove it from SetOfNodes
123 void FindCoincidentNodes( const SMDS_MeshNode * Node,
124 TIDSortedNodeSet* SetOfNodes,
125 std::list<const SMDS_MeshNode*>* Result,
126 const double precision);
128 // The max number of nodes a leaf box can contain
131 // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
132 TIDSortedNodeSet myNodes;