Salome HOME
50% of work performed of porting tests.
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_Utils.hxx
index 02b74cf2855573bfb6055a2b0108e6725dea3601..75a7f0b27001a8dde5923216c8e53c29a3d225eb 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -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