SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
naturalnbinterpolator.h
Go to the documentation of this file.
1
33#ifndef OPENSWMMVIS_MESH_NATURALNBINTERPOLATOR_H
34#define OPENSWMMVIS_MESH_NATURALNBINTERPOLATOR_H
35
36#include <QPair>
37#include <QPointF>
38#include <QString>
39#include <QVector>
40
41#include <utility>
42#include <vector>
43
44namespace mesh {
45
47{
48public:
49 enum class Variant { Sibson, Laplace };
50
52
53 void setVariant(Variant v) { m_variant = v; }
54 Variant variant() const { return m_variant; }
55
60 bool build(const QVector<QPointF> &pts, const QVector<double> &z, QString *err);
61
64 bool build(const QVector<QPointF> &pts, QString *err);
65
66 bool isValid() const { return m_valid; }
67
71 double interpolate(double x, double y) const;
72
89 bool weightsAt(double x, double y, QVector<QPair<int, double>> &out) const;
90
95 const std::vector<int> &keptSeedIndices() const { return m_seedOf; }
96
97private:
104 bool computeWeights(double qx, double qy,
105 std::vector<std::pair<int, double>> &out) const;
106
107 // Coordinates are normalised to a local [0,~1] space: translated by
108 // (-m_ox, -m_oy) (the seed bbox minimum) then divided by m_scale (the
109 // larger bbox side). This keeps orientation / in-circle / circumcenter
110 // determinants well-conditioned at projected-CRS magnitudes. z, and the
111 // Sibson (area-ratio) / Laplace (length-ratio) weights, are invariant
112 // under this affine map.
113 int locate(double qx, double qy) const; // returns triangle index or -1 (outside hull)
114
115 Variant m_variant = Variant::Sibson;
116 bool m_valid = false;
117
118 double m_ox = 0.0, m_oy = 0.0; // local-origin translation
119 double m_scale = 1.0; // normalisation scale (max bbox side)
120
121 std::vector<double> m_px, m_py, m_pz; // per Delaunay vertex (translated x,y; raw z)
122 std::vector<int> m_seedOf; // Delaunay vertex -> original input index
123 std::vector<int> m_tris; // 3 * numTri vertex indices (CCW)
124 std::vector<int> m_nbrs; // 3 * numTri neighbour tri indices (-1 = hull)
125 std::vector<double> m_ccx, m_ccy; // circumcenter per triangle (NaN if degenerate)
126 int m_numTri = 0;
127
128 mutable int m_lastTri = 0; // jump-and-walk start hint
129};
130
131} // namespace mesh
132
133#endif // OPENSWMMVIS_MESH_NATURALNBINTERPOLATOR_H
Definition naturalnbinterpolator.h:47
Variant variant() const
Definition naturalnbinterpolator.h:54
bool build(const QVector< QPointF > &pts, const QVector< double > &z, QString *err)
Triangulate the seed set. Snap-dedupes coincident points, requires >= 3 unique non-collinear points....
Definition naturalnbinterpolator.cpp:73
double interpolate(double x, double y) const
Interpolate z at (x, y). Returns NaN when the point is outside the seed convex hull or the local inse...
Definition naturalnbinterpolator.cpp:375
void setVariant(Variant v)
Definition naturalnbinterpolator.h:53
const std::vector< int > & keptSeedIndices() const
Original indices of the seeds that survived snap-dedupe, in Delaunay-vertex order....
Definition naturalnbinterpolator.h:95
bool weightsAt(double x, double y, QVector< QPair< int, double > > &out) const
Natural-neighbour weights at (x, y), keyed by ORIGINAL seed index.
Definition naturalnbinterpolator.cpp:396
bool isValid() const
Definition naturalnbinterpolator.h:66
Variant
Definition naturalnbinterpolator.h:49
QString err
Definition inpmeshwriter.cpp:575
QVector< QPointF > pts
Definition meshpatch.cpp:62
Definition meshcommands.h:302
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159