|
| static QString | buildSectionText (const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, const UnitInfo &units={}) |
| | Render the 2D mesh sections as a single text block.
|
| |
| static QString | buildBCSectionText (const QVector< MeshEdgeBC > &bcs) |
| | Slice §V.VD.1 — render the [2D_BOUNDARY_CONDITIONS] section for the per-edge BC vector. Returns an empty string when every edge is Wall (avoids polluting the .inp with a section that round-trips to default). Format:
|
| |
| static QString | buildConveyanceSectionText (const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs) |
| | Engine §11A — render the [2D_EDGE_CONVEYANCE] section.
|
| |
| static bool | writeExternal (const QString &inpPath, const QString &meshFilePath, const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, QString *errorOut=nullptr, const UnitInfo &units={}) |
| | Default mode: write the mesh into a sibling .2dm file and patch the .inp with a [2D_MESH_FILE] reference.
|
| |
| static bool | writeExternal (const QString &inpPath, const QString &meshFilePath, const MeshResult &mesh, const CouplingMap &coupling, const QVector< MeshEdgeBC > &bcs, double defaultMannings, QString *errorOut=nullptr, const UnitInfo &units={}) |
| | §V.VD.1 overload — additionally writes the [2D_BOUNDARY_CONDITIONS] section. Empty / all-Wall BC vector is equivalent to the non-BC overload (section is omitted).
|
| |
| static bool | writeInline (const QString &inpPath, const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, QString *errorOut=nullptr, const UnitInfo &units={}) |
| | Replace (or append) all four 2D sections in the .inp at inpPath. Existing 2D sections are stripped first; any existing [2D_MESH_FILE] block is also removed so the engine reads the freshly-inlined sections instead.
|
| |
| static bool | writeInline (const QString &inpPath, const MeshResult &mesh, const CouplingMap &coupling, const QVector< MeshEdgeBC > &bcs, double defaultMannings, QString *errorOut=nullptr, const UnitInfo &units={}) |
| | §V.VD.1 overload — additionally writes the [2D_BOUNDARY_CONDITIONS] section inline.
|
| |
| static bool | writeMeshFileRef (const QString &inpPath, const QString &meshFilePath, QString *errorOut=nullptr) |
| | Retarget the .inp's [2D_MESH_FILE] reference at an already-existing .2dm without writing any mesh geometry.
|
| |
| static bool | patchBCSections (const QString &filePath, const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs, QString *errorOut=nullptr) |
| | Replace the [2D_BOUNDARY_CONDITIONS] and [2D_EDGE_CONVEYANCE] sections of filePath (a .inp or external .2dm) with sections built from bcs, leaving every other section untouched.
|
| |
| static bool | patchAttributeSections (const QString &filePath, const MeshResult &mesh, QString *errorOut=nullptr, double defaultMannings=0.035) |
| | Replace the [2D_VERTICES], [2D_TRIANGLES], [2D_QUADS], [2D_VERTEX_NODE_MAP], [2D_TRIANGLE_NODE_MAP] and [2D_INFILTRATION_OPTIONS] / [2D_INFILTRATION_DEFAULTS] / [2D_INFILTRATION] sections of filePath with sections rebuilt from the layer's editable mesh state, leaving every other section untouched.
|
| |
| static bool | clearMeshFileRef (const QString &inpPath, QString *errorOut=nullptr) |
| | Strip any [2D_MESH_FILE] reference from the .inp so the engine falls back to the inline [2D_*] mesh sections.
|
| |
| static bool | write (MeshOutputMode mode, const QString &inpPath, const QString &meshFilePath, const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, QString *errorOut=nullptr, const UnitInfo &units={}) |
| | Convenience dispatch on MeshOutputMode.
|
| |
| QString mesh::InpMeshWriter::buildConveyanceSectionText |
( |
const MeshResult & |
mesh, |
|
|
const QVector< MeshEdgeBC > & |
bcs |
|
) |
| |
|
static |
Engine §11A — render the [2D_EDGE_CONVEYANCE] section.
Walks bcs (flat-indexed mesh::edgeSlot(cell, edge), parallel to mesh; endpoints via mesh::edgeEndpoints, every edge of a quad included) and emits one row per edge whose conveyance differs from the default 1.0. Interior edges occupy two slots that the GUI keeps in sync (see SWMM2DMeshLayer::applyMeshEdgeConveyance), so the writer canonicalises on the first encountered vertex-pair and silently drops the second half — interior edges appear exactly once. Returns an empty string when every edge is at default.
Format (matches the engine parser in SectionHandlers2D.cpp):
[2D_EDGE_CONVEYANCE]
;; FROM_VERTEX TO_VERTEX CONVEYANCE
12 37 0.5
12 45 0
CONVEYANCE is a dimensionless multiplier in [0, 1]. 1.0 (default) is unrestricted; 0.0 is a closed (impermeable) edge.
Render the 2D mesh sections as a single text block.
Order: [2D_VERTICES], [2D_TRIANGLES] (triangle cells), [2D_QUADS] (V1 V2 V3 V4 MANNINGS_N [INIT_DEPTH] [TAG], quad cells — emitted ONLY when the mesh holds a quad, so all-triangle output is byte-identical to the pre-quad writer), [2D_VERTEX_NODE_MAP], [2D_TRIANGLE_NODE_MAP], then the GG0a infiltration family [2D_INFILTRATION_OPTIONS] / [2D_INFILTRATION_DEFAULTS] / [2D_INFILTRATION]. Each section starts with a ;;-prefixed header comment. Sections with no content (e.g. empty vertex_node_map, a mesh with no infiltration data) are omitted entirely.
The infiltration sections are per-cell mesh attributes, so they ride with the mesh — into the .2dm in external mode, inline otherwise. They are deliberately NOT appended to [2D_TRIANGLES], whose columns are positional.
- Parameters
-
| mesh | output of MeshGenerator::generate() |
| coupling | vertex/triangle → SWMM node map |
| defaultMannings | used for triangles missing from coupling.triangleMannings (default 0.035 ≈ natural channel / grass). |
| units | optional ;; UNITS: / ;; SOURCE_CRS: header metadata (purely descriptive). |
| bool mesh::InpMeshWriter::patchAttributeSections |
( |
const QString & |
filePath, |
|
|
const MeshResult & |
mesh, |
|
|
QString * |
errorOut = nullptr, |
|
|
double |
defaultMannings = 0.035 |
|
) |
| |
|
static |
Replace the [2D_VERTICES], [2D_TRIANGLES], [2D_QUADS], [2D_VERTEX_NODE_MAP], [2D_TRIANGLE_NODE_MAP] and [2D_INFILTRATION_OPTIONS] / [2D_INFILTRATION_DEFAULTS] / [2D_INFILTRATION] sections of filePath with sections rebuilt from the layer's editable mesh state, leaving every other section untouched.
Every GUI-owned mesh-attribute section must be listed here. A section this function does not re-emit is discarded on every project save, because the save path restores a pre-engine-write snapshot of the mesh file first — see the comment at src/swmmvisprojectwindow.cpp:1414-1419.
The BC-patch's sibling for mesh attributes: the post-save external-mesh restore rolls the sidecar back to its pre-write snapshot, which predates the engine's write of the current vertex elevation / tag / coupling and triangle Manning / tag edits — without this re-emit those edits silently vanish from the saved model (and the next run reads the old elevations). The layer is authoritative for exactly the fields pushMeshEditsToEngine() pushes; a triangle whose Manning is unset (NaN) keeps the file's existing token so a generation-time default survives the rewrite.
Fails without touching the file when the section row counts don't match mesh — rows map to mesh entries by position, so a mismatch means the file holds a different mesh. Atomic via QSaveFile.
- Parameters
-
| filePath | External mesh file (or .inp) to patch. |
| mesh | The layer's current mesh state. |
| errorOut | Set on failure. |
| defaultMannings | MANNINGS_N materialized for a row that must carry an INIT_DEPTH or TAG but has no Manning's value on either side (columns are positional, so the later ones cannot be written without it). |
- Returns
- true on success.