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
GageAssignment Namespace Reference

Classes

struct  ClusterKey
 A canonical, integer-valued summary of one weight vector. More...
 

Functions

QVector< QPointF > clipHalfPlane (const QVector< QPointF > &ring, const QPointF &keep, const QPointF &drop)
 Clip an open ring by the half-plane of points at least as close to keep as to drop.
 
QVector< doublethiessenAreaShares (const QVector< QPointF > &ring, const QVector< QPointF > &gages)
 Area of ring intersected with each gage's Voronoi cell.
 
int areaMajorityGage (const QVector< double > &shares, double *fractionOut=nullptr)
 Index of the largest share, ties broken toward the lowest index.
 
QVector< QPointF > samplePolygon (const QVector< QPointF > &ring, int target=kDefaultSampleTarget)
 Interior sample points for area-averaging a field over a ring.
 
QVector< QPair< int, double > > idwWeights (const QPointF &p, const QVector< QPointF > &sites)
 Inverse-distance weights (power 2), normalised to sum 1.
 
ClusterKey quantizeWeights (const QVector< double > &w, double tol=kDefaultClusterTol, double wEps=kWeightEpsilon)
 Quantise a dense weight vector into a canonical cluster key.
 
QVector< doubledequantizeWeights (const ClusterKey &key, double tol, int nGages)
 Dense weights implied by a key — the blend actually synthesised.
 

Variables

constexpr double kWeightEpsilon = 1e-4
 Weights below this magnitude are clamped to zero before clustering.
 
constexpr double kDefaultClusterTol = 0.01
 Default weight-agreement tolerance for clustering (1%).
 
constexpr int kDefaultSampleTarget = 200
 Default number of interior samples requested per ring.
 

Function Documentation

◆ areaMajorityGage()

int GageAssignment::areaMajorityGage ( const QVector< double > &  shares,
double fractionOut = nullptr 
)

Index of the largest share, ties broken toward the lowest index.

Parameters
sharesAs returned by thiessenAreaShares().
fractionOutWhen non-null, receives the winner's share of the total.
Returns
The winning index, or -1 when every share is zero.

◆ clipHalfPlane()

QVector< QPointF > GageAssignment::clipHalfPlane ( const QVector< QPointF > &  ring,
const QPointF &  keep,
const QPointF &  drop 
)

Clip an open ring by the half-plane of points at least as close to keep as to drop.

Sutherland–Hodgman against the perpendicular bisector of the two sites. Clipping a CONCAVE ring this way yields coincident zero-width edges rather than separate pieces, but their contribution to the shoelace sum is exactly zero — so the AREA of the result is exact even though the ring itself may be degenerate. Only ever consume the area of the output, never its outline.

Returns
The clipped open ring; empty when nothing survives.
Here is the caller graph for this function:

◆ dequantizeWeights()

QVector< double > GageAssignment::dequantizeWeights ( const ClusterKey key,
double  tol,
int  nGages 
)

Dense weights implied by a key — the blend actually synthesised.

Recovering the weights from the key rather than from any one member's floats is what makes a cluster's generated series a pure function of its key, and therefore reproducible.

Parameters
keyAs returned by quantizeWeights().
tolThe same tolerance passed to quantizeWeights().
nGagesLength of the returned vector.

◆ idwWeights()

QVector< QPair< int, double > > GageAssignment::idwWeights ( const QPointF &  p,
const QVector< QPointF > &  sites 
)

Inverse-distance weights (power 2), normalised to sum 1.

The fallback for query points outside the natural-neighbour hull. Matches the engine's own convention in RainfallInterpolator so the GUI and the 2D solver agree. A query coincident with a site returns weight 1 on that site alone.

Returns
(site index, weight) pairs sorted ascending by index — sorted order is required, since cluster keys are built from these and must not depend on hash iteration order. Empty when sites is empty.

◆ quantizeWeights()

ClusterKey GageAssignment::quantizeWeights ( const QVector< double > &  w,
double  tol = kDefaultClusterTol,
double  wEps = kWeightEpsilon 
)

Quantise a dense weight vector into a canonical cluster key.

Clamps sub-wEps entries to zero, renormalises, rounds each weight to a multiple of tol, then pushes the rounding residual onto the largest term (ties toward the lowest index) so every key sums to the same constant. The result depends only on the weights, never on iteration order.

Parameters
wDense weights indexed by gage. Need not sum to 1.
tolAgreement tolerance; must be > 0.
wEpsZero-clamp threshold.
Returns
The key; empty when w has no positive entry.

◆ samplePolygon()

QVector< QPointF > GageAssignment::samplePolygon ( const QVector< QPointF > &  ring,
int  target = kDefaultSampleTarget 
)

Interior sample points for area-averaging a field over a ring.

Lays a square lattice of pitch sqrt(area / target) offset by half a pitch and keeps the points that pass an even-odd interior test. The lattice is coarsened when a thin sliver would otherwise generate an unbounded candidate count. Falls back to EditGeometry::interiorPoint when the lattice catches nothing, so the result is never empty for a ring of three or more vertices.

Parameters
ringOpen ring.
targetDesired sample count, clamped to [50, 2000].
Returns
Interior points, or an empty vector when ring has < 3 vertices.
Here is the call graph for this function:

◆ thiessenAreaShares()

QVector< double > GageAssignment::thiessenAreaShares ( const QVector< QPointF > &  ring,
const QVector< QPointF > &  gages 
)

Area of ring intersected with each gage's Voronoi cell.

Parameters
ringOpen subcatchment ring.
gagesGage positions, in the same CRS as ring. Index-aligned with the returned vector.
Returns
One area per gage, in the squared units of the input coordinates. All zero when the ring is degenerate or gages is empty. The sum equals the ring area (up to rounding) because Voronoi cells tile the plane.
Here is the call graph for this function:

Variable Documentation

◆ kDefaultClusterTol

constexpr double GageAssignment::kDefaultClusterTol = 0.01
constexpr

Default weight-agreement tolerance for clustering (1%).

◆ kDefaultSampleTarget

constexpr int GageAssignment::kDefaultSampleTarget = 200
constexpr

Default number of interior samples requested per ring.

◆ kWeightEpsilon

constexpr double GageAssignment::kWeightEpsilon = 1e-4
constexpr

Weights below this magnitude are clamped to zero before clustering.

Natural-neighbour and inverse-distance weighting both produce long microscopic tails. Left in place they fragment clusters without moving blended depth measurably — 1e-4 shifts it by under 0.01%.