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
IMesh2DSource Class Referenceabstract

Abstract source of mesh geometry + per-triangle depth time series. More...

#include <swmm2dresultslayer.h>

Inheritance diagram for IMesh2DSource:
Collaboration diagram for IMesh2DSource:

Public Member Functions

virtual ~IMesh2DSource ()=default
 
virtual int vertexCount () const =0
 Geometry counts. Stable for the lifetime of the source.
 
virtual int triangleCount () const =0
 
virtual int timeCount () const =0
 Latest known time-step count (grows during live mode).
 
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 readMeshGeometry (std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz, std::vector< std::array< int, 3 > > &tris)=0
 Fetch mesh geometry as a DISPLAY triangle fan. Resizes outputs.
 
virtual bool readCells (std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz, std::vector< std::array< int, 4 > > &cells)
 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.
 
virtual openswmmvis::io::CoordinateReference coordinateReference () const
 How the coordinates from readMeshGeometry relate to the model CRS — see openswmmvis::io::CoordinateReference.
 
virtual bool readDepthsAt (int timeIdx, std::vector< float > &depths)=0
 Fetch per-triangle depth at timeIdx. Resizes depths to triangleCount().
 
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.
 
virtual QDateTime simTimeAt (int timeIdx) const
 Wall-clock sim time at timeIdx (invalid if out of range or unknown).
 
virtual bool readEdgeFluxAt (int timeIdx, std::vector< float > &flux)
 Fetch per-edge signed normal flux at timeIdx.
 
virtual bool readEdgeGeometry (std::vector< float > &length, std::vector< float > &nx, std::vector< float > &ny)
 Fetch time-invariant edge geometry (length + outward unit normal).
 
virtual bool readVertexDepthsAt (int timeIdx, std::vector< float > &vdepths)
 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().
 
virtual bool hasFaceField (const char *dataset) const
 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.
 
virtual bool readFaceFieldAt (const char *dataset, int timeIdx, std::vector< float > &values)
 Fetch one time slice of a named per-face field (engine SI units). Resized to triangleCount(). Default returns false.
 
virtual bool readFaceEnvelope (const char *dataset, std::vector< float > &values)
 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().
 

Detailed Description

Abstract source of mesh geometry + per-triangle depth time series.

Two concrete implementations live in this header/.cpp pair:

Constructor & Destructor Documentation

◆ ~IMesh2DSource()

virtual IMesh2DSource::~IMesh2DSource ( )
virtualdefault

Member Function Documentation

◆ coordinateReference()

virtual openswmmvis::io::CoordinateReference IMesh2DSource::coordinateReference ( ) const
inlinevirtual

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 in HDF5Mesh2DSource.

◆ hasFaceField()

virtual bool IMesh2DSource::hasFaceField ( const char *  dataset) const
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ historyGeneration()

virtual int IMesh2DSource::historyGeneration ( ) const
inlinevirtual

Bumps whenever frames are removed or reordered (a live source thinning its history), invalidating anything cached per frame index. Appends do not bump it.

Reimplemented in EngineMesh2DSource.

Here is the caller graph for this function:

◆ isLive()

virtual bool IMesh2DSource::isLive ( ) const
inlinevirtual

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.

Reimplemented in EngineMesh2DSource.

◆ readCells()

virtual bool IMesh2DSource::readCells ( std::vector< double > &  vx,
std::vector< double > &  vy,
std::vector< double > &  vz,
std::vector< std::array< int, 4 > > &  cells 
)
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

Here is the call graph for this function:

◆ readDepthAt()

virtual bool IMesh2DSource::readDepthAt ( int  timeIdx,
int  cell,
float &  out 
)
inlinevirtual

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.

Reimplemented in EngineMesh2DSource.

Here is the call graph for this function:

◆ readDepthsAt()

virtual bool IMesh2DSource::readDepthsAt ( int  timeIdx,
std::vector< float > &  depths 
)
pure virtual

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

Implemented in EngineMesh2DSource, and HDF5Mesh2DSource.

Here is the caller graph for this function:

◆ readEdgeFluxAt()

virtual bool IMesh2DSource::readEdgeFluxAt ( int  timeIdx,
std::vector< float > &  flux 
)
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ readEdgeGeometry()

virtual bool IMesh2DSource::readEdgeGeometry ( std::vector< float > &  length,
std::vector< float > &  nx,
std::vector< float > &  ny 
)
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ readFaceEnvelope()

virtual bool IMesh2DSource::readFaceEnvelope ( const char *  dataset,
std::vector< float > &  values 
)
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ readFaceFieldAt()

virtual bool IMesh2DSource::readFaceFieldAt ( const char *  dataset,
int  timeIdx,
std::vector< float > &  values 
)
inlinevirtual

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

Reimplemented in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ readMeshGeometry()

virtual bool IMesh2DSource::readMeshGeometry ( std::vector< double > &  vx,
std::vector< double > &  vy,
std::vector< double > &  vz,
std::vector< std::array< int, 3 > > &  tris 
)
pure virtual

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.

Implemented in EngineMesh2DSource, and HDF5Mesh2DSource.

Here is the caller graph for this function:

◆ readVertexDepthsAt()

virtual bool IMesh2DSource::readVertexDepthsAt ( int  timeIdx,
std::vector< float > &  vdepths 
)
inlinevirtual

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 in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ simTimeAt()

virtual QDateTime IMesh2DSource::simTimeAt ( int  timeIdx) const
inlinevirtual

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

Reimplemented in EngineMesh2DSource, and HDF5Mesh2DSource.

Here is the caller graph for this function:

◆ timeCount()

virtual int IMesh2DSource::timeCount ( ) const
pure virtual

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

Implemented in EngineMesh2DSource, and HDF5Mesh2DSource.

Here is the caller graph for this function:

◆ triangleCount()

virtual int IMesh2DSource::triangleCount ( ) const
pure virtual

Implemented in EngineMesh2DSource, and HDF5Mesh2DSource.

◆ vertexCount()

virtual int IMesh2DSource::vertexCount ( ) const
pure virtual

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.

Implemented in EngineMesh2DSource, and HDF5Mesh2DSource.


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