Loading...
Searching...
No Matches
inpmeshwriter.h
Go to the documentation of this file.
1
19
20#ifndef OPENSWMMVIS_MESH_INPMESHWRITER_H
21#define OPENSWMMVIS_MESH_INPMESHWRITER_H
22
23#include "meshresult.h"
24#include "meshedgebc.h"
25
26#include <QHash>
27#include <QString>
28#include <QVector>
29
30namespace mesh
31{
32
42 QHash<int, QString> vertexToNode;
44 QHash<int, QString> triangleToNode;
47 QHash<int, double> triangleMannings;
48};
49
61
71{
72public:
87 struct UnitInfo {
88 QString
90 QString sourceCrsTag;
91
92 // User-declared (out-of-line) default ctor: makes UnitInfo a
93 // non-aggregate so the `const UnitInfo & = {}` default arguments
94 // below invoke this constructor instead of aggregate-initialising
95 // with the in-class member initializer — which clang rejects as
96 // "needed within definition of enclosing class outside of member
97 // functions" when the type is nested in InpMeshWriter.
105 };
106
142 [[nodiscard]] static QString buildSectionText(const MeshResult &mesh,
143 const CouplingMap &coupling,
144 double defaultMannings = 0.035,
145 const UnitInfo &units = {});
146
175 [[nodiscard]] static QString buildBCSectionText(const QVector<MeshEdgeBC> &bcs);
176
214 [[nodiscard]] static QString buildConveyanceSectionText(const MeshResult &mesh,
215 const QVector<MeshEdgeBC> &bcs);
216
255 [[nodiscard]] static bool writeExternal(const QString &inpPath, const QString &meshFilePath,
256 const MeshResult &mesh, const CouplingMap &coupling,
257 double defaultMannings = 0.035,
258 QString *errorOut = nullptr,
259 const UnitInfo &units = {});
260
294 [[nodiscard]] static bool writeExternal(const QString &inpPath, const QString &meshFilePath,
295 const MeshResult &mesh, const CouplingMap &coupling,
296 const QVector<MeshEdgeBC> &bcs, double defaultMannings,
297 QString *errorOut = nullptr,
298 const UnitInfo &units = {});
299
328 [[nodiscard]] static bool writeInline(const QString &inpPath, const MeshResult &mesh,
329 const CouplingMap &coupling,
330 double defaultMannings = 0.035,
331 QString *errorOut = nullptr, const UnitInfo &units = {});
332
362 [[nodiscard]] static bool writeInline(const QString &inpPath, const MeshResult &mesh,
363 const CouplingMap &coupling,
364 const QVector<MeshEdgeBC> &bcs, double defaultMannings,
365 QString *errorOut = nullptr, const UnitInfo &units = {});
366
391 [[nodiscard]] static bool writeMeshFileRef(const QString &inpPath, const QString &meshFilePath,
392 QString *errorOut = nullptr);
393
417 [[nodiscard]] static bool writePreparedMeshFileRef(const QString &inpPath,
418 const QString &logicalFinalMeshPath,
419 const QString &physicalStagedMeshPath,
420 QString *errorOut = nullptr);
421
440 [[nodiscard]] static bool validateTopologyReplacement(const QString &filePath,
441 QString *errorOut = nullptr);
442
477 [[nodiscard]] static bool replaceMeshSections(const QString &filePath, const MeshResult &mesh,
478 const QVector<MeshEdgeBC> &bcs,
479 QString *errorOut = nullptr,
480 double defaultMannings = 0.035,
481 const UnitInfo *units = nullptr);
482
508 [[nodiscard]] static bool patchBCSections(const QString &filePath, const MeshResult &mesh,
509 const QVector<MeshEdgeBC> &bcs,
510 QString *errorOut = nullptr);
511
548 [[nodiscard]] static bool patchAttributeSections(const QString &filePath,
549 const MeshResult &mesh,
550 QString *errorOut = nullptr,
551 double defaultMannings = 0.035,
552 const UnitInfo *units = nullptr);
553
586 [[nodiscard]] static bool patchMeshSections(const QString &filePath, const MeshResult &mesh,
587 const QVector<MeshEdgeBC> &bcs,
588 QString *errorOut = nullptr,
589 double defaultMannings = 0.035,
590 const UnitInfo *units = nullptr);
591
613 [[nodiscard]] static bool clearMeshFileRef(const QString &inpPath, QString *errorOut = nullptr);
614
640 [[nodiscard]] static bool write(MeshOutputMode mode, const QString &inpPath,
641 const QString &meshFilePath, const MeshResult &mesh,
642 const CouplingMap &coupling, double defaultMannings = 0.035,
643 QString *errorOut = nullptr, const UnitInfo &units = {});
644};
645
646} // namespace mesh
647
648#endif // OPENSWMMVIS_MESH_INPMESHWRITER_H
Stateless writer that renders a MeshResult plus CouplingMap as SWMM [2D_*] section text and writes or...
Definition inpmeshwriter.h:71
static QString buildBCSectionText(const QVector< MeshEdgeBC > &bcs)
Render authored cell/local-edge boundary rows with raw variant parameters.
Definition inpmeshwriter.cpp:1289
static bool patchAttributeSections(const QString &filePath, const MeshResult &mesh, QString *errorOut=nullptr, double defaultMannings=0.035, const UnitInfo *units=nullptr)
Rewrite owned geometry attributes/coupling/infiltration after matching row counts.
Definition inpmeshwriter.cpp:1621
static bool patchBCSections(const QString &filePath, const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs, QString *errorOut=nullptr)
Replace only owned boundary/conveyance sections in one file.
Definition inpmeshwriter.cpp:1609
static bool writePreparedMeshFileRef(const QString &inpPath, const QString &logicalFinalMeshPath, const QString &physicalStagedMeshPath, QString *errorOut=nullptr)
Publish an INP reference to a final logical mesh name after checking a physical staged file.
Definition inpmeshwriter.cpp:1162
static bool writeMeshFileRef(const QString &inpPath, const QString &meshFilePath, QString *errorOut=nullptr)
Replace GUI-owned inline mesh sections with a reference to an existing filesystem entry.
Definition inpmeshwriter.cpp:1087
static bool patchMeshSections(const QString &filePath, const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs, QString *errorOut=nullptr, double defaultMannings=0.035, const UnitInfo *units=nullptr)
Patch matched mesh attributes and complete boundary state in one atomic file update.
Definition inpmeshwriter.cpp:1637
static bool replaceMeshSections(const QString &filePath, const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs, QString *errorOut=nullptr, double defaultMannings=0.035, const UnitInfo *units=nullptr)
Replace the complete owned topology and attributes in one checked single-file commit.
Definition inpmeshwriter.cpp:1201
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={})
Dispatch to the geometry-only external or inline publication strategy.
Definition inpmeshwriter.cpp:1271
static bool writeInline(const QString &inpPath, const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, QString *errorOut=nullptr, const UnitInfo &units={})
Replace GUI-owned mesh sections and any external mesh reference with an inline mesh.
Definition inpmeshwriter.cpp:1002
static bool validateTopologyReplacement(const QString &filePath, QString *errorOut=nullptr)
Read a model and reject recognized unsupported mesh-indexed assignments before replacement.
Definition inpmeshwriter.cpp:1192
static QString buildSectionText(const MeshResult &mesh, const CouplingMap &coupling, double defaultMannings=0.035, const UnitInfo &units={})
Render native geometry, coupling and infiltration sections into an owned text block.
Definition inpmeshwriter.cpp:779
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={})
Publish a native mesh sidecar, then retarget an existing INP to that sidecar.
Definition inpmeshwriter.cpp:1029
static QString buildConveyanceSectionText(const MeshResult &mesh, const QVector< MeshEdgeBC > &bcs)
Render one nondefault conveyance factor per undirected real mesh edge.
Definition inpmeshwriter.cpp:1356
static bool clearMeshFileRef(const QString &inpPath, QString *errorOut=nullptr)
Strip recognized external-reference blocks while preserving inline mesh and other sections.
Definition inpmeshwriter.cpp:1125
Slice §V.VA — per-edge boundary condition value, stored on the SWMM2DMeshLayer in a SoA QVector index...
value types for the 2D mesh generator.
The Qt-facing MeshKit API (meshkit::core_qt, meshkit::model_qt, meshkit::io_qt): mesh value types and...
MeshOutputMode
Output strategy for the four 2D mesh sections.
Definition inpmeshwriter.h:57
@ Inline
Inline the four sections directly in the .inp.
Definition inpmeshwriter.h:59
@ External
Write .2dm next to the .inp; reference via [2D_MESH_FILE].
Definition inpmeshwriter.h:58
1D↔2D coupling map produced by the meshing dialog.
Definition inpmeshwriter.h:40
QHash< int, QString > triangleToNode
Triangle index (in MeshResult::triangles) → SWMM node ID.
Definition inpmeshwriter.h:44
QHash< int, QString > vertexToNode
Vertex index (in MeshResult::vertices) → SWMM node ID.
Definition inpmeshwriter.h:42
QHash< int, double > triangleMannings
Per-triangle Manning's n.
Definition inpmeshwriter.h:47
Unit & provenance metadata written as ;; header comments.
Definition inpmeshwriter.h:87
QString sourceCrsTag
Goes into ;; SOURCE_CRS: (e.g. "EPSG:2249").
Definition inpmeshwriter.h:90
QString linearUnitName
Goes into ;; UNITS: (e.g. "metre", "US survey foot", "SI (m)").
Definition inpmeshwriter.h:89
UnitInfo()
Construct empty length-unit and source-CRS metadata strings.
Result of MeshGenerator::generate.
Definition meshresult.h:203