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