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;
272 std::set<UInt_t>
fCells[(fNCells+1)*(fNCells+1)];
275 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.
int CellY(double y) const
TRObject operator()(const T1 &t1) 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.
Triangles::const_iterator begin() const
const double * fY
Pointer to X array (managed externally)
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
Int_t fNpoints
Number of Delaunay triangles found.
double fYCellStep
inverse denominator to calculate X cell = fNCells / (fXNmax - fXNmin)
double ZOuterValue() const
return the user defined Z-outer value
Namespace for new Math classes and functions.
you should not use this method at all Int_t Int_t z
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.
Int_t NumberOfTriangles() const
return the number of triangles
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.
Triangles::const_iterator end() const
int CellX(double x) const
double Interpolate(double x, double y)
Return the Interpolated z value corresponding to the (x,y) point.
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.