66 if (n == 0 || !x || !y || !z )
return;
69 xmin = *std::min_element(x, x+n);
70 xmax = *std::max_element(x, x+n);
72 ymin = *std::min_element(y, y+n);
73 ymax = *std::max_element(y, y+n);
130 if(
fInit.load(std::memory_order::memory_order_relaxed) == Initialization::INITIALIZED)
134 if(
fInit.compare_exchange_strong(cState, Initialization::INITIALIZING,
135 std::memory_order::memory_order_release, std::memory_order::memory_order_relaxed))
157 fInit = Initialization::INITIALIZED;
158 }
else while(cState != Initialization::INITIALIZED) {
160 cState =
fInit.load(std::memory_order::memory_order_relaxed);
171 void Delaunay2D::DonormalizePoints() {
177 fNormalizedPoints.insert(std::make_pair(p, n));
183 fCGALdelaunay.insert(fNormalizedPoints.begin(), fNormalizedPoints.end());
185 std::transform(fCGALdelaunay.finite_faces_begin(),
186 fCGALdelaunay.finite_faces_end(), std::back_inserter(
fTriangles),
187 [] (
const Delaunay::Face face) -> Triangle {
191 auto transform = [&] (
const unsigned int i) {
192 tri.x[i] = face.vertex(i)->point().x();
193 tri.y[i] = face.vertex(i)->point().y();
194 tri.idx[i] = face.vertex(i)->info();
219 std::vector<std::pair<Point, Coord_type> > coords;
220 auto nn = CGAL::natural_neighbor_coordinates_2(fCGALdelaunay, p,
221 std::back_inserter(coords));
230 Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
231 nn.second, Value_access(fNormalizedPoints,
fZ));
256 s.pointlist =
nullptr;
257 s.pointattributelist =
nullptr;
258 s.pointmarkerlist =
nullptr;
259 s.numberofpoints = 0;
260 s.numberofpointattributes = 0;
262 s.trianglelist =
nullptr;
263 s.triangleattributelist =
nullptr;
264 s.trianglearealist =
nullptr;
265 s.neighborlist =
nullptr;
266 s.numberoftriangles = 0;
267 s.numberofcorners = 0;
268 s.numberoftriangleattributes = 0;
270 s.segmentlist =
nullptr;
271 s.segmentmarkerlist =
nullptr;
272 s.numberofsegments = 0;
274 s.holelist =
nullptr;
277 s.regionlist =
nullptr;
278 s.numberofregions = 0;
280 s.edgelist =
nullptr;
281 s.edgemarkerlist =
nullptr;
282 s.normlist =
nullptr;
287 if(s.pointlist !=
nullptr)
free(s.pointlist);
288 if(s.pointattributelist !=
nullptr)
free(s.pointattributelist);
289 if(s.pointmarkerlist !=
nullptr)
free(s.pointmarkerlist);
291 if(s.trianglelist !=
nullptr)
free(s.trianglelist);
292 if(s.triangleattributelist !=
nullptr)
free(s.triangleattributelist);
293 if(s.trianglearealist !=
nullptr)
free(s.trianglearealist);
294 if(s.neighborlist !=
nullptr)
free(s.neighborlist);
296 if(s.segmentlist !=
nullptr)
free(s.segmentlist);
297 if(s.segmentmarkerlist !=
nullptr)
free(s.segmentmarkerlist);
299 if(s.holelist !=
nullptr)
free(s.holelist);
301 if(s.regionlist !=
nullptr)
free(s.regionlist);
303 if(s.edgelist !=
nullptr)
free(s.edgelist);
304 if(s.edgemarkerlist !=
nullptr)
free(s.edgemarkerlist);
305 if(s.normlist !=
nullptr)
free(s.normlist);
309 initStruct(in); initStruct(out);
327 auto transform = [&] (
const unsigned int v) {
348 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]) );
352 auto bx = std::minmax({tri.
x[0], tri.
x[1], tri.
x[2]});
353 auto by = std::minmax({tri.
y[0], tri.
y[1], tri.
y[2]});
355 unsigned int cellXmin =
CellX(bx.first);
356 unsigned int cellXmax =
CellX(bx.second);
358 unsigned int cellYmin =
CellY(by.first);
359 unsigned int cellYmax =
CellY(by.second);
361 for(
unsigned int i = cellXmin; i <= cellXmax; ++i)
362 for(
unsigned int j = cellYmin; j <= cellYmax; ++j){
369 freeStruct(in); freeStruct(out);
383 auto bayCoords = [&] (
const unsigned int t) -> std::tuple<double, double, double> {
389 return std::make_tuple(la, lb, (1 - la - lb));
392 auto inTriangle = [] (
const std::tuple<double, double, double> & coords) ->
bool {
393 return std::get<0>(coords) >= 0 && std::get<1>(coords) >= 0 && std::get<2>(coords) >= 0;
403 auto coords = bayCoords(t);
405 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.
double fScaleFactorX
Normalization offset Y.
double DoInterpolateNormalized(double x, double y)
internal method to compute the interpolation
Vc_ALWAYS_INLINE void free(T *p)
Frees memory that was allocated with Vc::malloc.
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.
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.
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 CellY(double y) const
Vc_ALWAYS_INLINE_L T *Vc_ALWAYS_INLINE_R malloc(size_t n)
Allocates memory on the Heap with alignment and padding suitable for vectorized access.
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.