68 if (n == 0 || !x || !y || !z )
return;
71 xmin = *std::min_element(x, x+n);
72 xmax = *std::max_element(x, x+n);
74 ymin = *std::min_element(y, y+n);
75 ymax = *std::max_element(y, y+n);
132 if(
fInit.load(std::memory_order::memory_order_relaxed) == Initialization::INITIALIZED)
136 if(
fInit.compare_exchange_strong(cState, Initialization::INITIALIZING,
137 std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
159 fInit = Initialization::INITIALIZED;
160 }
else while(cState != Initialization::INITIALIZED) {
162 cState =
fInit.load(std::memory_order::memory_order_relaxed);
173 void Delaunay2D::DonormalizePoints() {
179 fNormalizedPoints.insert(std::make_pair(p, n));
185 fCGALdelaunay.insert(fNormalizedPoints.begin(), fNormalizedPoints.end());
187 std::transform(fCGALdelaunay.finite_faces_begin(),
188 fCGALdelaunay.finite_faces_end(), std::back_inserter(
fTriangles),
189 [] (
const Delaunay::Face face) ->
Triangle {
193 auto transform = [&] (
const unsigned int i) {
194 tri.
x[i] = face.vertex(i)->point().x();
195 tri.
y[i] = face.vertex(i)->point().y();
196 tri.
idx[i] = face.vertex(i)->info();
221 std::vector<std::pair<Point, Coord_type> > coords;
222 auto nn = CGAL::natural_neighbor_coordinates_2(fCGALdelaunay, p,
223 std::back_inserter(coords));
232 Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
233 nn.second, Value_access(fNormalizedPoints,
fZ));
258 s.pointlist =
nullptr;
259 s.pointattributelist =
nullptr;
260 s.pointmarkerlist =
nullptr;
261 s.numberofpoints = 0;
262 s.numberofpointattributes = 0;
264 s.trianglelist =
nullptr;
265 s.triangleattributelist =
nullptr;
266 s.trianglearealist =
nullptr;
267 s.neighborlist =
nullptr;
268 s.numberoftriangles = 0;
269 s.numberofcorners = 0;
270 s.numberoftriangleattributes = 0;
272 s.segmentlist =
nullptr;
273 s.segmentmarkerlist =
nullptr;
274 s.numberofsegments = 0;
276 s.holelist =
nullptr;
279 s.regionlist =
nullptr;
280 s.numberofregions = 0;
282 s.edgelist =
nullptr;
283 s.edgemarkerlist =
nullptr;
284 s.normlist =
nullptr;
289 if(s.pointlist !=
nullptr)
free(s.pointlist);
290 if(s.pointattributelist !=
nullptr)
free(s.pointattributelist);
291 if(s.pointmarkerlist !=
nullptr)
free(s.pointmarkerlist);
293 if(s.trianglelist !=
nullptr)
free(s.trianglelist);
294 if(s.triangleattributelist !=
nullptr)
free(s.triangleattributelist);
295 if(s.trianglearealist !=
nullptr)
free(s.trianglearealist);
296 if(s.neighborlist !=
nullptr)
free(s.neighborlist);
298 if(s.segmentlist !=
nullptr)
free(s.segmentlist);
299 if(s.segmentmarkerlist !=
nullptr)
free(s.segmentmarkerlist);
301 if(s.holelist !=
nullptr)
free(s.holelist);
303 if(s.regionlist !=
nullptr)
free(s.regionlist);
305 if(s.edgelist !=
nullptr)
free(s.edgelist);
306 if(s.edgemarkerlist !=
nullptr)
free(s.edgemarkerlist);
307 if(s.normlist !=
nullptr)
free(s.normlist);
311 initStruct(in); initStruct(out);
329 auto transform = [&] (
const unsigned int v) {
350 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]) );
354 auto bx = std::minmax({tri.
x[0], tri.
x[1], tri.
x[2]});
355 auto by = std::minmax({tri.
y[0], tri.
y[1], tri.
y[2]});
357 unsigned int cellXmin =
CellX(bx.first);
358 unsigned int cellXmax =
CellX(bx.second);
360 unsigned int cellYmin =
CellY(by.first);
361 unsigned int cellYmax =
CellY(by.second);
363 for(
unsigned int i = cellXmin; i <= cellXmax; ++i) {
364 for(
unsigned int j = cellYmin; j <= cellYmax; ++j) {
371 freeStruct(in); freeStruct(out);
385 auto bayCoords = [&] (
const unsigned int t) -> std::tuple<double, double, double> {
391 return std::make_tuple(la, lb, (1 - la - lb));
394 auto inTriangle = [] (
const std::tuple<double, double, double> & coords) ->
bool {
395 return std::get<0>(coords) >= 0 && std::get<1>(coords) >= 0 && std::get<2>(coords) >= 0;
405 auto coords = bayCoords(t);
407 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
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
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.