14#ifndef ROOT_Math_Delaunay2D
15#define ROOT_Math_Delaunay2D
35 #pragma push_macro("PTR")
38 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
39 #include <CGAL/Delaunay_triangulation_2.h>
40 #include <CGAL/Triangulation_vertex_base_with_info_2.h>
41 #include <CGAL/Interpolation_traits_2.h>
42 #include <CGAL/natural_neighbor_coordinates_2.h>
43 #include <CGAL/interpolation_functions.h>
45 #pragma pop_macro("PTR")
126 return (
x+offset)*factor;
175 enum class Initialization :
char {
UNINITIALIZED, INITIALIZING, INITIALIZED};
176 std::atomic<Initialization>
fInit;
188 template<
class Po
intWithInfoMap,
typename ValueType >
189 struct Data_access :
public std::unary_function< typename PointWithInfoMap::key_type,
190 std::pair<ValueType, bool> >
193 Data_access(
const PointWithInfoMap&
points,
const ValueType * values)
194 : _points(
points), _values(values){};
196 std::pair< ValueType, bool>
197 operator()(
const typename PointWithInfoMap::key_type& p)
const {
198 typename PointWithInfoMap::const_iterator mit = _points.find(p);
199 if(mit!= _points.end())
200 return std::make_pair(_values[mit->second],
true);
201 return std::make_pair(ValueType(),
false);
204 const PointWithInfoMap& _points;
205 const ValueType * _values;
208 typedef CGAL::Exact_predicates_inexact_constructions_kernel
K;
209 typedef CGAL::Triangulation_vertex_base_with_info_2<uint, K> Vb;
210 typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
211 typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay;
212 typedef CGAL::Interpolation_traits_2<K> Traits;
213 typedef K::FT Coord_type;
214 typedef K::Point_2 Point;
215 typedef std::map<Point, Vb::Info, K::Less_xy_2> PointWithInfoMap;
216 typedef Data_access< PointWithInfoMap, double > Value_access;
218 Delaunay fCGALdelaunay;
219 PointWithInfoMap fNormalizedPoints;
TRObject operator()(const T1 &t1) const
Class to generate a Delaunay triangulation of a 2D set of points.
Triangles::const_iterator end() const
double fXNmin
Pointer to Z array.
double DoInterpolateNormalized(double x, double y)
internal method to compute the interpolation
int CellY(double y) const
Triangles::const_iterator begin() const
Delaunay2D(const Delaunay2D &)
double Interpolate(double x, double y)
Return the Interpolated z value corresponding to the (x,y) point.
const double * fZ
Pointer to Y array.
double fXNmax
Minimum value of fXN.
void SetZOuterValue(double z=0.)
set z value to be returned for points outside the region
double fZout
Normalization factor Y.
Int_t NumberOfTriangles() const
return the number of triangles
double fOffsetY
Normalization offset X.
Delaunay2D & operator=(const Delaunay2D &)
double ZOuterValue() const
return the user defined Z-outer value
Triangles fTriangles
True if FindAllTriangels() has been performed.
unsigned int Cell(UInt_t x, UInt_t y) const
grid cells with containing triangles
double Linear_transform(double x, double offset, double factor)
double fYCellStep
inverse denominator to calculate X cell = fNCells / (fXNmax - fXNmin)
std::vector< double > fYN
normalized X
Delaunay2D(int n, const double *x, const double *y, const double *z, double xmin=0, double xmax=0, double ymin=0, double ymax=0)
class constructor from array of data points
void FindAllTriangles()
Find all triangles.
static const int fNCells
normalized Y
std::vector< double > fXN
Triangles of Triangulation.
double fXCellStep
number of cells to divide the normalized space
std::set< UInt_t > fCells[(fNCells+1) *(fNCells+1)]
inverse denominator to calculate X cell = fNCells / (fYNmax - fYNmin)
double fYNmin
Maximum value of fXN.
double fOffsetX
Maximum value of fYN.
Int_t fNpoints
Number of Delaunay triangles found.
std::vector< Triangle > Triangles
Bool_t fInit
Height for points lying outside the convex hull.
const double * fY
Pointer to X array (managed externally)
void SetInputPoints(int n, const double *x, const double *y, const double *z, double xmin=0, double xmax=0, double ymin=0, double ymax=0)
set the input points for building the graph
const double * fX
Number of data points.
void DoNormalizePoints()
internal function to normalize the points
double fYNmax
Minimum value of fYN.
double fScaleFactorY
Normalization factor X.
double fScaleFactorX
Normalization offset Y.
void DoFindTriangles()
internal function to find the triangle use Triangle or CGAL if flag is set
int CellX(double x) const
Namespace for new Math classes and functions.
static const uint32_t K[64]
static const Int_t UNINITIALIZED