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
mesh2dresultsexport.h File Reference
#include <QString>
#include <QStringList>
#include <functional>
#include <vector>
Include dependency graph for mesh2dresultsexport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmmvis::io::Mesh2DExportOptions
 What to export. Collected by the dialog, consumed by exportMesh2DResults. More...
 
struct  openswmmvis::io::Mesh2DExportInputs
 The run to export plus the unit / CRS context the source cannot state. More...
 
struct  openswmmvis::io::Mesh2DExportReport
 What was written, or why nothing was. More...
 
struct  openswmmvis::io::Mesh2DGridHint
 What a caller needs to size a raster before running the export. More...
 

Namespaces

namespace  openswmmvis
 
namespace  openswmmvis::io
 

Typedefs

using openswmmvis::io::Mesh2DExportProgress = std::function< bool(int done, int total, const QString &what)>
 Progress sink. Return false to cancel — every file written so far is then deleted, so a cancelled export leaves nothing half-written behind.
 

Enumerations

enum class  openswmmvis::io::Mesh2DExportFormat {
  openswmmvis::io::Shapefile ,
  openswmmvis::io::GeoPackage ,
  openswmmvis::io::GeoTiff
}
 Output container. Vector formats share one OGR code path. More...
 
enum class  openswmmvis::io::Mesh2DInterp {
  openswmmvis::io::NaturalNeighbour ,
  openswmmvis::io::Idw ,
  openswmmvis::io::GreenGauss
}
 How cell-centred values are carried to raster pixels. More...
 
enum  openswmmvis::io::Mesh2DVariable : unsigned {
  openswmmvis::io::Mesh2DDepth = 1u << 0 ,
  openswmmvis::io::Mesh2DHead = 1u << 1 ,
  openswmmvis::io::Mesh2DVx = 1u << 2 ,
  openswmmvis::io::Mesh2DVy = 1u << 3 ,
  openswmmvis::io::Mesh2DVmag = 1u << 4
}
 Exportable fields, as a bitmask. More...
 

Functions

bool openswmmvis::io::exportMesh2DResults (const Mesh2DExportInputs &inputs, const Mesh2DExportOptions &options, const Mesh2DExportProgress &progress, Mesh2DExportReport *report)
 Run the export described by options against inputs.
 
Mesh2DGridHint openswmmvis::io::mesh2DGridHint (IMesh2DSource *source, double unitFactor)
 Mesh extent and a default pixel size for source, so a dialog can show the resulting raster's dimensions before anything is written.
 
QString openswmmvis::io::mesh2DVariableKey (Mesh2DVariable variable)
 Lower-case single-word name of variable ("depth", "vmag", …), used for file suffixes, layer names and the sidecar's field column.
 
QString openswmmvis::io::mesh2DVariableLabel (Mesh2DVariable variable)
 Human label for variable, e.g. "Water surface elevation".
 

Variables

constexpr float openswmmvis::io::kMesh2DNoData = -9999.0f
 NoData written into every raster band (dry / outside the mesh).
 
constexpr unsigned openswmmvis::io::kMesh2DMaxVariables = Mesh2DDepth | Mesh2DHead | Mesh2DVmag
 Maximum fields exist only for these variables (see Mesh2DExportOptions::includeMax). A signed component's maximum is not a meaningful envelope.
 

Detailed Description

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License\n GPL-3.0-or-later

Export a 2D results run (an IMesh2DSource — the engine's CF/UGRID .h5, or any in-memory source) to GIS:

  • VECTOR (ESRI Shapefile / GeoPackage) — one polygon feature per mesh CELL (triangle or quad, never the display sub-triangle fan), one LAYER/FILE PER VARIABLE, one FIELD per selected time step (t0001…) plus max.
  • RASTER (GeoTIFF, Float32, NoData -9999) — one file per variable with one BAND per selected time step (band description = ISO datetime), plus a separate single-band _max.tif. Cell values are interpolated to the pixel grid by natural neighbour, inverse distance weighting or a per-cell Green–Gauss gradient reconstruction.

The t0001-style field names exist because a Shapefile's DBF caps field names at 10 characters; writeTimesCsv's sidecar (<base>_times.csv) maps each name back to its frame index and datetime.

The module is deliberately widget-free (CLAUDE.md §5.1): the dialog collects a Mesh2DExportOptions and this code does the work, so the export is testable headless and could be driven from a script later.

Units: every coordinate and value is written in the MODEL's display unit system. The engine's 2D solver runs in SI, so the caller supplies Mesh2DExportInputs::unitFactor (the layer's depthToMeshUnits()) and every x/y/z, depth, head and velocity is multiplied by it. The dry-depth comparison happens in metres, before scaling.