69 if (n == 0 || !x || !y || !z )
return;
72 xmin = *std::min_element(x, x+n);
73 xmax = *std::max_element(x, x+n);
75 ymin = *std::min_element(y, y+n);
76 ymax = *std::max_element(y, y+n);
133 if(
fInit.load(std::memory_order::memory_order_relaxed) == Initialization::INITIALIZED)
137 if(
fInit.compare_exchange_strong(cState, Initialization::INITIALIZING,
138 std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
160 fInit = Initialization::INITIALIZED;
161 }
else while(cState != Initialization::INITIALIZED) {
163 cState =
fInit.load(std::memory_order::memory_order_relaxed);
174 void Delaunay2D::DonormalizePoints() {
180 fNormalizedPoints.insert(std::make_pair(p, n));
186 fCGALdelaunay.insert(fNormalizedPoints.begin(), fNormalizedPoints.end());
188 std::transform(fCGALdelaunay.finite_faces_begin(),
189 fCGALdelaunay.finite_faces_end(), std::back_inserter(
fTriangles),
190 [] (
const Delaunay::Face face) ->
Triangle {
194 auto transform = [&] (
const unsigned int i) {
195 tri.
x[i] = face.vertex(i)->point().x();
196 tri.
y[i] = face.vertex(i)->point().y();
197 tri.
idx[i] = face.vertex(i)->info();
222 std::vector<std::pair<Point, Coord_type> > coords;
223 auto nn = CGAL::natural_neighbor_coordinates_2(fCGALdelaunay, p,
224 std::back_inserter(coords));
233 Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
234 nn.second, Value_access(fNormalizedPoints,
fZ));
259 s.pointlist =
nullptr;
260 s.pointattributelist =
nullptr;
261 s.pointmarkerlist =
nullptr;
262 s.numberofpoints = 0;
263 s.numberofpointattributes = 0;
265 s.trianglelist =
nullptr;
266 s.triangleattributelist =
nullptr;
267 s.trianglearealist =
nullptr;
268 s.neighborlist =
nullptr;
269 s.numberoftriangles = 0;
270 s.numberofcorners = 0;
271 s.numberoftriangleattributes = 0;
273 s.segmentlist =
nullptr;
274 s.segmentmarkerlist =
nullptr;
275 s.numberofsegments = 0;
277 s.holelist =
nullptr;
280 s.regionlist =
nullptr;
281 s.numberofregions = 0;
283 s.edgelist =
nullptr;
284 s.edgemarkerlist =
nullptr;
285 s.normlist =
nullptr;
290 if(s.pointlist !=
nullptr)
free(s.pointlist);
291 if(s.pointattributelist !=
nullptr)
free(s.pointattributelist);
292 if(s.pointmarkerlist !=
nullptr)
free(s.pointmarkerlist);
294 if(s.trianglelist !=
nullptr)
free(s.trianglelist);
295 if(s.triangleattributelist !=
nullptr)
free(s.triangleattributelist);
296 if(s.trianglearealist !=
nullptr)
free(s.trianglearealist);
297 if(s.neighborlist !=
nullptr)
free(s.neighborlist);
299 if(s.segmentlist !=
nullptr)
free(s.segmentlist);
300 if(s.segmentmarkerlist !=
nullptr)
free(s.segmentmarkerlist);
302 if(s.holelist !=
nullptr)
free(s.holelist);
304 if(s.regionlist !=
nullptr)
free(s.regionlist);
306 if(s.edgelist !=
nullptr)
free(s.edgelist);
307 if(s.edgemarkerlist !=
nullptr)
free(s.edgemarkerlist);
308 if(s.normlist !=
nullptr)
free(s.normlist);
312 initStruct(in); initStruct(out);
330 auto transform = [&] (
const unsigned int v) {
351 tri.
invDenom = 1 / ( (tri.
y[1] - tri.
y[2])*(tri.
x[0] - tri.
x[2]) + (tri.
x[2] - tri.
x[1])*(tri.
y[0] - tri.
y[2]) );
355 auto bx = std::minmax({tri.
x[0], tri.
x[1], tri.
x[2]});
356 auto by = std::minmax({tri.
y[0], tri.
y[1], tri.
y[2]});
358 unsigned int cellXmin =
CellX(bx.first);
359 unsigned int cellXmax =
CellX(bx.second);
361 unsigned int cellYmin =
CellY(by.first);
362 unsigned int cellYmax =
CellY(by.second);
364 for(
unsigned int i = cellXmin; i <= cellXmax; ++i) {
365 for(
unsigned int j = cellYmin; j <= cellYmax; ++j) {
372 freeStruct(in); freeStruct(out);
386 auto bayCoords = [&] (
const unsigned int t) -> std::tuple<double, double, double> {
392 return std::make_tuple(la, lb, (1 - la - lb));
395 auto inTriangle = [] (
const std::tuple<double, double, double> & coords) ->
bool {
396 return std::get<0>(coords) >= 0 && std::get<1>(coords) >= 0 && std::get<2>(coords) >= 0;
406 auto coords = bayCoords(t);
408 if(inTriangle(coords)){
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
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
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)
double fXNmax
Minimum value of fXN.
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)
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.
void triangulate(char *triswitches, struct triangulateio *in, struct triangulateio *out, struct triangulateio *vorout)
const double * fX
Number of data points.
double fYNmin
Maximum value of fXN.
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.