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);
180 for (i = 0; i < fNpoints; ++i) points[i] = CDT::V2d<double>::make(
fXN[i],
fYN[i]);
181 CDT::RemoveDuplicates(
points);
183 CDT::Triangulation<double> cdt;
184 cdt.insertVertices(
points);
185 cdt.eraseSuperTriangle();
187 auto AllTriangles = cdt.triangles;
188 auto AllVertices = cdt.vertices;
195 const auto& t = AllTriangles[i];
197 const auto&
v0 = AllVertices[t.vertices[0]];
200 tri.
idx[0] = t.vertices[0];
202 const auto&
v1 = AllVertices[t.vertices[1]];
205 tri.
idx[1] = t.vertices[1];
207 const auto&
v2 = AllVertices[t.vertices[2]];
210 tri.
idx[2] = t.vertices[2];
213 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]) );
217 auto bx = std::minmax({tri.
x[0], tri.
x[1], tri.
x[2]});
218 auto by = std::minmax({tri.
y[0], tri.
y[1], tri.
y[2]});
220 unsigned int cellXmin =
CellX(bx.first);
221 unsigned int cellXmax =
CellX(bx.second);
223 unsigned int cellYmin =
CellY(by.first);
224 unsigned int cellYmax =
CellY(by.second);
226 for(
unsigned int j = cellXmin; j <= cellXmax; j++) {
227 for(
unsigned int k = cellYmin; k <= cellYmax; k++) {
245 auto bayCoords = [&](
const unsigned int t) -> std::tuple<double, double, double> {
253 return std::make_tuple(la, lb, (1 - la - lb));
261 auto inTriangle = [](
const std::tuple<double, double, double> &coords) ->
bool {
262 constexpr double eps = -4 * std::numeric_limits<double>::epsilon();
263 return std::get<0>(coords) > eps && std::get<1>(coords) > eps && std::get<2>(coords) > eps;
274 auto coords = bayCoords(t);
279 if (inTriangle(coords)) {
295void Delaunay2D::DonormalizePoints() {
301 fNormalizedPoints.insert(std::make_pair(
p,
n));
307 fCGALdelaunay.insert(fNormalizedPoints.begin(), fNormalizedPoints.end());
309 std::transform(fCGALdelaunay.finite_faces_begin(),
310 fCGALdelaunay.finite_faces_end(), std::back_inserter(
fTriangles),
311 [] (
const Delaunay::Face face) -> Triangle {
315 auto transform = [&] (const unsigned int i) {
316 tri.x[i] = face.vertex(i)->point().x();
317 tri.y[i] = face.vertex(i)->point().y();
318 tri.idx[i] = face.vertex(i)->info();
331double Delaunay2D::DoInterpolateNormalized(
double xx,
double yy)
343 std::vector<std::pair<Point, Coord_type> > coords;
344 auto nn = CGAL::natural_neighbor_coordinates_2(fCGALdelaunay,
p,
345 std::back_inserter(coords));
352 Coord_type res = CGAL::linear_interpolation(coords.begin(), coords.end(),
353 nn.second, Value_access(fNormalizedPoints, fZ));
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
int fNpoints
! Number of data points
double fXNmin
! Minimum value of fXN
std::set< unsigned int > fCells[(fNCells+1) *(fNCells+1)]
! grid cells with containing triangles
int fNdt
! Number of Delaunay triangles found
double DoInterpolateNormalized(double x, double y)
internal method to compute the interpolation
int CellY(double y) const
double Interpolate(double x, double y)
Return the Interpolated z value corresponding to the given (x,y) point.
const double * fZ
! Pointer to Z array
double fXNmax
! Maximum value of fXN
double fZout
! Height for points lying outside the convex hull
double fOffsetY
! Normalization offset Y
Triangles fTriangles
! Triangles of Triangulation
double Linear_transform(double x, double offset, double factor)
double fYCellStep
! inverse denominator to calculate X cell = fNCells / (fYNmax - fYNmin)
std::vector< double > fYN
! normalized Y
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
void FindAllTriangles()
Find all triangles.
static const int fNCells
! number of cells to divide the normalized space
bool fInit
! True if FindAllTriangles() has been performed
unsigned int Cell(unsigned int x, unsigned int y) const
std::vector< double > fXN
! normalized X
double fXCellStep
! inverse denominator to calculate X cell = fNCells / (fXNmax - fXNmin)
double fYNmin
! Minimum value of fYN
double fOffsetX
! Normalization offset X
const double * fY
! Pointer to Y array
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
const double * fX
! Pointer to X array (managed externally)
void DoNormalizePoints()
internal function to normalize the points.
double fYNmax
! Maximum value of fYN
int NumberOfTriangles() const
return the number of triangles
double fScaleFactorY
! Normalization factor Y
double fScaleFactorX
! Normalization factor X
void DoFindTriangles()
internal function to find the triangle use Triangle or CGAL if flag is set
int CellX(double x) const
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...