Back to index

salome-smesh  6.5.0
SMESH_OctreeNode.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 
00023 //  SMESH SMESH_OctreeNode : Octree with Nodes set
00024 //  inherites global class SMESH_Octree
00025 //  File      : SMESH_OctreeNode.hxx
00026 //  Created   : Tue Jan 16 16:00:00 2007
00027 //  Author    : Nicolas Geimer & Aurelien Motteux  (OCC)
00028 //  Module    : SMESH
00029 //
00030 #ifndef _SMESH_OCTREENODE_HXX_
00031 #define _SMESH_OCTREENODE_HXX_
00032 
00033 #include "SMESH_Utils.hxx"
00034 #include "SMESH_Octree.hxx"
00035 #include <gp_Pnt.hxx>
00036 #include "SMDS_MeshNode.hxx"
00037 
00038 #include <list>
00039 #include <set>
00040 #include <map>
00041 
00042 #include "SMDS_ElemIterator.hxx"
00043 
00044 //forward declaration
00045 class SMDS_MeshNode;
00046 class SMESH_OctreeNode;
00047 
00048 typedef SMDS_Iterator<SMESH_OctreeNode*>              SMESH_OctreeNodeIterator;
00049 typedef boost::shared_ptr<SMESH_OctreeNodeIterator>   SMESH_OctreeNodeIteratorPtr;
00050 typedef std::set< const SMDS_MeshNode*, TIDCompare >  TIDSortedNodeSet;
00051 
00052 class SMESHUtils_EXPORT SMESH_OctreeNode : public SMESH_Octree {
00053 
00054 public:
00055 
00056   // Constructor
00057   SMESH_OctreeNode (const TIDSortedNodeSet& theNodes, const int maxLevel = 8,
00058                     const int maxNbNodes = 5, const double minBoxSize = 0.);
00059 
00060 //=============================
00064 //=============================
00065   virtual ~SMESH_OctreeNode () {};
00066 
00067   // Tells us if Node is inside the current box with the precision "precision"
00068   virtual const bool isInside(const gp_XYZ& p, const double precision = 0.);
00069 
00070   // Return in Result a list of Nodes potentials to be near Node
00071   void               NodesAround(const SMDS_MeshNode *            Node,
00072                                  std::list<const SMDS_MeshNode*>* Result,
00073                                  const double                     precision = 0.);
00074 
00075   // Return in dist2Nodes nodes mapped to their square distance from Node
00076   bool               NodesAround(const gp_XYZ& node,
00077                                  std::map<double, const SMDS_MeshNode*>& dist2Nodes,
00078                                  double                                  precision);
00079 
00080   // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
00081   // Search for all the nodes in nodes
00082   void               FindCoincidentNodes ( TIDSortedNodeSet*           nodes,
00083                                            const double                theTolerance,
00084                                            std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes);
00085 
00086   // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
00087   // theTolerance search for all the nodes in nodes
00088   static void        FindCoincidentNodes ( TIDSortedNodeSet&                              nodes,
00089                                            std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes,
00090                                            const double theTolerance = 0.00001,
00091                                            const int maxLevel = -1,
00092                                            const int maxNbNodes = 5);
00096   void                        UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt );
00100   SMESH_OctreeNodeIteratorPtr GetChildrenIterator();
00104   SMDS_NodeIteratorPtr        GetNodeIterator();
00108   int                         NbNodes() const { return myNodes.size(); }
00109 
00110 protected:
00111 
00112   SMESH_OctreeNode (int maxNbNodes );
00113 
00114   // Compute the bounding box of the whole set of nodes myNodes
00115   virtual Bnd_B3d*      buildRootBox();
00116 
00117   // Shares the father's data with each of his child
00118   virtual void          buildChildrenData();
00119 
00120   // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
00121   virtual SMESH_Octree* allocateOctreeChild() const;
00122 
00123   // Return in result a list of nodes closed to Node and remove it from SetOfNodes
00124   void                  FindCoincidentNodes( const SMDS_MeshNode *            Node,
00125                                              TIDSortedNodeSet*                SetOfNodes,
00126                                              std::list<const SMDS_MeshNode*>* Result,
00127                                              const double                     precision);
00128 
00129   // The max number of nodes a leaf box can contain
00130   int                myMaxNbNodes;
00131 
00132   // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
00133   TIDSortedNodeSet   myNodes;
00134 
00135 };
00136 
00137 #endif