Version: 6.3.1

src/SMESH/SMESH_OctreeNode.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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_Octree.hxx"
00034 #include <gp_Pnt.hxx>
00035 #include "SMDS_MeshNode.hxx"
00036 
00037 #include <list>
00038 #include <set>
00039 #include <map>
00040 
00041 #include "SMDS_ElemIterator.hxx"
00042 
00043 //forward declaration
00044 class SMDS_MeshNode;
00045 class SMESH_OctreeNode;
00046 
00047 typedef SMDS_Iterator<SMESH_OctreeNode*>              SMESH_OctreeNodeIterator;
00048 typedef boost::shared_ptr<SMESH_OctreeNodeIterator>   SMESH_OctreeNodeIteratorPtr;
00049 typedef std::set< const SMDS_MeshNode*, TIDCompare >  TIDSortedNodeSet;
00050 
00051 class SMESH_OctreeNode : public SMESH_Octree {
00052 
00053 public:
00054 
00055   // Constructor
00056   SMESH_OctreeNode (const TIDSortedNodeSet& theNodes, const int maxLevel = 8,
00057                     const int maxNbNodes = 5, const double minBoxSize = 0.);
00058 
00059 //=============================
00063 //=============================
00064   virtual ~SMESH_OctreeNode () {};
00065 
00066   // Tells us if Node is inside the current box with the precision "precision"
00067   virtual const bool isInside(const gp_XYZ& p, const double precision = 0.);
00068 
00069   // Return in Result a list of Nodes potentials to be near Node
00070   void               NodesAround(const SMDS_MeshNode *            Node,
00071                                  std::list<const SMDS_MeshNode*>* Result,
00072                                  const double                     precision = 0.);
00073 
00074   // Return in dist2Nodes nodes mapped to their square distance from Node
00075   bool               NodesAround(const gp_XYZ& node,
00076                                  std::map<double, const SMDS_MeshNode*>& dist2Nodes,
00077                                  double                                  precision);
00078 
00079   // Return in theGroupsOfNodes a list of group of nodes close to each other within theTolerance
00080   // Search for all the nodes in nodes
00081   void               FindCoincidentNodes ( TIDSortedNodeSet*           nodes,
00082                                            const double                theTolerance,
00083                                            std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes);
00084 
00085   // Static method that return in theGroupsOfNodes a list of group of nodes close to each other within
00086   // theTolerance search for all the nodes in nodes
00087   static void        FindCoincidentNodes ( TIDSortedNodeSet&                              nodes,
00088                                            std::list< std::list< const SMDS_MeshNode*> >* theGroupsOfNodes,
00089                                            const double theTolerance = 0.00001,
00090                                            const int maxLevel = -1,
00091                                            const int maxNbNodes = 5);
00095   void                        UpdateByMoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt );
00099   SMESH_OctreeNodeIteratorPtr GetChildrenIterator();
00103   SMDS_NodeIteratorPtr        GetNodeIterator();
00107   int                         NbNodes() const { return myNodes.size(); }
00108 
00109 protected:
00110 
00111   SMESH_OctreeNode (int maxNbNodes );
00112 
00113   // Compute the bounding box of the whole set of nodes myNodes
00114   virtual Bnd_B3d*      buildRootBox();
00115 
00116   // Shares the father's data with each of his child
00117   virtual void          buildChildrenData();
00118 
00119   // Construct an empty SMESH_OctreeNode used by SMESH_Octree::buildChildren()
00120   virtual SMESH_Octree* allocateOctreeChild() const;
00121 
00122   // Return in result a list of nodes closed to Node and remove it from SetOfNodes
00123   void                  FindCoincidentNodes( const SMDS_MeshNode *            Node,
00124                                              TIDSortedNodeSet*                SetOfNodes,
00125                                              std::list<const SMDS_MeshNode*>* Result,
00126                                              const double                     precision);
00127 
00128   // The max number of nodes a leaf box can contain
00129   int                myMaxNbNodes;
00130 
00131   // The set of nodes inside the box of the Octree (Empty if Octree is not a leaf)
00132   TIDSortedNodeSet   myNodes;
00133 
00134 };
00135 
00136 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS