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
mesh::DTMThinner Class Reference

Terrain-adaptive Steiner point selector from a DTM raster. More...

#include <dtmthinner.h>

Collaboration diagram for mesh::DTMThinner:

Public Member Functions

 DTMThinner ()
 
 ~DTMThinner ()
 
 DTMThinner (const DTMThinner &)=delete
 
DTMThinneroperator= (const DTMThinner &)=delete
 
bool open (const QString &filePath, int band=1)
 
void close ()
 
bool isOpen () const noexcept
 
QVector< QPointF > generatePoints (const MapExtent &domain, const DTMThinnerOptions &opts={}, QVector< double > *outZ=nullptr, const DTMProgressFn &progress={}, const DTMThinnerLimits &limits={}) const
 Generate terrain-significant sample points within domain.
 
double pixelSize () const
 
QString crsWkt () const
 
QString errorMsg () const
 
double sampleAt (double x, double y) const
 Sample the DTM at a single map-CRS coordinate. Returns NaN when out-of-bounds or NoData.
 
void sampleMany (const QVector< QPointF > &xy, QVector< double > *outZ, qint64 maxBufBytes=kMaxReadBufBytesDefault) const
 Batch bilinear sampling at many DTM-CRS coordinates.
 
void readPixels (const MapExtent &bbox, QVector< QPointF > &xyOut, QVector< double > &zOut) const
 Read every valid raster pixel whose centre falls within bbox.
 

Static Public Attributes

static constexpr qint64 kMaxReadBufBytesDefault = qint64(256) * 1024 * 1024
 
static constexpr qint64 kMaxGridBytesDefault = qint64(2048) * 1024 * 1024
 
static constexpr qint64 kMaxRetainedPointsDefault = 64ll * 1024 * 1024
 
static constexpr int kMaxThinningHalo = 64
 

Detailed Description

Terrain-adaptive Steiner point selector from a DTM raster.

Usage:

QVector<double> z;
if (thinner.open(dtmPath)) {
const auto pts = thinner.generatePoints(domain, opts, &z);
for (int i = 0; i < pts.size(); ++i) {
sp.xy = pts[i]; sp.z = z[i]; sp.hasZ = true;
gen.addSteinerPoint(sp);
}
}
Terrain-adaptive Steiner point selector from a DTM raster.
Definition dtmthinner.h:132
bool open(const QString &filePath, int band=1)
Definition dtmthinner.cpp:319
QVector< QPointF > generatePoints(const MapExtent &domain, const DTMThinnerOptions &opts={}, QVector< double > *outZ=nullptr, const DTMProgressFn &progress={}, const DTMThinnerLimits &limits={}) const
Generate terrain-significant sample points within domain.
Definition dtmthinner.cpp:693
size_t i
Definition contourjob.cpp:27
QVector< QPointF > pts
Definition meshpatch.cpp:62
A point that must appear as a vertex in the output mesh.
Definition meshgenerator.h:46
bool hasZ
If true, z is exact — skip DTM re-sampling in post-mesh step.
Definition meshgenerator.h:51
QPointF xy
Definition meshgenerator.h:47
double z
Pre-sampled elevation when hasZ is true (e.g. from DTM thinner).
Definition meshgenerator.h:50

Constructor & Destructor Documentation

◆ DTMThinner() [1/2]

mesh::DTMThinner::DTMThinner ( )

◆ ~DTMThinner()

mesh::DTMThinner::~DTMThinner ( )
Here is the call graph for this function:

◆ DTMThinner() [2/2]

mesh::DTMThinner::DTMThinner ( const DTMThinner )
delete

Member Function Documentation

◆ close()

void mesh::DTMThinner::close ( )
Here is the caller graph for this function:

◆ crsWkt()

QString mesh::DTMThinner::crsWkt ( ) const

◆ errorMsg()

QString mesh::DTMThinner::errorMsg ( ) const
inline

◆ generatePoints()

QVector< QPointF > mesh::DTMThinner::generatePoints ( const MapExtent domain,
const DTMThinnerOptions opts = {},
QVector< double > *  outZ = nullptr,
const DTMProgressFn progress = {},
const DTMThinnerLimits limits = {} 
) const

Generate terrain-significant sample points within domain.

Grids that exceed limits.maxGridBytes are processed in row bands with a halo (see file header "Scaling notes") — output is bit-identical to the untiled run for pass counts ≤ kMaxThinningHalo.

Parameters
domainMeshing extent (same CRS as the DTM raster).
optsThinning parameters.
outZIf non-null, filled with the exact DEM elevation for each returned point (parallel array). These values should be used directly — do NOT re-sample them from the DTM later.
progressOptional progress/cancel callback (see DTMProgressFn).
limitsResource ceilings — defaults are production values; exposed for tests.
Returns
(x, y) coordinates of retained terrain-feature vertices.
Here is the call graph for this function:

◆ isOpen()

bool mesh::DTMThinner::isOpen ( ) const
noexcept

◆ open()

bool mesh::DTMThinner::open ( const QString &  filePath,
int  band = 1 
)
Here is the call graph for this function:

◆ operator=()

DTMThinner & mesh::DTMThinner::operator= ( const DTMThinner )
delete

◆ pixelSize()

double mesh::DTMThinner::pixelSize ( ) const
Here is the caller graph for this function:

◆ readPixels()

void mesh::DTMThinner::readPixels ( const MapExtent bbox,
QVector< QPointF > &  xyOut,
QVector< double > &  zOut 
) const

Read every valid raster pixel whose centre falls within bbox.

Issues a single bulk RasterIO call for the entire bounding box — far faster than calling sampleAt() per pixel. Pixel centres are reported in the raster's native map CRS (same as sampleAt()).

The caller is responsible for transforming the returned (x,y) to the mesh CRS if the two CRSs differ.

Regions whose output points would exceed the same ~2 GB working-set ceiling used by generatePoints() are refused up front: nothing is appended and the reason lands in errorMsg(). (A full-DEM bbox on a multi-GB raster would otherwise demand tens of GB and die at the Windows commit limit as an uncatchable-looking bad_alloc.)

Parameters
bboxAxis-aligned bounding box in the raster's own CRS.
xyOutPixel-centre map coordinates (DTM CRS) — appended.
zOutCorresponding elevation values — appended (parallel).

◆ sampleAt()

double mesh::DTMThinner::sampleAt ( double  x,
double  y 
) const

Sample the DTM at a single map-CRS coordinate. Returns NaN when out-of-bounds or NoData.

◆ sampleMany()

void mesh::DTMThinner::sampleMany ( const QVector< QPointF > &  xy,
QVector< double > *  outZ,
qint64  maxBufBytes = kMaxReadBufBytesDefault 
) const

Batch bilinear sampling at many DTM-CRS coordinates.

outZ is resized to xy.size(); each entry equals what sampleAt() would return for that point (NaN when out-of-range, NoData in the 2×2 window, or on read failure). Queries are binned into raster row-strips sized to maxBufBytes and each strip is read with ONE RasterIO call (with a 1-row overlap so bilinear windows spanning a strip boundary resolve), instead of one RasterIO per point. Results are bit-identical to per-point sampleAt(). maxBufBytes is exposed for tests.

Member Data Documentation

◆ kMaxGridBytesDefault

constexpr qint64 mesh::DTMThinner::kMaxGridBytesDefault = qint64(2048) * 1024 * 1024
staticconstexpr

Per-band grid working-set ceiling (~46 bytes per grid point).

◆ kMaxReadBufBytesDefault

constexpr qint64 mesh::DTMThinner::kMaxReadBufBytesDefault = qint64(256) * 1024 * 1024
staticconstexpr

Raster scratch-buffer ceiling shared by the banded readers.

◆ kMaxRetainedPointsDefault

constexpr qint64 mesh::DTMThinner::kMaxRetainedPointsDefault = 64ll * 1024 * 1024
staticconstexpr

Total retained-points ceiling across all bands (~64 M points).

◆ kMaxThinningHalo

constexpr int mesh::DTMThinner::kMaxThinningHalo = 64
staticconstexpr

Maximum halo width — and therefore the per-band pass cap — in multi-band mode. "(unlimited)" passes are truncated to this.


The documentation for this class was generated from the following files: