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
openswmmvis::io::Mesh2DH5Reader Class Reference

#include <mesh2dh5reader.h>

Collaboration diagram for openswmmvis::io::Mesh2DH5Reader:

Public Member Functions

 Mesh2DH5Reader ()
 
 ~Mesh2DH5Reader ()
 
 Mesh2DH5Reader (const Mesh2DH5Reader &)=delete
 
Mesh2DH5Readeroperator= (const Mesh2DH5Reader &)=delete
 
bool open (const QString &path)
 Open the HDF5 file read-only.
 
void close ()
 Close the file (idempotent; called automatically on destruction).
 
bool isOpen () const noexcept
 
const QString & path () const noexcept
 Current path (empty if not open).
 
const QString & lastError () const noexcept
 Last error message from a failing open/read call.
 
int vertexCount () const
 Number of mesh vertices (/Mesh2_node_x length).
 
int triangleCount () const
 Number of mesh CELLS (/Mesh2_face_nodes row count — the file's face count, triangles and quads alike). Historical name; identical to cellCount. Per-face datasets have this length.
 
int cellCount () const
 Number of mesh cells (== triangleCount).
 
int displayTriangleCount () const
 Number of DISPLAY triangles returned by readTriangles (cells + quads; == cellCount() for an all-triangle file). 0 on error.
 
int edgeStride () const
 Width of the file's per-edge datasets (/Mesh2_face_nodes dim 1): 3 for an all-triangle file, 4 once any quad exists. The arrays this reader returns are always kEdgeStride wide. 0 on error.
 
bool readMeshGeometry (std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz) const
 Read vertex coordinates into vx,vy,vz. Resizes output.
 
bool readCells (std::vector< std::array< int, 4 > > &cells) const
 Read the cells verbatim. cells[c] = {v0,v1,v2,v3}, with v3 = −1 for a triangle (cyclic order for a quad). Indices are normalised to 0-based (start_index), padding is taken from _FillValue / negative entries / /Mesh2_face_nv.
 
bool readTriangles (std::vector< std::array< int, 3 > > &tris) const
 Read the DISPLAY sub-triangle fan. tris[i] = {v0,v1,v2}; one entry per triangle cell, two per quad (mesh::cellGeom's diagonal), so tris.size() == displayTriangleCount(). Use triangleFaceMap to look up the cell whose value display triangle i carries. For an all-triangle file this is exactly the file's connectivity.
 
const std::vector< int > & triangleFaceMap () const
 Display triangle → cell index (parallel to readTriangles; the identity for an all-triangle file). Empty until readTriangles / displayTriangleCount / readCells has run successfully.
 
bool readCoordinateReference (CoordinateReference &out) const
 Read the /crs georeferencing variable (engine 6.0+).
 
int timeCount () const
 Current number of time steps written to /time.
 
bool readTimes (std::vector< double > &times) const
 Read all time values. Resizes output.
 
bool readDepthsAt (int timeIdx, std::vector< float > &depths) const
 Read one time slice of /Mesh2_face_depth.
 
bool readFaceFieldAt (const char *dataset, int timeIdx, std::vector< float > &values) const
 Read one time slice of any per-face [nTime, nFace] dataset (e.g. Mesh2_face_rainfall, Mesh2_face_rain_cum).
 
bool hasFaceField (const char *dataset) const
 True iff dataset exists at the file root (probe cached).
 
bool readFaceEnvelope (const char *dataset, std::vector< float > &values) const
 Read a time-INVARIANT per-face [nFace] dataset — the engine's run envelopes (Mesh2_face_max_depth, Mesh2_face_max_velocity, Mesh2_face_max_continuity_err), written under the REPORT_2D_VARIABLES group ENVELOPES and overwritten in place each output step, so the values are whole-run maxima.
 
bool readVertexHeadsAt (int timeIdx, std::vector< double > &heads) const
 Read one time slice of /Mesh2_node_head — the engine's pseudo-Laplacian vertex-head reconstruction.
 
bool readVertexSignedDepthsAt (int timeIdx, std::vector< float > &depths) const
 Read one time slice of /Mesh2_node_depth — the engine's wet-masked, depth-weighted SIGNED vertex depth (η_v − z_v; the render field: dry-cell bed elevations never contribute, negative over the dry side of partially wet cells).
 
bool readEdgeFluxAt (int timeIdx, std::vector< float > &flux) const
 Read one time slice of /Mesh2_edge_flux.
 
bool readEdgeGeometry (std::vector< float > &length, std::vector< float > &nx, std::vector< float > &ny) const
 Read time-invariant edge length + outward unit normal.
 

Static Public Attributes

static constexpr int kEdgeStride = 4
 Edge slots per cell in every per-edge array this reader returns (== mesh::kEdgeStride; asserted in the .cpp).
 

Constructor & Destructor Documentation

◆ Mesh2DH5Reader() [1/2]

openswmmvis::io::Mesh2DH5Reader::Mesh2DH5Reader ( )
default

◆ ~Mesh2DH5Reader()

openswmmvis::io::Mesh2DH5Reader::~Mesh2DH5Reader ( )
Here is the call graph for this function:

◆ Mesh2DH5Reader() [2/2]

openswmmvis::io::Mesh2DH5Reader::Mesh2DH5Reader ( const Mesh2DH5Reader )
delete

Member Function Documentation

◆ cellCount()

int openswmmvis::io::Mesh2DH5Reader::cellCount ( ) const
inline

Number of mesh cells (== triangleCount).

Here is the call graph for this function:

◆ close()

void openswmmvis::io::Mesh2DH5Reader::close ( )

Close the file (idempotent; called automatically on destruction).

Here is the caller graph for this function:

◆ displayTriangleCount()

int openswmmvis::io::Mesh2DH5Reader::displayTriangleCount ( ) const

Number of DISPLAY triangles returned by readTriangles (cells + quads; == cellCount() for an all-triangle file). 0 on error.

◆ edgeStride()

int openswmmvis::io::Mesh2DH5Reader::edgeStride ( ) const

Width of the file's per-edge datasets (/Mesh2_face_nodes dim 1): 3 for an all-triangle file, 4 once any quad exists. The arrays this reader returns are always kEdgeStride wide. 0 on error.

◆ hasFaceField()

bool openswmmvis::io::Mesh2DH5Reader::hasFaceField ( const char *  dataset) const

True iff dataset exists at the file root (probe cached).

Here is the caller graph for this function:

◆ isOpen()

bool openswmmvis::io::Mesh2DH5Reader::isOpen ( ) const
inlinenoexcept

◆ lastError()

const QString & openswmmvis::io::Mesh2DH5Reader::lastError ( ) const
inlinenoexcept

Last error message from a failing open/read call.

◆ open()

bool openswmmvis::io::Mesh2DH5Reader::open ( const QString &  path)

Open the HDF5 file read-only.

Returns
true on success. On failure, lastError() carries the message.

The file may still be growing on disk (live mode). HDF5's SWMR is not required because the engine flushes after each update() and our timeCount() re-reads the time-dimension extent on every call.

Here is the call graph for this function:

◆ operator=()

Mesh2DH5Reader & openswmmvis::io::Mesh2DH5Reader::operator= ( const Mesh2DH5Reader )
delete

◆ path()

const QString & openswmmvis::io::Mesh2DH5Reader::path ( ) const
inlinenoexcept

Current path (empty if not open).

Here is the caller graph for this function:

◆ readCells()

bool openswmmvis::io::Mesh2DH5Reader::readCells ( std::vector< std::array< int, 4 > > &  cells) const

Read the cells verbatim. cells[c] = {v0,v1,v2,v3}, with v3 = −1 for a triangle (cyclic order for a quad). Indices are normalised to 0-based (start_index), padding is taken from _FillValue / negative entries / /Mesh2_face_nv.

Here is the caller graph for this function:

◆ readCoordinateReference()

bool openswmmvis::io::Mesh2DH5Reader::readCoordinateReference ( CoordinateReference out) const

Read the /crs georeferencing variable (engine 6.0+).

Never fails on a file that predates /crs: out is left with declared == false and metresPerModelUnit == 1.0, and storedUnits is still filled from the units attribute on /Mesh2_node_x when present. Callers treat undeclared files with the layer-CRS fallback.

Returns
true if a /crs variable was found and parsed.

◆ readDepthsAt()

bool openswmmvis::io::Mesh2DH5Reader::readDepthsAt ( int  timeIdx,
std::vector< float > &  depths 
) const

Read one time slice of /Mesh2_face_depth.

Parameters
timeIdx0-based time index (must be < timeCount()).
depthsOutput, resized to triangleCount(). Values in metres.
Returns
true on success.
Here is the call graph for this function:

◆ readEdgeFluxAt()

bool openswmmvis::io::Mesh2DH5Reader::readEdgeFluxAt ( int  timeIdx,
std::vector< float > &  flux 
) const

Read one time slice of /Mesh2_edge_flux.

Parameters
timeIdx0-based time index (must be < timeCount()).
fluxOutput, resized to cellCount()*kEdgeStride, indexed [cell*kEdgeStride + localEdge] (mesh::edgeSlot) whatever the file's own width (edgeStride); slot 3 of a triangle is 0. Units m² s⁻¹; sign convention positive = outward through the edge's outward normal.
Returns
true on success; false (with lastError set) if the file does not carry the dataset.
Here is the call graph for this function:

◆ readEdgeGeometry()

bool openswmmvis::io::Mesh2DH5Reader::readEdgeGeometry ( std::vector< float > &  length,
std::vector< float > &  nx,
std::vector< float > &  ny 
) const

Read time-invariant edge length + outward unit normal.

Prefers the /Mesh2_edge_length, /Mesh2_edge_nx, /Mesh2_edge_ny datasets written by engine 6.0+ (CF.2). When any of them is absent (older .h5 files), falls back to recomputing on the fly from /Mesh2_node_x, /Mesh2_node_y, and /Mesh2_face_nodes using the same convention as the engine's MeshBuilder (edge e joins v[(e+1)nv] and v[(e+2)nv]; outward normal flipped if needed so it points away from the centroid).

Parameters
lengthOutput, resized to cellCount()*kEdgeStride ([cell*kEdgeStride + localEdge], file width repacked).
nx,nyOutput, same layout.
Returns
true on success.
Here is the call graph for this function:

◆ readFaceEnvelope()

bool openswmmvis::io::Mesh2DH5Reader::readFaceEnvelope ( const char *  dataset,
std::vector< float > &  values 
) const

Read a time-INVARIANT per-face [nFace] dataset — the engine's run envelopes (Mesh2_face_max_depth, Mesh2_face_max_velocity, Mesh2_face_max_continuity_err), written under the REPORT_2D_VARIABLES group ENVELOPES and overwritten in place each output step, so the values are whole-run maxima.

Parameters
datasetDataset name at the file root.
valuesOutput, resized to triangleCount(); engine SI units.
Returns
true on success; false when the file lacks the dataset (presence probed once per name and cached) or when it is not rank 1 of length triangleCount()readFaceFieldAt handles the rank-2 [nTime, nFace] fields instead.
Here is the call graph for this function:

◆ readFaceFieldAt()

bool openswmmvis::io::Mesh2DH5Reader::readFaceFieldAt ( const char *  dataset,
int  timeIdx,
std::vector< float > &  values 
) const

Read one time slice of any per-face [nTime, nFace] dataset (e.g. Mesh2_face_rainfall, Mesh2_face_rain_cum).

Parameters
datasetDataset name at the file root.
timeIdx0-based time index (must be < timeCount()).
valuesOutput, resized to triangleCount(); engine SI units.
Returns
true on success; false (presence probed once per name and cached, no HDF5 error spam) when the file lacks the dataset.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readMeshGeometry()

bool openswmmvis::io::Mesh2DH5Reader::readMeshGeometry ( std::vector< double > &  vx,
std::vector< double > &  vy,
std::vector< double > &  vz 
) const

Read vertex coordinates into vx,vy,vz. Resizes output.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readTimes()

bool openswmmvis::io::Mesh2DH5Reader::readTimes ( std::vector< double > &  times) const

Read all time values. Resizes output.

Here is the call graph for this function:

◆ readTriangles()

bool openswmmvis::io::Mesh2DH5Reader::readTriangles ( std::vector< std::array< int, 3 > > &  tris) const

Read the DISPLAY sub-triangle fan. tris[i] = {v0,v1,v2}; one entry per triangle cell, two per quad (mesh::cellGeom's diagonal), so tris.size() == displayTriangleCount(). Use triangleFaceMap to look up the cell whose value display triangle i carries. For an all-triangle file this is exactly the file's connectivity.

◆ readVertexHeadsAt()

bool openswmmvis::io::Mesh2DH5Reader::readVertexHeadsAt ( int  timeIdx,
std::vector< double > &  heads 
) const

Read one time slice of /Mesh2_node_head — the engine's pseudo-Laplacian vertex-head reconstruction.

Parameters
timeIdx0-based time index (must be < timeCount()).
headsOutput, resized to vertexCount(). Values in metres, read as double — heads carry the elevation datum, and a float ulp at high z exceeds the dry-depth threshold.
Returns
true on success; false (without HDF5 error spam — presence is probed once via H5Lexists and cached) when the file predates the dataset.
Here is the call graph for this function:

◆ readVertexSignedDepthsAt()

bool openswmmvis::io::Mesh2DH5Reader::readVertexSignedDepthsAt ( int  timeIdx,
std::vector< float > &  depths 
) const

Read one time slice of /Mesh2_node_depth — the engine's wet-masked, depth-weighted SIGNED vertex depth (η_v − z_v; the render field: dry-cell bed elevations never contribute, negative over the dry side of partially wet cells).

Parameters
timeIdx0-based time index (must be < timeCount()).
depthsOutput, resized to vertexCount(). Metres; float is ample because the datum is subtracted engine-side in double.
Returns
true on success; false (presence probed once via H5Lexists and cached) when the file predates the dataset — callers then fall back to the GUI-side wet-only reconstruction.
Here is the call graph for this function:

◆ timeCount()

int openswmmvis::io::Mesh2DH5Reader::timeCount ( ) const

Current number of time steps written to /time.

Re-reads the dataspace dims on every call so live-tailing works: as the engine appends, subsequent calls return the new count.

Here is the caller graph for this function:

◆ triangleCount()

int openswmmvis::io::Mesh2DH5Reader::triangleCount ( ) const

Number of mesh CELLS (/Mesh2_face_nodes row count — the file's face count, triangles and quads alike). Historical name; identical to cellCount. Per-face datasets have this length.

Here is the caller graph for this function:

◆ triangleFaceMap()

const std::vector< int > & openswmmvis::io::Mesh2DH5Reader::triangleFaceMap ( ) const
inline

Display triangle → cell index (parallel to readTriangles; the identity for an all-triangle file). Empty until readTriangles / displayTriangleCount / readCells has run successfully.

◆ vertexCount()

int openswmmvis::io::Mesh2DH5Reader::vertexCount ( ) const

Number of mesh vertices (/Mesh2_node_x length).

Here is the caller graph for this function:

Member Data Documentation

◆ kEdgeStride

constexpr int openswmmvis::io::Mesh2DH5Reader::kEdgeStride = 4
staticconstexpr

Edge slots per cell in every per-edge array this reader returns (== mesh::kEdgeStride; asserted in the .cpp).


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