![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
#include <mesh2dh5reader.h>
Public Member Functions | |
| Mesh2DH5Reader () | |
| ~Mesh2DH5Reader () | |
| Mesh2DH5Reader (const Mesh2DH5Reader &)=delete | |
| Mesh2DH5Reader & | operator= (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 > ×) 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). | |
|
default |
| openswmmvis::io::Mesh2DH5Reader::~Mesh2DH5Reader | ( | ) |
|
delete |
|
inline |
| void openswmmvis::io::Mesh2DH5Reader::close | ( | ) |
Close the file (idempotent; called automatically on destruction).
| int openswmmvis::io::Mesh2DH5Reader::displayTriangleCount | ( | ) | const |
Number of DISPLAY triangles returned by readTriangles (cells + quads; == cellCount() for an all-triangle file). 0 on error.
| 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.
| bool openswmmvis::io::Mesh2DH5Reader::hasFaceField | ( | const char * | dataset | ) | const |
True iff dataset exists at the file root (probe cached).
|
inlinenoexcept |
|
inlinenoexcept |
Last error message from a failing open/read call.
| bool openswmmvis::io::Mesh2DH5Reader::open | ( | const QString & | path | ) |
Open the HDF5 file read-only.
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.
|
delete |
|
inlinenoexcept |
Current path (empty if not open).
| 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.
| 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.
/crs variable was found and parsed. | bool openswmmvis::io::Mesh2DH5Reader::readDepthsAt | ( | int | timeIdx, |
| std::vector< float > & | depths | ||
| ) | const |
Read one time slice of /Mesh2_face_depth.
| timeIdx | 0-based time index (must be < timeCount()). |
| depths | Output, resized to triangleCount(). Values in metres. |
| bool openswmmvis::io::Mesh2DH5Reader::readEdgeFluxAt | ( | int | timeIdx, |
| std::vector< float > & | flux | ||
| ) | const |
Read one time slice of /Mesh2_edge_flux.
| timeIdx | 0-based time index (must be < timeCount()). |
| flux | Output, 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. |
lastError set) if the file does not carry the dataset. | 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).
| length | Output, resized to cellCount()*kEdgeStride ([cell*kEdgeStride + localEdge], file width repacked). |
| nx,ny | Output, same layout. |
| 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.
| dataset | Dataset name at the file root. |
| values | Output, resized to triangleCount(); engine SI units. |
triangleCount() — readFaceFieldAt handles the rank-2 [nTime, nFace] fields instead. | 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).
| dataset | Dataset name at the file root. |
| timeIdx | 0-based time index (must be < timeCount()). |
| values | Output, resized to triangleCount(); engine SI units. |
| 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.
| bool openswmmvis::io::Mesh2DH5Reader::readTimes | ( | std::vector< double > & | times | ) | const |
Read all time values. Resizes output.
| 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.
| 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.
| timeIdx | 0-based time index (must be < timeCount()). |
| heads | Output, 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. |
| 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).
| timeIdx | 0-based time index (must be < timeCount()). |
| depths | Output, resized to vertexCount(). Metres; float is ample because the datum is subtracted engine-side in double. |
| 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.
| 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.
|
inline |
Display triangle → cell index (parallel to readTriangles; the identity for an all-triangle file). Empty until readTriangles / displayTriangleCount / readCells has run successfully.
| int openswmmvis::io::Mesh2DH5Reader::vertexCount | ( | ) | const |
Number of mesh vertices (/Mesh2_node_x length).
|
staticconstexpr |
Edge slots per cell in every per-edge array this reader returns (== mesh::kEdgeStride; asserted in the .cpp).