Version: 9.16.0
SMESH_OctreeNode.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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// 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)
28// Module : SMESH
29//
30#ifndef _SMESH_OCTREENODE_HXX_
31#define _SMESH_OCTREENODE_HXX_
32
33#include "SMDS_ElemIterator.hxx"
34#include "SMDS_MeshNode.hxx"
35#include "SMESH_Octree.hxx"
36#include "SMESH_Utils.hxx"
37
38#include <gp_Pnt.hxx>
39
40#include <list>
41#include <set>
42#include <map>
43#include <vector>
44
45//forward declaration
46class SMDS_MeshNode;
48
50typedef boost::shared_ptr<SMESH_OctreeNodeIterator> SMESH_OctreeNodeIteratorPtr;
51typedef std::set< const SMDS_MeshNode*, TIDCompare > TIDSortedNodeSet;
52typedef std::list< std::list< const SMDS_MeshNode*> > TListOfNodeLists;
53
55{
56 public:
57
58 // Constructor
59 SMESH_OctreeNode (const TIDSortedNodeSet& theNodes, const int maxLevel = 8,
60 const int maxNbNodes = 5, const double minBoxSize = 0.);
61
62 // destructor
63 virtual ~SMESH_OctreeNode () {};
64
65 // Tells us if Node is inside the current box with the precision "precision"
66 virtual bool isInside(const gp_XYZ& p, const double precision = 0.);
67
68 // Return in Result a list of Nodes potentials to be near Node
69 void AllNodesAround(const SMDS_MeshNode * node,
70 std::vector<const SMDS_MeshNode*>* result,
71 const double precision = 0.);
72
73 // Return in dist2Nodes nodes mapped to their square distance from Node
74 bool NodesAround(const gp_XYZ& point,
75 std::map<double, const SMDS_MeshNode*>& dist2Nodes,
76 double precision);
77
78 // Return a list of Nodes close to a point
79 void NodesAround(const gp_XYZ& point,
80 std::vector<const SMDS_MeshNode*>& nodes,
81 double precision);
82
83 // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
84 // Search for all the nodes in nodes
85 void FindCoincidentNodes ( TIDSortedNodeSet* nodes,
86 const double theTolerance,
87 TListOfNodeLists * theGroupsOfNodes);
88
89 // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
90 // theTolerance search for all the nodes in nodes
91 static void FindCoincidentNodes ( TIDSortedNodeSet& nodes,
92 TListOfNodeLists* theGroupsOfNodes,
93 const double theTolerance = 0.00001,
94 const int maxLevel = -1,
95 const int maxNbNodes = 5);
99 void UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt );
103 SMESH_OctreeNodeIteratorPtr GetChildrenIterator();
107 SMDS_NodeIteratorPtr GetNodeIterator();
111 size_t NbNodes() const { return myNodes.size(); }
112
113protected:
114
115 struct Limit : public SMESH_TreeLimit
116 {
118 Limit(int maxLevel, double minSize, int maxNbNodes)
119 :SMESH_TreeLimit(maxLevel, minSize), myMaxNbNodes(maxNbNodes) {}
120 };
121
122 int getMaxNbNodes() const;
123
125
126 // Compute the bounding box of the whole set of nodes myNodes
127 virtual Bnd_B3d* buildRootBox();
128
129 // Shares the father's data with each of his child
130 virtual void buildChildrenData();
131
132 // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
133 virtual SMESH_Octree* newChild() const;
134
135 // Return in result a list of nodes closed to Node
136 void findCoincidentNodes( const SMDS_MeshNode * Node,
137 TIDSortedNodeSet* SetOfNodes,
138 std::vector<const SMDS_MeshNode*>* Result,
139 const double precision);
140
141 // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
142 std::vector< const SMDS_MeshNode* > myNodes;
143
144};
145
146#endif
boost::shared_ptr< SMDS_Iterator< const SMDS_MeshNode * > > SMDS_NodeIteratorPtr
Definition: SMDS_ElemIterator.hxx:46
boost::shared_ptr< SMESH_OctreeNodeIterator > SMESH_OctreeNodeIteratorPtr
Definition: SMESH_OctreeNode.hxx:50
std::set< const SMDS_MeshNode *, TIDCompare > TIDSortedNodeSet
Definition: SMESH_OctreeNode.hxx:51
SMDS_Iterator< SMESH_OctreeNode * > SMESH_OctreeNodeIterator
Definition: SMESH_OctreeNode.hxx:49
std::list< std::list< const SMDS_MeshNode * > > TListOfNodeLists
Definition: SMESH_OctreeNode.hxx:52
#define SMESHUtils_EXPORT
Definition: SMESH_Utils.hxx:37
Abstract class for iterators.
Definition: SMDS_Iterator.hxx:33
Definition: SMDS_MeshNode.hxx:36
Definition: SMESH_OctreeNode.hxx:55
size_t NbNodes() const
Return nb nodes in a tree.
Definition: SMESH_OctreeNode.hxx:111
virtual ~SMESH_OctreeNode()
Definition: SMESH_OctreeNode.hxx:63
std::vector< const SMDS_MeshNode * > myNodes
Definition: SMESH_OctreeNode.hxx:142
3D tree of anything.
Definition: SMESH_Octree.hxx:45
virtual void buildChildrenData()=0
virtual box_type * buildRootBox()=0
virtual SMESH_Tree * newChild() const=0
@ Node
Selection of mesh nodes.
Definition: libSMESH_Swig.h:52
Definition: SMESH_OctreeNode.hxx:116
int myMaxNbNodes
Definition: SMESH_OctreeNode.hxx:117
Limit(int maxLevel, double minSize, int maxNbNodes)
Definition: SMESH_OctreeNode.hxx:118
Definition: SMESH_Tree.hxx:38