Natural-neighbour (Sibson or Laplace) interpolator over scattered (x, y, z) seeds. More...
#include <mesh/naturalnbinterpolator.h>
Public Types | |
| enum class | Variant { Sibson , Laplace } |
| Natural-neighbour coordinate construction used by interpolate() and weightsAt(): Sibson (default) uses area-stealing coordinates, Laplace uses Voronoi facet length divided by the distance to the seed. More... | |
Public Member Functions | |
| NaturalNeighbourInterpolator ()=default | |
| Construct an invalid empty interpolator using the Sibson variant. | |
| void | setVariant (Variant v) |
| Select which natural-neighbor weight construction later queries use. | |
| Variant | variant () const |
| Read the currently stored interpolation variant. | |
| bool | build (const QVector< QPointF > &pts, const QVector< double > &z, QString *err) |
| Replace interpolation geometry with a snap-deduplicated normalized Delaunay seed set. | |
| bool | build (const QVector< QPointF > &pts, QString *err) |
| Build the same triangulation for weight-only queries using zero scalar values. | |
| bool | isValid () const |
| Read whether the latest full build completed successfully. | |
| double | interpolate (double x, double y) const |
| Interpolate one scalar through the chosen normalized natural-neighbor weight scheme. | |
| bool | weightsAt (double x, double y, QVector< QPair< int, double > > &out) const |
| Return normalized natural-neighbor weights keyed by original retained input indices. | |
| const std::vector< int > & | keptSeedIndices () const |
| Borrow the original input-index mapping in internal Delaunay-vertex order. | |
Natural-neighbour (Sibson or Laplace) interpolator over scattered (x, y, z) seeds.
build() copies and triangulates the seeds; interpolate() and weightsAt() then answer queries inside the seeds' convex hull and return NaN / false elsewhere. The instance owns all its storage. Queries mutate internal caches, so one instance must not be queried from several threads at once (see the file comment).
|
strong |
Natural-neighbour coordinate construction used by interpolate() and weightsAt(): Sibson (default) uses area-stealing coordinates, Laplace uses Voronoi facet length divided by the distance to the seed.
| Enumerator | |
|---|---|
| Sibson | Area-stealing (Sibson) coordinates; the default. |
| Laplace | Voronoi facet length divided by the distance to the seed. |
|
default |
Construct an invalid empty interpolator using the Sibson variant.
| bool mesh::NaturalNeighbourInterpolator::build | ( | const QVector< QPointF > & | pts, |
| const QVector< double > & | z, | ||
| QString * | err ) |
Replace interpolation geometry with a snap-deduplicated normalized Delaunay seed set.
| [in] | pts | Borrowed planar seed coordinates in common CRS/units, unchanged; count must match z. Finite x/y times 1e7 must fit qint64 for unchecked qRound64 snap keys, and counts must fit int. |
| [in] | z | Borrowed scalar values in a consistent application-defined unit, unchanged; nonfinite coordinate/value seeds are skipped. First finite occurrence of each 1e-7 quantized xy key is retained. |
| [out] | err | Optional borrowed diagnostic, overwritten only on checked failure, not cleared on success. |
Triangulate the seed set. Snap-dedupes coincident points, requires >= 3 unique non-collinear points. Returns false (and sets *err when non-null) when interpolation is unavailable — the caller should then fall back to IDW entirely.
| bool mesh::NaturalNeighbourInterpolator::build | ( | const QVector< QPointF > & | pts, |
| QString * | err ) |
Build the same triangulation for weight-only queries using zero scalar values.
| [in] | pts | Borrowed seeds in common planar CRS/units, unchanged; all full-build coordinate/count preconditions apply, including representable 1e7 snap-key scaling. |
| [out] | err | Optional borrowed error string, overwritten on checked failure, unchanged on success. |
Triangulate seeds for weight queries only (weightsAt), with no associated values. Equivalent to build() with a zero z vector.
| double mesh::NaturalNeighbourInterpolator::interpolate | ( | double | x, |
| double | y ) const |
Interpolate one scalar through the chosen normalized natural-neighbor weight scheme.
| [in] | x | Finite query x in the original seed planar CRS/units, unchanged; normalized arithmetic and weighted sums must remain representable for meaningful results. |
| [in] | y | Finite query y in the same original coordinate system, unchanged. |
Interpolate z at (x, y). Returns NaN when the point is outside the seed convex hull or the local insertion is degenerate — the caller falls back to IDW for that vertex.
|
inline |
Read whether the latest full build completed successfully.
|
inline |
Borrow the original input-index mapping in internal Delaunay-vertex order.
Original indices of the seeds that survived snap-dedupe, in Delaunay-vertex order. Coincident inputs collapse to the first occurrence, so a caller can diff this against its input to learn which seeds were dropped and will never carry weight.
|
inline |
Select which natural-neighbor weight construction later queries use.
| [in] | v | Variant, normally Sibson or Laplace; implementation treats other enum values as Sibson. |
|
inline |
Read the currently stored interpolation variant.
| bool mesh::NaturalNeighbourInterpolator::weightsAt | ( | double | x, |
| double | y, | ||
| QVector< QPair< int, double > > & | out ) const |
Return normalized natural-neighbor weights keyed by original retained input indices.
| [in] | x | Finite original-seed-CRS x query coordinate, unchanged. |
| [in] | y | Finite original-seed-CRS y query coordinate, unchanged; normalized geometry/sums must be representable. |
| [out] | out | Borrowed destination, cleared at entry and empty on checked failure. Success fills owned (index,dimensionless weight) pairs sorted ascending by original seed index; dropped seeds are absent. |
Natural-neighbour weights at (x, y), keyed by ORIGINAL seed index.
Same scheme interpolate() uses; this exposes the coordinates themselves so a caller can blend something other than a scalar z (e.g. whole rainfall time series). Weights are normalised to sum 1 and returned SORTED ASCENDING BY INDEX — the order is contractual, because the underlying accumulation walks a QHash whose iteration order is randomised per process, and callers that hash these weights need reproducibility.