SALOME - SMESH
|
00001 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 // SMESH SMESH_OctreeNode : Octree with Nodes set 00023 // inherites global class SMESH_Octree 00024 // 00025 // File : SMESH_OctreeNode.hxx 00026 // Created : Tue Jan 16 16:00:00 2007 00027 // Author : Nicolas Geimer & Aurélien Motteux (OCC) 00028 // Module : SMESH 00029 00030 #ifndef _SMESH_OCTREENODE_HXX_ 00031 #define _SMESH_OCTREENODE_HXX_ 00032 00033 #include "SMESH_Octree.hxx" 00034 00035 #include <list> 00036 #include <set> 00037 #include <map> 00038 00039 #include "SMDS_ElemIterator.hxx" 00040 00041 //forward declaration 00042 class SMDS_MeshNode; 00043 class SMESH_OctreeNode; 00044 00045 typedef SMDS_Iterator<SMESH_OctreeNode*> SMESH_OctreeNodeIterator; 00046 typedef boost::shared_ptr<SMESH_OctreeNodeIterator> SMESH_OctreeNodeIteratorPtr; 00047 00048 class SMESH_OctreeNode : public SMESH_Octree { 00049 00050 public: 00051 00052 // Constructor 00053 SMESH_OctreeNode (const std::set<const SMDS_MeshNode*>& theNodes, const int maxLevel = -1, 00054 const int maxNbNodes = 5, const double minBoxSize = 0.); 00055 00056 //============================= 00060 //============================= 00061 virtual ~SMESH_OctreeNode () {}; 00062 00063 // Tells us if Node is inside the current box with the precision "precision" 00064 virtual const bool isInside(const SMDS_MeshNode * Node, const double precision = 0.); 00065 00066 // Return in Result a list of Nodes potentials to be near Node 00067 void NodesAround(const SMDS_MeshNode * Node, 00068 std::list<const SMDS_MeshNode*>* Result, 00069 const double precision = 0.); 00070 00071 // Return in dist2Nodes nodes mapped to their square distance from Node 00072 bool NodesAround(const SMDS_MeshNode * Node, 00073 std::map<double, const SMDS_MeshNode*>& dist2Nodes, 00074 double precision); 00075 00076 // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance 00077 // Search for all the nodes in nodes 00078 void FindCoincidentNodes ( std::set<const SMDS_MeshNode*>* nodes, 00079 const double theTolerance, 00080 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes); 00081 00082 // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within 00083 // theTolerance search for all the nodes in nodes 00084 static void FindCoincidentNodes ( std::set<const SMDS_MeshNode*>& nodes, 00085 std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes, 00086 const double theTolerance = 0.00001, 00087 const int maxLevel = -1, 00088 const int maxNbNodes = 5); 00092 void UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ); 00096 SMESH_OctreeNodeIteratorPtr GetChildrenIterator(); 00100 SMDS_NodeIteratorPtr GetNodeIterator(); 00104 int NbNodes() const { return myNodes.size(); } 00105 00106 protected: 00107 00108 SMESH_OctreeNode (int maxNbNodes ); 00109 00110 // Compute the bounding box of the whole set of nodes myNodes 00111 virtual Bnd_B3d* buildRootBox(); 00112 00113 // Shares the father's data with each of his child 00114 virtual void buildChildrenData(); 00115 00116 // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren() 00117 virtual SMESH_Octree* allocateOctreeChild() const; 00118 00119 // Return in result a list of nodes closed to Node and remove it from SetOfNodes 00120 void FindCoincidentNodes( const SMDS_MeshNode * Node, 00121 std::set<const SMDS_MeshNode*>* SetOfNodes, 00122 std::list<const SMDS_MeshNode*>* Result, 00123 const double precision); 00124 00125 // The max number of nodes a leaf box can contain 00126 int myMaxNbNodes; 00127 00128 // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf) 00129 std::set<const SMDS_MeshNode*> myNodes; 00130 00131 }; 00132 00133 #endif