]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
0021756: [CEA 602] MEDPartitioner improvements
authoreap <eap@opencascade.com>
Fri, 28 Dec 2012 09:49:56 +0000 (09:49 +0000)
committereap <eap@opencascade.com>
Fri, 28 Dec 2012 09:49:56 +0000 (09:49 +0000)
+  /*!
+   * \brief Class encapsulating BBTree of dimension given at construction and
+   *        providing all features of BBTree
+   */
+  class BBTreeOfDim

src/MEDPartitioner/MEDPARTITIONER_Utils.cxx
src/MEDPartitioner/MEDPARTITIONER_Utils.hxx

index 6bbe1a86c2b6e3bf54e65dd28de5aebd07bff9a2..64488d052a0170e0207389a2db0e8fb76ed285a0 100644 (file)
@@ -826,3 +826,54 @@ ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::CreateEmptyMEDCouplingUMesh()
   umesh->checkCoherency();
   return umesh;
 }
+
+namespace MEDPARTITIONER
+{
+  BBTreeOfDim::BBTreeOfDim( int           dim,
+                            const double* bbs,
+                            int*          elems,
+                            int           level,
+                            int           nbelems,
+                            double        epsilon)
+  {
+    switch ( dim )
+      {
+      case 3:
+        _tree=new BBTree<3> (bbs,elems,level,nbelems,epsilon);
+        _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 3 >;
+        _PgetIntersectingElems   = & BBTreeOfDim::_getIntersectingElems< 3 >;
+        break;
+      case 2:
+        _tree=new BBTree<2> (bbs,elems,level,nbelems,epsilon);
+        _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 2 >;
+        _PgetIntersectingElems   = & BBTreeOfDim::_getIntersectingElems< 2 >;
+        break;
+      case 1:
+        _tree=new BBTree<1> (bbs,elems,level,nbelems,epsilon);
+        _PgetElementsAroundPoint = & BBTreeOfDim::_getElementsAroundPoint< 1 >;
+        _PgetIntersectingElems   = & BBTreeOfDim::_getIntersectingElems< 1 >;
+        break;
+      default:
+        _tree=0;
+        throw INTERP_KERNEL::Exception("BBTreeOfDim(): wrong space dimension");
+      }
+  }
+
+  BBTreeOfDim::~BBTreeOfDim()
+  {
+    delete (BBTree<3>*)_tree;
+  }
+
+  void BBTreeOfDim::getElementsAroundPoint( const double* coordsPtr,
+                                            std::vector<int>& elems ) const
+  {
+    BBTreeOfDim* me = (BBTreeOfDim*) this;
+    (me->*_PgetElementsAroundPoint) ( coordsPtr, elems );
+  }
+  void BBTreeOfDim::getIntersectingElems(const double* bb,
+                                         std::vector<int>& elems) const
+  {
+    BBTreeOfDim* me = (BBTreeOfDim*) this;
+    (me->*_PgetIntersectingElems) ( bb, elems );
+  }
+}
index 02b74cf2855573bfb6055a2b0108e6725dea3601..1fcdc33a2a1ca5a26ffdfa7f2795081f71bba812 100644 (file)
@@ -23,6 +23,7 @@
 #include "MEDPARTITIONER.hxx"
 
 #include "MEDCouplingUMesh.hxx"
+#include "BBTree.txx"
 
 #include <string>
 #include <vector>
@@ -133,5 +134,44 @@ namespace MEDPARTITIONER
     /*! used for descriptions of components of fields for example...*/
     static std::vector<std::string> _General_Informations;
   };
+
+
+
+  /*!
+   * \brief Class encapsulating BBTree of dimension given at construction and
+   *        providing all features of BBTree
+   */
+  class BBTreeOfDim
+  {
+    void * _tree;
+    void (BBTreeOfDim::*_PgetElementsAroundPoint)( const double* coordsPtr,
+                                                   std::vector<int>& elems ) const;
+    void (BBTreeOfDim::*_PgetIntersectingElems)( const double* bb,
+                                                 std::vector<int>& elems ) const;
+
+    template< int dim>
+    void _getElementsAroundPoint( const double* coordsPtr,
+                                  std::vector<int>& elems ) const
+    {
+      ((BBTree<dim,int>*)_tree)->getElementsAroundPoint( coordsPtr, elems );
+    }
+    template< int dim>
+    void _getIntersectingElems(const double* bb,
+                               std::vector<int>& elems) const
+    {
+      ((BBTree<dim,int>*)_tree)->getIntersectingElems( bb, elems );
+    }
+  public:
+
+    BBTreeOfDim( int           dim,
+                 const double* bbs,
+                 int*          elems,
+                 int           level,
+                 int           nbelems,
+                 double        epsilon=1e-12);
+    ~BBTreeOfDim();
+    void getElementsAroundPoint(const double* coordsPtr, std::vector<int>& elems ) const;
+    void getIntersectingElems  (const double* bb,        std::vector<int>& elems)  const;
+  };
 }
 #endif