Loading...
Searching...
No Matches
cellplanner.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2#pragma once
3#include "meshquadregion.h"
4#include "meshpatch.h"
5#include <functional>
6
7namespace mesh
8{
36
61 double terrainTolerance = 0;
64 std::function<double(const QRectF &)> terrainToleranceForFootprint;
67 std::function<double(const QRectF &)> maximumSize;
70 std::function<double(double, double)> elevationAt;
74 std::function<double(const QPointF *, const double *)> terrainBound;
76 std::function<bool()> cancelled;
77};
78
88 bool ok = false, repairable = false, cancelled = false;
89 QString reason;
90};
91
105 bool allowQuads = true;
107 double defaultSize = 1;
117 quint64 maximumCells = 20000000, maximumPatchCells = 250000;
123 quint64 maximumWorkspaceBytes = quint64(2) << 30, workBudget = 0;
124 // Previous bounded conformity retry found this candidate unsafe.
126 std::function<bool(const QPolygonF &)> excluded;
127};
128
138 QVector<QPolygonF> domains, holes;
140 QVector<QVector<QPointF>> lines;
142 QVector<QPointF> pins;
144 QVector<PatchMesh> fixedPatches;
145};
146
147struct QuadPlan {
154 bool ok = false, cancelled = false, resourceLimited = false;
155 QString error;
157 QVector<PatchMesh> patches;
158 QVector<int> patchRegions;
159 QVector<PatchDecision> decisions;
166 quint64 sharedSides = 0, workUsed = 0, plannedCells = 0;
167};
168// Plan all region patches together before CDT construction. Full shared sides
169// use one exact station sequence; opposite/shared counts are solved jointly.
170// Authored vertices and indexed source junctions are retained. Unknown/infeasible
171// preferred candidates use triangles; a required failure refuses the whole plan.
194QuadPlan planQuadRegions(const QVector<QuadRegion> &, const QuadPlanningGeometry &,
195 const QuadPlanningOptions & = {});
202 int first = -1, second = -1;
207 double firstSize = 0, secondSize = 0;
208};
209
215 bool ok = false, cancelled = false;
216 QString error;
221 quint64 sharedFaces = 0, violations = 0;
222 double largestRatio = 1;
224 QVector<PatchInterfaceConflict> examples;
225};
226// Compact independent incidence/ratio check restricted to actual patch edges.
227// Ordinary triangles are scanned once; storage grows with patch perimeter.
246PatchInterfaceReport auditPatchInterfaces(const MeshResult &, const QVector<MeshEdge> &,
247 double maximumRatio,
248 const std::function<bool()> &cancelled = {},
249 int maximumExamples = 64);
250}
Structured quad patches (workplans/TRI_QUAD_MESHING_PLAN_2026-09-06.md §3.2, phase G3).
PSLG quad regions (workplans/QUAD_MESHING_REDESIGN_PLAN_2026-09-06.md §3, §4.1): closed polygons insi...
The Qt-facing MeshKit API (meshkit::core_qt, meshkit::model_qt, meshkit::io_qt): mesh value types and...
PatchDisposition
Final outcome of one quad region in unified cell planning.
Definition cellplanner.h:19
@ RequiredFailure
A required region could not be planned; the whole plan fails.
Definition cellplanner.h:19
@ Accepted
The mapped patch passed every check without repair.
Definition cellplanner.h:19
@ Repaired
The mapped patch passed after its station counts were refined.
Definition cellplanner.h:19
@ Triangles
No patch is delivered; the region is meshed with triangles.
Definition cellplanner.h:19
QuadPlan planQuadRegions(const QVector< QuadRegion > &, const QuadPlanningGeometry &, const QuadPlanningOptions &={})
Plan mapped quad patches for all regions jointly, before CDT construction.
Definition cellplanner.cpp:7
PatchAssessment assessPlannedPatch(const PatchMesh &, const PatchLimits &)
Check a generated mapped patch cell by cell against acceptance limits.
Definition cellplanner.cpp:6
PatchInterfaceReport auditPatchInterfaces(const MeshResult &, const QVector< MeshEdge > &, double maximumRatio, const std::function< bool()> &cancelled={}, int maximumExamples=64)
Measure nominal-size ratios across delivered patch interface edges.
Definition cellplanner.cpp:8
Result of MeshGenerator::generate.
Definition meshresult.h:203
Result of assessPlannedPatch().
Definition cellplanner.h:79
QString reason
English reason for the first failure; empty when ok.
Definition cellplanner.h:89
bool cancelled
PatchLimits::cancelled returned true.
Definition cellplanner.h:88
bool ok
Every cell met every limit.
Definition cellplanner.h:88
bool repairable
When ok is false: finer stations may fix the failure (angle, aspect, directional spacing,...
Definition cellplanner.h:88
Per-region planning record explaining the disposition chosen by planQuadRegions().
Definition cellplanner.h:21
QString source
Region tag, or "region:<i>" with the zero-based index when the tag is empty.
Definition cellplanner.h:27
QString reason
English explanation: the acceptance note, the refusal or priority reason, or the last repairable fail...
Definition cellplanner.h:27
int repairRounds
Station-doubling rounds the delivered patch needed; 0 otherwise.
Definition cellplanner.h:34
quint64 cells
n x m cell count at the patch's last successful assessment; 0 if none passed.
Definition cellplanner.h:33
PatchDisposition disposition
Final outcome.
Definition cellplanner.h:30
int region
Zero-based index into the planned regions; -1 when not assigned.
Definition cellplanner.h:28
bool required
QuadRegion::requireMapped or directionalSpacing was set.
Definition cellplanner.h:29
One interface face whose nominal-size ratio exceeds the limit.
Definition cellplanner.h:197
double firstSize
Nominal size of cell first (XY length).
Definition cellplanner.h:207
int second
Higher MeshResult::triangles index of the two incident cells.
Definition cellplanner.h:202
int first
Lower MeshResult::triangles index of the two incident cells.
Definition cellplanner.h:202
double secondSize
Nominal size of cell second (XY length).
Definition cellplanner.h:207
Result of auditPatchInterfaces().
Definition cellplanner.h:210
QVector< PatchInterfaceConflict > examples
Up to maximumExamples violations, sorted by cell indices.
Definition cellplanner.h:224
QString error
English reason when ok is false; empty otherwise.
Definition cellplanner.h:216
bool cancelled
Cancellation was observed; ok is false.
Definition cellplanner.h:215
quint64 violations
Shared faces whose size ratio exceeds the limit.
Definition cellplanner.h:221
bool ok
The audit completed on valid input; violations may still be present.
Definition cellplanner.h:215
quint64 sharedFaces
Interface edges with exactly two incident cells.
Definition cellplanner.h:221
double largestRatio
Largest size ratio over shared faces; 1 when none.
Definition cellplanner.h:222
Acceptance limits for one mapped patch, checked cell by cell by assessPlannedPatch().
Definition cellplanner.h:43
std::function< double(const QRectF &)> maximumSize
Optional size cap for a cell's XY bounding box, compared with sqrt(cell area); 0 means no cap,...
Definition cellplanner.h:67
double minimumAngleDegrees
Smallest allowed interior angle in degrees, in [0, 180); 0 disables.
Definition cellplanner.h:50
std::function< double(double, double)> elevationAt
Terrain elevation at (x, y), sampled at the quad corners; required by terrain checks.
Definition cellplanner.h:70
double terrainTolerance
Constant terrain error tolerance, used when terrainToleranceForFootprint is unset.
Definition cellplanner.h:61
double alongSize
Limit on the mean length of the opposite edge pair best aligned with alongAngleDegrees; 0 disables th...
Definition cellplanner.h:58
double maximumAspect
Largest allowed quad aspect ratio as computed by quadQuality(); 0 disables.
Definition cellplanner.h:50
double minimumEdge
Shortest allowed cell edge; 0 disables.
Definition cellplanner.h:50
std::function< double(const QRectF &)> terrainToleranceForFootprint
Optional tolerance for a cell's XY bounding box; replaces terrainTolerance and must return a finite p...
Definition cellplanner.h:64
double alongAngleDegrees
Undirected along axis in degrees counterclockwise from +x; must be finite.
Definition cellplanner.h:58
double acrossSize
Limit on the mean length of the other opposite edge pair; 0 disables.
Definition cellplanner.h:58
std::function< bool()> cancelled
Optional cancellation poll; planQuadRegions() also uses it as its cancellation source.
Definition cellplanner.h:76
std::function< double(const QPointF *, const double *)> terrainBound
Certified terrain error bound of the planar triangle through three XY points and heights (arrays vali...
Definition cellplanner.h:74
A generated patch in local indices.
Definition meshpatch.h:88
Result of planQuadRegions().
Definition cellplanner.h:147
QVector< int > patchRegions
Zero-based region index of each entry in patches.
Definition cellplanner.h:158
bool resourceLimited
A work, workspace or cell budget stopped the plan or refused a required region.
Definition cellplanner.h:154
QVector< PatchDecision > decisions
One decision per input region, in input order.
Definition cellplanner.h:159
quint64 workUsed
Work units consumed.
Definition cellplanner.h:166
bool ok
Planning finished and every required region has a patch.
Definition cellplanner.h:154
QVector< PatchMesh > patches
Delivered patches with CCW quads, required regions first, then in region order.
Definition cellplanner.h:157
bool cancelled
Cancellation was observed; ok is false.
Definition cellplanner.h:154
quint64 plannedCells
Total quads over patches.
Definition cellplanner.h:166
quint64 sharedSides
Region sides that matched an already registered identical side path.
Definition cellplanner.h:166
QString error
English reason when ok is false; empty on success.
Definition cellplanner.h:155
Source geometry that protects against planned patches, in the regions' XY frame.
Definition cellplanner.h:132
QVector< QVector< QPointF > > lines
Protected open polylines; they may run along a patch boundary but not enter or cross it.
Definition cellplanner.h:140
QVector< PatchMesh > fixedPatches
Existing patches; their boundaries (orderedPatchBoundary()) take priority like holes.
Definition cellplanner.h:144
QVector< QPolygonF > domains
Domain rings; a patch must lie inside one (tested at its first cell's centroid) and no domain edge ma...
Definition cellplanner.h:138
QVector< QPolygonF > holes
Hole rings; they take priority over any patch.
Definition cellplanner.h:138
QVector< QPointF > pins
Protected points; one inside or on a patch must coincide with a generated vertex.
Definition cellplanner.h:142
Settings and budgets for planQuadRegions().
Definition cellplanner.h:104
quint64 maximumWorkspaceBytes
Estimated limit for the source index, stations and planned cells (2 GiB by default); not a bound on t...
Definition cellplanner.h:123
quint64 maximumPatchCells
Cell limit for a single patch.
Definition cellplanner.h:117
double defaultSize
Spacing for regions without a positive QuadRegion::spacing; finite and positive.
Definition cellplanner.h:107
std::function< bool(const QPolygonF &)> excluded
Optional veto given a candidate's ordered patch boundary; returning true refuses it.
Definition cellplanner.h:126
bool allowQuads
False refuses all regions: global triangles-only priority.
Definition cellplanner.h:105
quint64 workBudget
Work-unit limit; 0 selects 512 per maximumCells plus 100,000.
Definition cellplanner.h:123
int maximumRepairRounds
Rounds that double station counts after repairable failures; valid range [0, 3].
Definition cellplanner.h:112
quint64 maximumCells
Cell budget over all planned patches; also bounds side subdivision counts.
Definition cellplanner.h:117
PatchLimits limits
Limits for every candidate patch; a region's aspectMax, isotropic spacing and directional spacing ove...
Definition cellplanner.h:110