26#ifndef OPENSWMMVIS_MESH_MESHGENERATOR_H
27#define OPENSWMMVIS_MESH_MESHGENERATOR_H
106 std::function<void(
const QString &)>
120 std::function<double(
const QPointF *,
const double *, QPointF *)>
terrainError;
121 std::function<double(
const QPointF *,
const double *)>
362 void setDomain(
const QPolygonF &outerBoundary);
377 void setDomains(
const QVector<QPolygonF> &outerBoundaries);
389 void addDomain(
const QPolygonF &outerBoundary);
431 void addHole(
const QPointF &interiorPointInsideHole);
505 return m_acceptedTerrainLines;
534 return m_quadReports;
554 [[nodiscard]]
const QVector<PatchDecision> &
cellPlanDecisions()
const {
return m_patchDecisions; }
654 QVector<QPolygonF> m_domains;
655 QVector<ConstraintSegment> m_segments;
656 QVector<SteinerPoint> m_steiners;
657 QVector<QPointF> m_holes;
658 QVector<RegionMarker> m_regions;
659 QVector<PatchMesh> m_patches;
660 QVector<QuadRegion> m_quadRegions;
661 QVector<QVector<QPointF>> m_terrainLines;
662 mutable QVector<QVector<QPointF>> m_acceptedTerrainLines;
663 mutable QVector<QuadRegionReport> m_quadReports;
664 mutable QVector<PatchDecision> m_patchDecisions;
666 mutable QSet<QPair<qint64, qint64>> m_leakedPatches;
667 mutable QSet<int> m_disabledPlanRegions;
668 mutable QHash<int,int> m_planRefinements;
669 mutable QString m_planRetryReason;
682 [[nodiscard]]
MeshResult generateOnce(QPair<qint64, qint64> *leaked)
const;
689 mutable QHash<int, QString> m_vertexTagByMarker;
690 mutable QHash<int, QString> m_edgeTagByMarker;
691 mutable QHash<int, QString> m_triangleTagByRegionId;
void addRegion(const RegionMarker ®ion)
Append a copied region-flood tagging seed and attribute metadata.
Definition meshgenerator.cpp:512
QVector< QVector< QPointF > > previewTerrainBreaklines() const
Compute early terrain-line preparation against accumulated geometry before generated strips.
Definition meshgenerator.cpp:2004
QString tagForEdgeMarker(int marker) const
Copy the last generation attempt's constraint-marker tag value.
Definition meshgenerator.cpp:542
void addPatch(const PatchMesh &patch)
Append an owned local-index quad patch for later validated constrained stitching.
Definition meshgenerator.cpp:516
void addHole(const QPointF &interiorPointInsideHole)
Append a copied interior seed for a constraint-bounded excluded component.
Definition meshgenerator.cpp:508
void addDomain(const QPolygonF &outerBoundary)
Append one copied outer boundary to current domain components.
Definition meshgenerator.cpp:492
QString tagForVertexMarker(int marker) const
Copy the last generation attempt's marker-to-vertex-tag lookup value.
Definition meshgenerator.cpp:537
QSet< QPair< int, int > > quadRegionMergeLocks(const MeshResult &mesh) const
Return the compatibility placeholder for triangle-pairing locks.
Definition meshgenerator.cpp:547
void setRefineHook(const RefineHook &hook)
Copy synchronous sizing, elevation, error, progress and cancellation callbacks.
Definition meshgenerator.cpp:532
MeshGenerator()=default
Construct an empty geometry accumulator with default options and no callbacks.
MeshResult generate() const
Generate an owned mixed mesh from copied geometry with local constraints, refinement and stitching.
Definition meshgenerator.cpp:2040
void setTerrainBreaklines(const QVector< QVector< QPointF > > &lines)
Replace owned dense noncoupling terrain line inputs.
Definition meshgenerator.cpp:524
const QVector< QuadRegionReport > & quadRegionReports() const
Borrow one outcome report per configured quad region from the last generation attempt.
Definition meshgenerator.h:532
void setDomains(const QVector< QPolygonF > &outerBoundaries)
Replace domain-ring storage with copied outer polygons.
Definition meshgenerator.cpp:487
const QVector< QVector< QPointF > > & acceptedTerrainBreaklines() const
Borrow terrain lines retained by the most recent generation attempt.
Definition meshgenerator.h:503
void addSteinerPoint(const SteinerPoint &pt)
Append an owned mandatory point with marker/tag and optional sampled elevation metadata.
Definition meshgenerator.cpp:500
const GenerationStats & stats() const
Borrow counts and diagnostics from the most recent generation attempt.
Definition meshgenerator.h:545
void addConstraintSegment(const ConstraintSegment &seg)
Append an owned copy of a required constraint polyline and its marker/tag/strip request.
Definition meshgenerator.cpp:496
void setOptions(const GenerationOptions &opts)
Copy numeric/strategy settings for subsequent generation without running validation.
Definition meshgenerator.cpp:528
const QVector< PatchDecision > & cellPlanDecisions() const
Borrow the patch planning records of the most recent generation attempt.
Definition meshgenerator.h:554
void setDomain(const QPolygonF &outerBoundary)
Replace all domain rings with one copied boundary without changing other accumulated inputs.
Definition meshgenerator.cpp:481
void addQuadRegion(const QuadRegion ®ion)
Append a copied region ring, tag, optional spacing and requested quad strategy.
Definition meshgenerator.cpp:520
void reserveSteinerPoints(qsizetype additional)
Reserve total capacity for current plus additional mandatory points without changing count.
Definition meshgenerator.cpp:504
Unordered vertex-pair key shared by the quad pairing, cleanup and generator code (formerly in meshqua...
Structured quad patches (workplans/TRI_QUAD_MESHING_PLAN_2026-09-06.md §3.2, phase G3).
Quadrilateral quality metrics (workplans/QUAD_MESHING_REDESIGN_PLAN_2026-09-06.md §5).
PSLG quad regions (workplans/QUAD_MESHING_REDESIGN_PLAN_2026-09-06.md §3, §4.1): closed polygons insi...
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...
QuadRegionMode
Requested (or classified) cell strategy of a QuadRegion.
Definition meshquadregion.h:45
@ Auto
classifyQuadRegion() decides: Mapped → Submapped → Free.
Definition meshquadregion.h:46
CoarseningOrder
Order in which terrain coarsening tries to remove free vertices.
Definition terrainpolicy.hpp:10
A polyline that must appear as constrained edges in the mesh.
Definition meshgenerator.h:53
double stripWidth
Width of a swept quad strip along the line; 0 (default) = no strip.
Definition meshgenerator.h:64
int marker
Preserved on output edges.
Definition meshgenerator.h:55
QVector< QPointF > path
>= 2 points; consecutive pairs become constrained edges.
Definition meshgenerator.h:54
QString tag
Resolved later via the marker→tag lookup the caller maintains.
Definition meshgenerator.h:56
Quality knobs surfaced to the user dialog.
Definition meshgenerator.h:148
CoarseningOrder coarseningOrder
Order in which coarsening visits free vertices: LegacyFlatness by star flatness; ResolutionAware by n...
Definition meshgenerator.h:181
bool unifiedCellPlanning
Plan all quad regions jointly before triangulation, gate every patch and regenerate (at most three re...
Definition meshgenerator.h:217
double coarseningReferenceSize
XY-unit size ResolutionAware ordering uses where the target is 0 (unbounded).
Definition meshgenerator.h:188
bool diagnosticProvenance
Review harness only; no effect on geometry.
Definition meshgenerator.h:175
int maxCells
Resource ceiling; reported if reached.
Definition meshgenerator.h:166
int maximumSizingRepairInsertions
Cap on vertices the repair passes may insert, >= 0; reaching it (or 0) stops the repair and sets Gene...
Definition meshgenerator.h:233
double channelSpacing
Smallest spacing between distinct channel corridor vertices (lattice offsets and stations).
Definition meshgenerator.h:195
int sizingRepairPasses
Re-examination passes (0..3) of every live triangle against the size, footprint and adjacent-ratio bo...
Definition meshgenerator.h:233
double normalVerticalToXY
Factor turning elevation differences into XY units for ResolutionAware facet normals (vertical / hori...
Definition meshgenerator.h:188
double maxArea
0 = no global cap; else upper bound on triangle area.
Definition meshgenerator.h:149
bool quadsBetweenBreaklines
Two terrain break lines that face each other with lower ground between them become a bank-pair quad s...
Definition meshgenerator.h:198
int coarsenPasses
Bounded attempts to remove unnecessary free vertices; 0 = off.
Definition meshgenerator.h:176
double patchSnapEps
Snap radius (map units) used to match patch vertices against the output vertices.
Definition meshgenerator.h:202
double minimumRequiredEdge
Shortest permitted quad patch cell edge, XY units; 0 = no check.
Definition meshgenerator.h:221
bool latticeSeeding
Seed free vertices on hexagonal lattices graded by the size field before refinement,...
Definition meshgenerator.h:171
double maximumAdjacentRatio
Largest size ratio, sqrt of the area ratio, between neighbouring triangles, enforced by the sizing re...
Definition meshgenerator.h:226
bool allowQuads
Global cell-shape gate.
Definition meshgenerator.h:207
int smoothingPasses
Passes of non-degrading smoothing on free vertices after refinement (ConstrainedDelaunay::QualityOpti...
Definition meshgenerator.h:174
bool preserveConstraintCoordinates
Only exact junctions/crossings are joined.
Definition meshgenerator.h:208
double terrainMinLineLength
0 = four times minimum target size.
Definition meshgenerator.h:203
bool verifiedSizing
Also cap every triangle's area by its footprint: RefineHook::footprintMaximumSize over its bounding b...
Definition meshgenerator.h:213
bool prioritizeQuality
Worst angle buckets before ordinary size/error work.
Definition meshgenerator.h:165
double minAngleDeg
Every triangle's smallest angle reaches this (degrees), except in the wedge of two constraints meetin...
Definition meshgenerator.h:164
double minCellSize
Floor cell size h_min (map units): the lower clamp of the size function.
Definition meshgenerator.h:157
What the last generate() built (MeshGenerator::stats()).
Definition meshgenerator.h:248
int regionPatches
Quad regions meshed with aligned quads.
Definition meshgenerator.h:250
int coarsenAttempts
Removal attempts: active vertices taken from the coarsening queue.
Definition meshgenerator.h:290
int terrainInserted
Refinement vertices placed where a triangle's terrain error exceeded the tolerance.
Definition meshgenerator.h:264
int conduitStrips
Conduit quad strips placed.
Definition meshgenerator.h:251
int trianglesBelowAngle
Triangles under the minimum angle that the small-input-angle exemption does not explain: they rest on...
Definition meshgenerator.h:275
int plannedPatches
Unified-planning regions delivered as mapped patches (accepted or repaired).
Definition meshgenerator.h:326
int breaklineStrips
Quad strips between facing break lines.
Definition meshgenerator.h:252
int sizeInserted
Refinement vertices placed because a triangle exceeded a size bound (target size, footprint cap or ad...
Definition meshgenerator.h:264
int coarsenRemoved
Free vertices coarsening removed.
Definition meshgenerator.h:282
bool coarsenSkippedTerrain
True when terrain refinement was active without RefineHook::terrainErrorBound, so coarsening was skip...
Definition meshgenerator.h:301
int triangulationPasses
Generation attempts the last generate() made; > 1 means a patch or planning retry.
Definition meshgenerator.h:326
int refineInserted
Vertices the quality refinement added.
Definition meshgenerator.h:254
bool sizingRepairLimited
True when the repair stopped at GenerationOptions::maximumSizingRepairInsertions (or that cap was 0),...
Definition meshgenerator.h:317
int segmentSplits
Constrained subsegment splits during refinement (counted in refineInserted too).
Definition meshgenerator.h:264
bool refineCapped
Refinement stopped at its safety cap.
Definition meshgenerator.h:309
int stripsDropped
Strips that did not fit (logged; the feature stays triangles).
Definition meshgenerator.h:253
int coarsenRejectedAngle
Removals refused because a replacement triangle would break the minimum angle.
Definition meshgenerator.h:282
int triangleFallbacks
Unified-planning regions that requested quads but resolved to triangles.
Definition meshgenerator.h:326
int qualityInserted
Refinement vertices placed to raise a triangle's smallest angle.
Definition meshgenerator.h:264
int coarsenRejectedTerrain
Removals refused by the terrain checks (includes coarsenHeightRejects).
Definition meshgenerator.h:290
int coarsenRejectedEdge
Removals refused because a replacement triangle's shortest edge would be shorter than the shortest ed...
Definition meshgenerator.h:290
int sizingRepairPasses
Repair passes actually run, 0..3; a pass that inserts nothing ends the repair.
Definition meshgenerator.h:314
int terrainUnknown
Final-check triangles whose error or tolerance is not finite (coverage unverified).
Definition meshgenerator.h:270
int coarsenRejectedSize
Removals refused because a replacement triangle would exceed a size bound.
Definition meshgenerator.h:282
quint64 coarsenPriorityQueries
Target-size queries made to rank vertices (ResolutionAware order only; else 0).
Definition meshgenerator.h:307
int terrainUnresolved
Final-check triangles whose terrain error is still above the tolerance; 0 when the check is off (Refi...
Definition meshgenerator.h:270
int coarsenHeightRejects
Terrain refusals where the removed vertex's own height misses the new covering plane by more than the...
Definition meshgenerator.h:298
double maxTerrainError
Largest finite final-check terrain error, Z units.
Definition meshgenerator.h:271
int coarsenExactQueries
Replacement triangles that needed a RefineHook::terrainErrorBound call.
Definition meshgenerator.h:298
int sizingRepairInserted
Vertices the sizing repair passes inserted (GenerationOptions::sizingRepairPasses).
Definition meshgenerator.h:314
QJsonObject provenance
Vertex origins and shortest-edge associations before assembly.
Definition meshgenerator.h:249
int repairedPatches
Of plannedPatches, those that needed at least one repair round.
Definition meshgenerator.h:326
double coarsenSeconds
Wall-clock seconds spent in the coarsening stage.
Definition meshgenerator.h:302
quint64 coarsenQueuePeak
Largest number of entries the coarsening queue held.
Definition meshgenerator.h:307
int coarsenBoundAccepts
Replacement triangles certified by the propagated error bound, with no DEM query.
Definition meshgenerator.h:298
Result of MeshGenerator::generate.
Definition meshresult.h:203
A generated patch in local indices.
Definition meshpatch.h:88
A polygon in which quadrilateral cells are requested, with its spacing, shape and tagging policy.
Definition meshquadregion.h:61
Per-region outcome of generate() (MeshGenerator::quadRegionReports()).
Definition meshgenerator.h:237
double spacing
Size override inside the ring (0 = none).
Definition meshgenerator.h:243
QString message
Why the region has no quads, or a validation error; empty when clean.
Definition meshgenerator.h:244
bool accepted
Region was included in generation, not skipped.
Definition meshgenerator.h:242
int index
Region index in addQuadRegion() order.
Definition meshgenerator.h:238
QuadRegionMode requested
The region's QuadRegion::mode.
Definition meshgenerator.h:239
QuadRegionMode resolved
Mapped = aligned quads; TrianglesOnly = triangles inside the ring.
Definition meshgenerator.h:240
Cancellation, progress and graded sizing callbacks.
Definition meshgenerator.h:88
bool terrainFinalCheck
Measure every final triangle's terrain error at the end of refinement (QualityOptions::terrainFinalCh...
Definition meshgenerator.h:144
std::function< void(const QString &)> onDiagnostic
Per-job geometry/patch notes; no global logger.
Definition meshgenerator.h:107
std::function< double(double, double)> terrainElevationAt
Ground elevation (Z units) at a mesh XY coordinate; non-finite = unknown.
Definition meshgenerator.h:126
std::function< double(const QRectF &)> footprintMaximumSize
Verified sizing: bound over the full footprint.
Definition meshgenerator.h:98
std::function< double(const QRectF &)> terrainToleranceForFootprint
Tolerance (Z units) for a triangle's or patch cell's XY bounding box, replacing terrainTolerance per ...
Definition meshgenerator.h:135
double terrainTolerance
Terrain error tolerance in Z units; > 0 (with terrainError and terrainElevationAt) enables terrain re...
Definition meshgenerator.h:130
std::function< double(double x, double y)> elevationAt
Ground elevation at a mesh coordinate (NaN = unknown), for GenerationOptions::quadsBetweenBreaklines:...
Definition meshgenerator.h:113
std::function< double(const QPointF *, const double *, QPointF *)> terrainError
Surface error (Z units) of one triangle against the reference DEM: receives its three XY corners and ...
Definition meshgenerator.h:120
std::function< void(const GenerationProgress &)> onDetailedProgress
Typed progress at bounded checkpoints of quality refinement, called synchronously on the generating t...
Definition meshgenerator.h:105
std::function< bool()> isCancelled
Polled between stages and inside the long loops.
Definition meshgenerator.h:92
bool terrainWorstFirst
Insert terrain points worst error first once size and angle are met (ConstrainedDelaunay::QualityOpti...
Definition meshgenerator.h:140
std::function< double(double x, double y)> targetAreaAt
Maximum permitted triangle area at map coordinate (x, y); the target edge length is the side of the e...
Definition meshgenerator.h:97
std::function< void(qint64 count)> onProgress
Legacy callback: allocated vertex slots, including super/unused vertices; this is NOT a cell count.
Definition meshgenerator.h:101
std::function< double(const QPointF *, const double *)> terrainErrorBound
Certified residual and coverage for coarsening.
Definition meshgenerator.h:122
A region attribute — an interior seed point whose value propagates through the constrained Delaunay r...
Definition meshgenerator.h:80
QString tag
Convenience.
Definition meshgenerator.h:84
double maxArea
-1 = use global max area.
Definition meshgenerator.h:83
QPointF xy
Seed point inside the region (must be inside a sub-polygon).
Definition meshgenerator.h:81
double attribute
Region id; resolved via id→tag map.
Definition meshgenerator.h:82
A point that must appear as a vertex in the output mesh.
Definition meshgenerator.h:68
bool hasZ
If true, z is exact — skip DTM re-sampling in post-mesh step.
Definition meshgenerator.h:73
QString tag
Convenience copy (caller can resolve via marker, but stash here too).
Definition meshgenerator.h:71
int marker
Carries a tag id; resolved via marker→tag map.
Definition meshgenerator.h:70
QPointF xy
Location in the mesh XY frame; must be finite or generate() fails.
Definition meshgenerator.h:69
double z
Pre-sampled elevation when hasZ is true (e.g. from DTM thinner).
Definition meshgenerator.h:72
Counter snapshot passed to ConstrainedDelaunay::QualityOptions::onProgress during refineQuality().
Definition progress.hpp:14