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
HDF5Mesh2DSource Class Reference

#include <swmm2dresultslayer.h>

Inheritance diagram for HDF5Mesh2DSource:
Collaboration diagram for HDF5Mesh2DSource:

Public Member Functions

 HDF5Mesh2DSource ()
 
 ~HDF5Mesh2DSource () override
 
bool open (const QString &path)
 
const QString & path () const noexcept
 
int vertexCount () const override
 Geometry counts. Stable for the lifetime of the source.
 
int triangleCount () const override
 
int timeCount () const override
 Latest known time-step count (grows during live mode).
 
bool readMeshGeometry (std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz, std::vector< std::array< int, 3 > > &tris) override
 Fetch mesh geometry as a DISPLAY triangle fan. Resizes outputs.
 
bool readCells (std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz, std::vector< std::array< int, 4 > > &cells) override
 Fetch mesh geometry as CELLS: cells[i] = {v0,v1,v2,v3} with v3 == -1 for a triangle (cyclic order for a quad), one entry per face, engine order (triangles first, then quads). Resizes outputs.
 
bool readDepthsAt (int timeIdx, std::vector< float > &depths) override
 Fetch per-triangle depth at timeIdx. Resizes depths to triangleCount().
 
QDateTime simTimeAt (int timeIdx) const override
 Wall-clock sim time at timeIdx (invalid if out of range or unknown).
 
bool readEdgeFluxAt (int timeIdx, std::vector< float > &flux) override
 Fetch per-edge signed normal flux at timeIdx.
 
bool readEdgeGeometry (std::vector< float > &length, std::vector< float > &nx, std::vector< float > &ny) override
 Fetch time-invariant edge geometry (length + outward unit normal).
 
bool readVertexDepthsAt (int timeIdx, std::vector< float > &vdepths) override
 Fetch per-vertex SIGNED water depth (m) at timeIdx — the engine's wet-masked, depth-weighted render reconstruction η_v − z_v (Mesh2_node_depth / swmm_2d_vertex_get_render_depths_bulk). NOT clamped: negative values over the dry side of partially wet cells carry the sub-cell shoreline intercept; exactly 0 where no incident cell is wet. Dry-cell bed elevations never contribute (unlike the legacy Mesh2_node_head solver field, which is deliberately NOT consumed here — blending dry-cell beds lifted the rendered surface up adverse slopes/steps). Resized to vertexCount().
 
bool hasFaceField (const char *dataset) const override
 Whether the source carries a named per-face [nTime, nFace] field beyond depth (e.g. "Mesh2_face_rainfall", "Mesh2_face_rain_cum"). Default: none — the live in-process source streams depth/flux only.
 
bool readFaceFieldAt (const char *dataset, int timeIdx, std::vector< float > &values) override
 Fetch one time slice of a named per-face field (engine SI units). Resized to triangleCount(). Default returns false.
 
bool readFaceEnvelope (const char *dataset, std::vector< float > &values) override
 Fetch a time-INVARIANT per-face [nFace] envelope written by the engine's ENVELOPES output group ("Mesh2_face_max_depth", "Mesh2_face_max_velocity"): the whole-run maximum per cell, engine SI units, resized to triangleCount().
 
openswmmvis::io::CoordinateReference coordinateReference () const override
 How the coordinates from readMeshGeometry relate to the model CRS — see openswmmvis::io::CoordinateReference.
 
void setSimulationStart (QDateTime t)
 Anchor wall-clock time for the simulation start (so /time (seconds since start) maps back to a QDateTime for the global slider).
 
- Public Member Functions inherited from IMesh2DSource
virtual ~IMesh2DSource ()=default
 
virtual bool isLive () const
 True while this source is streaming from a running simulation (frames keep arriving). The animation must NOT auto-advance to the newest frame for a live source — the user drives playback via the slider / Play. A completed file source returns false.
 
virtual bool readDepthAt (int timeIdx, int cell, float &out)
 One cell's depth at timeIdx. The default copies the whole frame through readDepthsAt; a source holding frames in memory overrides it in O(1) so per-cell time series (comparison plots) do not copy every frame per point.
 
virtual int historyGeneration () const
 Bumps whenever frames are removed or reordered (a live source thinning its history), invalidating anything cached per frame index. Appends do not bump it.
 

Constructor & Destructor Documentation

◆ HDF5Mesh2DSource()

HDF5Mesh2DSource::HDF5Mesh2DSource ( )

◆ ~HDF5Mesh2DSource()

HDF5Mesh2DSource::~HDF5Mesh2DSource ( )
overridedefault

Member Function Documentation

◆ coordinateReference()

openswmmvis::io::CoordinateReference HDF5Mesh2DSource::coordinateReference ( ) const
overridevirtual

How the coordinates from readMeshGeometry relate to the model CRS — see openswmmvis::io::CoordinateReference.

Every source delivers SI metres (the 2D solver's internal unit), which for a foot-based model CRS is NOT the unit the coordinates must be reprojected from. The default returns an undeclared reference, so a source that cannot state the factor makes the layer fall back to the layer CRS's own linear unit rather than silently assuming 1.0.

Reimplemented from IMesh2DSource.

◆ hasFaceField()

bool HDF5Mesh2DSource::hasFaceField ( const char *  dataset) const
overridevirtual

Whether the source carries a named per-face [nTime, nFace] field beyond depth (e.g. "Mesh2_face_rainfall", "Mesh2_face_rain_cum"). Default: none — the live in-process source streams depth/flux only.

Reimplemented from IMesh2DSource.

◆ open()

bool HDF5Mesh2DSource::open ( const QString &  path)
Here is the call graph for this function:

◆ path()

const QString & HDF5Mesh2DSource::path ( ) const
inlinenoexcept
Here is the caller graph for this function:

◆ readCells()

bool HDF5Mesh2DSource::readCells ( std::vector< double > &  vx,
std::vector< double > &  vy,
std::vector< double > &  vz,
std::vector< std::array< int, 4 > > &  cells 
)
overridevirtual

Fetch mesh geometry as CELLS: cells[i] = {v0,v1,v2,v3} with v3 == -1 for a triangle (cyclic order for a quad), one entry per face, engine order (triangles first, then quads). Resizes outputs.

Default: an all-triangle source — readMeshGeometry's triangles ARE the cells, so they are wrapped with v3 = -1. Mixed-mesh sources override.

Reimplemented from IMesh2DSource.

◆ readDepthsAt()

bool HDF5Mesh2DSource::readDepthsAt ( int  timeIdx,
std::vector< float > &  depths 
)
overridevirtual

Fetch per-triangle depth at timeIdx. Resizes depths to triangleCount().

Implements IMesh2DSource.

◆ readEdgeFluxAt()

bool HDF5Mesh2DSource::readEdgeFluxAt ( int  timeIdx,
std::vector< float > &  flux 
)
overridevirtual

Fetch per-edge signed normal flux at timeIdx.

Parameters
fluxResized to mesh::edgeSlotCount(triangleCount()), indexed mesh::edgeSlot(cell, localEdge) (stride mesh::kEdgeStride; slot 3 of a triangle is padding). Units m² s⁻¹; positive flows outward through the edge's outward normal.
Returns
true on success. Default implementation returns false so callers can probe whether the source supports flux data without an error.

Reimplemented from IMesh2DSource.

◆ readEdgeGeometry()

bool HDF5Mesh2DSource::readEdgeGeometry ( std::vector< float > &  length,
std::vector< float > &  nx,
std::vector< float > &  ny 
)
overridevirtual

Fetch time-invariant edge geometry (length + outward unit normal).

Parameters
lengthResized to mesh::edgeSlotCount(triangleCount()) (m).
nx,nyResized likewise (dimensionless); indexed mesh::edgeSlot.
Returns
true on success. Default returns false.

Reimplemented from IMesh2DSource.

◆ readFaceEnvelope()

bool HDF5Mesh2DSource::readFaceEnvelope ( const char *  dataset,
std::vector< float > &  values 
)
overridevirtual

Fetch a time-INVARIANT per-face [nFace] envelope written by the engine's ENVELOPES output group ("Mesh2_face_max_depth", "Mesh2_face_max_velocity"): the whole-run maximum per cell, engine SI units, resized to triangleCount().

Returns
true on success. Default false — a source that cannot serve the envelope makes the caller scan every frame instead.

Reimplemented from IMesh2DSource.

◆ readFaceFieldAt()

bool HDF5Mesh2DSource::readFaceFieldAt ( const char *  dataset,
int  timeIdx,
std::vector< float > &  values 
)
overridevirtual

Fetch one time slice of a named per-face field (engine SI units). Resized to triangleCount(). Default returns false.

Reimplemented from IMesh2DSource.

◆ readMeshGeometry()

bool HDF5Mesh2DSource::readMeshGeometry ( std::vector< double > &  vx,
std::vector< double > &  vy,
std::vector< double > &  vz,
std::vector< std::array< int, 3 > > &  tris 
)
overridevirtual

Fetch mesh geometry as a DISPLAY triangle fan. Resizes outputs.

tris carries one triangle per triangle cell and two per quad (the engine's VFR sub-triangle split, mesh::cellGeom), in cell order — so tris.size() >= triangleCount(). Consumers that need per-cell values must use readCells and map fan triangles back to their cell.

Implements IMesh2DSource.

◆ readVertexDepthsAt()

bool HDF5Mesh2DSource::readVertexDepthsAt ( int  timeIdx,
std::vector< float > &  vdepths 
)
overridevirtual

Fetch per-vertex SIGNED water depth (m) at timeIdx — the engine's wet-masked, depth-weighted render reconstruction η_v − z_v (Mesh2_node_depth / swmm_2d_vertex_get_render_depths_bulk). NOT clamped: negative values over the dry side of partially wet cells carry the sub-cell shoreline intercept; exactly 0 where no incident cell is wet. Dry-cell bed elevations never contribute (unlike the legacy Mesh2_node_head solver field, which is deliberately NOT consumed here — blending dry-cell beds lifted the rendered surface up adverse slopes/steps). Resized to vertexCount().

Returns
true on success. Default returns false so callers can probe whether the source carries the signed field (older engines / older HDF5 files) and fall back to the GUI-side wet-only reconstruction.

Reimplemented from IMesh2DSource.

◆ setSimulationStart()

void HDF5Mesh2DSource::setSimulationStart ( QDateTime  t)
inline

Anchor wall-clock time for the simulation start (so /time (seconds since start) maps back to a QDateTime for the global slider).

◆ simTimeAt()

QDateTime HDF5Mesh2DSource::simTimeAt ( int  timeIdx) const
overridevirtual

Wall-clock sim time at timeIdx (invalid if out of range or unknown).

Reimplemented from IMesh2DSource.

Here is the call graph for this function:

◆ timeCount()

int HDF5Mesh2DSource::timeCount ( ) const
overridevirtual

Latest known time-step count (grows during live mode).

Implements IMesh2DSource.

◆ triangleCount()

int HDF5Mesh2DSource::triangleCount ( ) const
overridevirtual

Implements IMesh2DSource.

◆ vertexCount()

int HDF5Mesh2DSource::vertexCount ( ) const
overridevirtual

Geometry counts. Stable for the lifetime of the source.

triangleCount() is the number of CELLS (engine faces — triangles and, on a mixed mesh, quads; workplans/TRI_QUAD_MESHING_PLAN_2026-09-06.md). Every per-face array (readDepthsAt, readFaceFieldAt) is sized to it; the historical name is kept for its callers.

Implements IMesh2DSource.


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