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
meshstagecache.h
Go to the documentation of this file.
1
27#ifndef OPENSWMMVIS_MESH_MESHSTAGECACHE_H
28#define OPENSWMMVIS_MESH_MESHSTAGECACHE_H
29
30#include "mesh/dtmthinner.h"
31
32#include <QByteArray>
33#include <QLoggingCategory>
34#include <QPointF>
35#include <QPolygonF>
36#include <QRectF>
37#include <QString>
38#include <QVector>
39
40// Opt-in perf/diagnostic chatter for the mesh pipeline:
41// QT_LOGGING_RULES="openswmm.mesh.perf.debug=true" (cache lines are qCInfo).
42Q_DECLARE_LOGGING_CATEGORY(lcMeshPerf)
43
44namespace mesh {
45
47{
48public:
50 explicit MeshStageCache(const QString &projectInpPath);
51
52 [[nodiscard]] bool isUsable() const;
53
56 {
57 QString absPath;
58 qint64 mtimeMs = 0;
59 qint64 sizeBytes = 0;
60 };
61
62 // ── Stage A payload: prepared PSLG boundary ──────────────────────
64 {
65 QVector<QPolygonF> domains;
66 QVector<QVector<QPointF>> holeRings;
67 QVector<QPointF> holeSeeds;
68 QVector<bool> holeValid;
69 qint32 skippedRings = 0;
70 };
71
72 // ── Stage B payload: terrain candidates (DTM CRS, pre-filter) ────
74 {
75 QVector<QPointF> xyDtm;
76 QVector<double> z;
77 };
78
85 static QByteArray boundaryKey(const FileIdentity &src,
86 const QByteArray &subcatchHash,
87 const QString &layerName,
88 const QString &boundaryCRSWkt,
89 const QString &meshCRSWkt,
90 double simplifyEps,
91 double maxBoundaryEdgeLen,
92 double minCellSize = 0.0,
93 bool minSizeEnforce = false);
94
98 static QByteArray terrainKey(const FileIdentity &dem, int band,
99 const DTMThinnerOptions &opts,
100 bool doThinning,
101 const QRectF &dtmBbox);
102
103 bool loadBoundary(const QByteArray &key, BoundaryPrep *out) const;
104 bool storeBoundary(const QByteArray &key, const BoundaryPrep &v) const;
105 bool loadTerrain(const QByteArray &key, TerrainPoints *out) const;
106 bool storeTerrain(const QByteArray &key, const TerrainPoints &v) const;
107
109 void prune(int keepPerStage = 8) const;
110
111 [[nodiscard]] QString dir() const { return m_dir; }
112
113private:
114 static constexpr quint32 kMagic = 0x4D435348; // "MCSH"
115 // Salted into every cache key AND written into every payload header —
116 // bumping it invalidates all entries at once. MUST be bumped when
117 // DTMThinner's banded-thinning geometry constants change
118 // (kBytesPerGridPoint, kMaxGridBytesDefault, kMaxThinningHalo in
119 // dtmthinner.{h,cpp}): they determine multi-band tiling and therefore
120 // the terrain-point OUTPUT for banded configurations.
121 static constexpr quint16 kFormatVersion = 1;
122
123 [[nodiscard]] QString entryPath(char stage, const QByteArray &key) const;
124
125 QString m_dir;
126};
127
128} // namespace mesh
129
130#endif // OPENSWMMVIS_MESH_MESHSTAGECACHE_H
Definition meshstagecache.h:47
QString dir() const
Definition meshstagecache.h:111
void prune(int keepPerStage=8) const
Definition meshstagecache.cpp:193
bool storeBoundary(const QByteArray &key, const BoundaryPrep &v) const
Definition meshstagecache.cpp:145
static QByteArray boundaryKey(const FileIdentity &src, const QByteArray &subcatchHash, const QString &layerName, const QString &boundaryCRSWkt, const QString &meshCRSWkt, double simplifyEps, double maxBoundaryEdgeLen, double minCellSize=0.0, bool minSizeEnforce=false)
Definition meshstagecache.cpp:60
static QByteArray terrainKey(const FileIdentity &dem, int band, const DTMThinnerOptions &opts, bool doThinning, const QRectF &dtmBbox)
Definition meshstagecache.cpp:88
bool isUsable() const
Definition meshstagecache.cpp:45
bool loadBoundary(const QByteArray &key, BoundaryPrep *out) const
Definition meshstagecache.cpp:128
bool storeTerrain(const QByteArray &key, const TerrainPoints &v) const
Definition meshstagecache.cpp:177
bool loadTerrain(const QByteArray &key, TerrainPoints *out) const
Definition meshstagecache.cpp:161
const char * key
Definition meshcellparams.cpp:24
Definition meshcommands.h:302
int src
index into the caller's vector; -1 = new
Definition pslgminsize.cpp:152
QVector< int > v
pool vertex indices
Definition pslgminsize.cpp:159
Parameters for the normal-deviation terrain thinning.
Definition dtmthinner.h:93
Definition meshstagecache.h:64
qint32 skippedRings
Definition meshstagecache.h:69
QVector< bool > holeValid
parallel: false → skip ring
Definition meshstagecache.h:68
QVector< QPolygonF > domains
simplified+densified exteriors
Definition meshstagecache.h:65
QVector< QPointF > holeSeeds
parallel: interior seed per ring
Definition meshstagecache.h:67
QVector< QVector< QPointF > > holeRings
prepared rings (ALL, in order)
Definition meshstagecache.h:66
Definition meshstagecache.h:56
QString absPath
Definition meshstagecache.h:57
qint64 sizeBytes
Definition meshstagecache.h:59
qint64 mtimeMs
Definition meshstagecache.h:58
Definition meshstagecache.h:74
QVector< QPointF > xyDtm
Definition meshstagecache.h:75
QVector< double > z
Definition meshstagecache.h:76