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
meshinfil.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
43#ifndef OPENSWMMVIS_MESHINFIL_H
44#define OPENSWMMVIS_MESHINFIL_H
45
46#include <QByteArray>
47#include <QHash>
48#include <QString>
49#include <QStringList>
50#include <QVector>
51#include <QtGlobal>
52#include <QtNumeric>
53
54namespace mesh {
55
56struct MeshResult;
57
61enum class InfilMethod : int {
62 None = -1,
63 Horton = 0,
64 ModHorton = 1,
65 GreenAmpt = 2,
66 ModGreenAmpt = 3,
67 CurveNumber = 4,
68 Constant = 5
69};
70
72enum class InfilDest : int {
73 Lost = 0,
74 SubcatchAquifer = 1,
75 Aquifer2D = 2
76};
77
79inline constexpr int kInfilMaxParams = 5;
80
98{
100 double p[kInfilMaxParams] = {qQNaN(), qQNaN(), qQNaN(), qQNaN(), qQNaN()};
102
103 bool isNone() const { return method == InfilMethod::None; }
104 bool operator==(const InfilRow &o) const;
105 bool operator!=(const InfilRow &o) const { return !(*this == o); }
106};
107
111{
112 QString tag;
114};
115
118{
121 double infilStep = 0.0;
122};
123
127enum class InfilProvenance : int {
128 None = 0,
129 Star = 1,
130 Tag = 2,
131 Override = 3
132};
133
145
146// ---------------------------------------------------------------------------
147// Resolution
148// ---------------------------------------------------------------------------
149
155ResolvedInfil resolveInfil(const MeshResult &mesh, int tri);
156
158InfilRow starDefault(const MeshResult &mesh);
159
161int indexOfDefault(const MeshResult &mesh, const QString &tag);
162
163// ---------------------------------------------------------------------------
164// Method ↔ parameter masks
165// ---------------------------------------------------------------------------
166
173bool infilUsesParam(InfilMethod method, int slot);
174
177
180QString infilParamLabel(InfilMethod method, int slot);
181
188QByteArray infilParamKey(InfilMethod method, int slot);
189
192int infilSlotForKey(InfilMethod method, const QByteArray &key);
193
196const QVector<QByteArray> &infilParamKeys();
197
198// ---------------------------------------------------------------------------
199// Tokens (must match the engine exactly)
200// ---------------------------------------------------------------------------
201
203InfilMethod infilMethodFromToken(const QString &token, bool *ok = nullptr);
205QStringList infilMethodLabels();
206
207QString infilDestToken(InfilDest d);
208InfilDest infilDestFromToken(const QString &token, bool *ok = nullptr);
209QString infilDestLabel(InfilDest d);
210QStringList infilDestLabels();
211
220QString infilDestHint(InfilDest d);
221
222// ---------------------------------------------------------------------------
223// Classified-lookup tables (GUI plan §3.4(a))
224// ---------------------------------------------------------------------------
225
229{
230 QString key1;
231 QString key2;
233};
234
238{
239 QString name;
240 bool twoKey = false;
241 QString key1Label;
242 QString key2Label;
243 QVector<InfilLookupEntry> entries;
245
247 InfilRow lookup(const QString &k1, const QString &k2, bool *matched = nullptr) const;
248};
249
252bool saveLookupTableCsv(const InfilLookupTable &table, const QString &path, QString *err);
253bool loadLookupTableCsv(InfilLookupTable *table, const QString &path, QString *err);
254
255} // namespace mesh
256
257#endif // OPENSWMMVIS_MESHINFIL_H
const char * token
Definition diagramspec.cpp:20
bool ok
Definition inpmeshwriter.cpp:575
QString err
Definition inpmeshwriter.cpp:575
MaskMode m
Definition maskspec.cpp:18
Mesh2DInterp method
Definition mesh2dresultsexport.cpp:543
const char * key
Definition meshcellparams.cpp:24
QString tag
r.tag or inherited from a dropped RegionMarker.
Definition meshgenerator.cpp:167
Definition meshcommands.h:302
QString infilDestHint(InfilDest d)
A one-sentence tooltip for destination d: where the water goes and what the choice needs.
Definition meshinfil.cpp:356
int infilParamCount(InfilMethod method)
Number of meaningful positional parameters for method.
Definition meshinfil.cpp:147
ResolvedInfil resolveInfil(const MeshResult &mesh, int tri)
Resolve one triangle's infiltration per engine D-I3 precedence: ‘override > tag row > ’*' row > none`...
Definition meshinfil.cpp:93
bool loadLookupTableCsv(InfilLookupTable *table, const QString &path, QString *err)
Definition meshinfil.cpp:505
InfilDest
Definition meshinfil.h:72
@ Aquifer2D
G1: recharges the integrated two-zone kernel.
@ SubcatchAquifer
U3: recharges the containing subcatchment's aquifer.
@ Lost
Leaves the model.
int indexOfDefault(const MeshResult &mesh, const QString &tag)
Index of tag in MeshResult::infilDefaults, or -1.
Definition meshinfil.cpp:69
InfilRow starDefault(const MeshResult &mesh)
Convenience: the '*' row from mesh, or a None row when absent.
Definition meshinfil.cpp:76
int infilSlotForKey(InfilMethod method, const QByteArray &key)
Inverse of infilParamKey(): maps a registry key to the positional slot it occupies under method,...
Definition meshinfil.cpp:227
InfilMethod
Definition meshinfil.h:61
QString infilMethodLabel(InfilMethod m)
Translated UI label.
Definition meshinfil.cpp:292
QString infilDestToken(InfilDest d)
"LOST", …
Definition meshinfil.cpp:314
InfilMethod infilMethodFromToken(const QString &token, bool *ok=nullptr)
Definition meshinfil.cpp:270
QString infilMethodToken(InfilMethod m)
"HORTON", "CURVE_NUMBER", "NONE", …
Definition meshinfil.cpp:256
constexpr int kInfilMaxParams
Definition meshinfil.h:79
QString infilParamLabel(InfilMethod method, int slot)
Display label for positional slot slot under method, e.g. ("Horton", 0) → "Max Rate (f0)"....
Definition meshinfil.cpp:163
QStringList infilMethodLabels()
For EnumComboDelegate, in enum order.
Definition meshinfil.cpp:306
QByteArray infilParamKey(InfilMethod method, int slot)
Registry key for positional slot slot under method, e.g. "infil.f0". Empty when unused.
Definition meshinfil.cpp:193
const QVector< QByteArray > & infilParamKeys()
Every named parameter key, in registration order. The attribute table and the assign dialog iterate t...
Definition meshinfil.cpp:235
InfilProvenance
Definition meshinfil.h:127
@ Star
From the '*' default row.
@ None
No model resolves for this cell.
@ Override
From a per-cell override.
@ Tag
From a tag default row.
QString infilDestLabel(InfilDest d)
Definition meshinfil.cpp:338
QStringList infilDestLabels()
Definition meshinfil.cpp:348
InfilDest infilDestFromToken(const QString &token, bool *ok=nullptr)
Definition meshinfil.cpp:324
bool saveLookupTableCsv(const InfilLookupTable &table, const QString &path, QString *err)
CSV round-trip. Column order: key1[,key2],method,p0,p1,p2,p3,p4,dest, # comments, header row optional...
Definition meshinfil.cpp:458
bool infilUsesParam(InfilMethod method, int slot)
True when method uses positional slot slot.
Definition meshinfil.cpp:129
int path
Definition pslgminsize.cpp:234
One [2D_INFILTRATION_DEFAULTS] row. tag == "*" is the mesh-wide fallback and may appear anywhere in t...
Definition meshinfil.h:111
InfilRow row
Definition meshinfil.h:113
QString tag
Definition meshinfil.h:112
One row of a classified lookup: a key (or key pair, for the Curve-Number landuse×HSG case) mapping to...
Definition meshinfil.h:229
InfilRow row
Definition meshinfil.h:232
QString key2
Empty for single-key lookups.
Definition meshinfil.h:231
QString key1
Definition meshinfil.h:230
An editable, reusable classified lookup table. Saved/loaded as CSV so an agency's standard table trav...
Definition meshinfil.h:238
QString key2Label
Definition meshinfil.h:242
bool twoKey
Definition meshinfil.h:240
QVector< InfilLookupEntry > entries
Definition meshinfil.h:243
QString key1Label
Definition meshinfil.h:241
InfilRow fallback
Applied to unmatched keys.
Definition meshinfil.h:244
InfilRow lookup(const QString &k1, const QString &k2, bool *matched=nullptr) const
Definition meshinfil.cpp:395
QString name
Definition meshinfil.h:239
[2D_INFILTRATION_OPTIONS].
Definition meshinfil.h:118
double infilStep
Definition meshinfil.h:121
One infiltration specification: method + positional parameters + destination.
Definition meshinfil.h:98
InfilMethod method
Definition meshinfil.h:99
bool operator==(const InfilRow &o) const
Definition meshinfil.cpp:57
bool operator!=(const InfilRow &o) const
Definition meshinfil.h:105
double p[kInfilMaxParams]
Definition meshinfil.h:100
InfilDest dest
Definition meshinfil.h:101
bool isNone() const
Definition meshinfil.h:103
Result of resolving one triangle's infiltration.
Definition meshinfil.h:136
InfilProvenance provenance
Definition meshinfil.h:138
InfilRow row
Definition meshinfil.h:137
bool isOverride() const
Definition meshinfil.h:141
bool isInherited() const
Definition meshinfil.h:142
QString sourceTag
Tag that supplied it (Tag/Star only)
Definition meshinfil.h:139