Loading...
Searching...
No Matches
planning.hpp
Go to the documentation of this file.
1#include "meshkit/regions.hpp"
2#include "meshkit/patch.hpp"
4// SPDX-License-Identifier: Apache-2.0
5#pragma once
6#include <functional>
7
8namespace meshkit::plan
9{
22
44
74 double terrainTolerance = 0;
78 std::function<double(const Box2 &)> terrainToleranceForFootprint;
82 std::function<double(const Box2 &)> maximumSize;
85 std::function<double(double, double)> elevationAt;
91 std::function<double(const Point2 *, const double *)> terrainBound;
94 std::function<bool()> cancelled;
95};
96
106 bool ok = false, repairable = false, cancelled = false;
108};
109
128 bool allowQuads = true;
131 double defaultSize = 1;
145 std::uint64_t maximumCells = 20000000, maximumPatchCells = 250000;
152 std::uint64_t maximumWorkspaceBytes = std::uint64_t(2) << 30, workBudget = 0;
157 // Previous bounded conformity retry found this candidate unsafe.
158 std::function<bool(const Polygon &)> excluded;
159};
160
182
209
231// Plan all region patches together before CDT construction. Full shared sides
232// use one exact station sequence; opposite/shared counts are solved jointly.
233// Authored vertices and indexed source junctions are retained. Unknown/infeasible
234// preferred candidates use triangles; a required failure refuses the whole plan.
236 const QuadPlanningOptions & = {});
243 int first = -1, second = -1;
249 double firstSize = 0, secondSize = 0;
250};
251
269
289// Compact independent incidence/ratio check restricted to actual patch edges.
290// Ordinary triangles are scanned once; storage grows with patch perimeter.
292 double maximumRatio,
293 const std::function<bool()> &cancelled = {},
294 int maximumExamples = 64);
295}
Axis-aligned rectangle in the XY plane, stored as an origin corner and a signed size.
Definition geometry.hpp:167
Point or displacement vector in the horizontal (XY) plane.
Definition geometry.hpp:21
std::vector<T> with the QVector-style member names the CDT kernel and plan model use.
Definition storage.hpp:31
Point sequence in XY units used for polygon rings and polylines.
Definition planmodel.hpp:83
Owned byte string with the QString-style helpers used for tags and diagnostics.
Definition planmodel.hpp:21
Planning algorithms on standard containers: quad patch planning and placement, size fields,...
QuadPlan planQuadRegions(const Vector< QuadRegion > &, const QuadPlanningGeometry &, const QuadPlanningOptions &={})
Plan mapped quad patches for all regions jointly, before CDT construction.
Definition planning.cpp:320
PatchInterfaceReport auditPatchInterfaces(const MeshResult &, const Vector< MeshEdge > &, double maximumRatio, const std::function< bool()> &cancelled={}, int maximumExamples=64)
Check the size transition across delivered patch interface edges.
Definition planning.cpp:830
PatchAssessment assessPlannedPatch(const PatchMesh &, const PatchLimits &)
Check a mapped patch cell by cell against shape, size and terrain limits.
Definition planning.cpp:211
PatchDisposition
Outcome recorded for one quad region in a PatchDecision.
Definition planning.hpp:11
@ RequiredFailure
A required region could not be planned, so the whole plan was refused.
Definition planning.hpp:11
@ Accepted
Mapped patch accepted without any repair round.
Definition planning.hpp:11
@ Repaired
Mapped patch obtained after refinement: in a QuadPlan, accepted after at least one station-doubling r...
Definition planning.hpp:11
@ Triangles
No mapped patch is delivered and the region is left to triangles (the default).
Definition planning.hpp:11
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...
Mesh as read by the native audits: vertices, cells, marked edges and a status.
Definition planmodel.hpp:279
Result of assessPlannedPatch().
Definition planning.hpp:97
bool ok
True when every cell passed every enabled check.
Definition planning.hpp:106
bool cancelled
True when PatchLimits::cancelled stopped the assessment (ok is then false).
Definition planning.hpp:106
bool repairable
True when more stations could cure the failure: a shape, directional spacing, footprint size or terra...
Definition planning.hpp:106
Text reason
Failure description; empty when ok is true.
Definition planning.hpp:107
Per-region record of what was decided about a mapped patch and why.
Definition planning.hpp:24
std::uint64_t cells
Cells (n x m) in the region's patch.
Definition planning.hpp:39
Text source
Region label.
Definition planning.hpp:31
int region
0-based index of the source region; -1 when unassigned.
Definition planning.hpp:32
int repairRounds
Repair rounds or retries recorded.
Definition planning.hpp:42
PatchDisposition disposition
Outcome; Triangles by default.
Definition planning.hpp:36
bool required
True for a hard requirement (QuadRegion::requireMapped or directionalSpacing), whose failure refuses ...
Definition planning.hpp:35
Text reason
Explanation of the latest refusal, repair or acceptance; may be empty when planning stopped before th...
Definition planning.hpp:31
One patch interface edge whose two cells differ in size by more than allowed.
Definition planning.hpp:238
int second
Index into MeshResult::triangles of the other cell on the edge.
Definition planning.hpp:243
int first
Index into MeshResult::triangles of the lower-numbered cell on the edge.
Definition planning.hpp:243
double firstSize
Nominal size of first, XY units: sqrt(area) for a quad, the side of the equilateral triangle of equal...
Definition planning.hpp:249
double secondSize
Nominal size of second, same measure.
Definition planning.hpp:249
Result of auditPatchInterfaces().
Definition planning.hpp:252
std::uint64_t sharedFaces
Listed edges with exactly two incident cells; edges with one cell are skipped.
Definition planning.hpp:263
bool ok
True when the audit completed; size violations do not clear it (see violations).
Definition planning.hpp:257
Vector< PatchInterfaceConflict > examples
Up to maximumExamples (clamped to [0, 1000]) violations with the smallest (first, second) cell indice...
Definition planning.hpp:267
bool cancelled
True when the cancellation callback stopped the audit.
Definition planning.hpp:257
Text error
Why ok is false; empty on success.
Definition planning.hpp:258
double largestRatio
Largest size ratio over shared edges (>= 1); 1 when none.
Definition planning.hpp:264
std::uint64_t violations
Shared edges whose size ratio exceeds the allowed ratio (relative tolerance 1e-9).
Definition planning.hpp:263
Acceptance limits and callbacks for one mapped patch; see assessPlannedPatch().
Definition planning.hpp:51
double minimumEdge
Shortest permitted cell edge, XY units; 0 disables.
Definition planning.hpp:60
std::function< double(double, double)> elevationAt
Ground elevation, Z units, at (x, y) in XY units.
Definition planning.hpp:85
double alongSize
Largest mean length, XY units, of the opposite cell sides most aligned with alongAngleDegrees.
Definition planning.hpp:71
double alongAngleDegrees
Along-axis direction, degrees counterclockwise from +x.
Definition planning.hpp:71
std::function< double(const Box2 &)> terrainToleranceForFootprint
Tolerance, Z units, for a cell's XY bounding box.
Definition planning.hpp:78
std::function< bool()> cancelled
Polled before the first cell and then every 1024 cells; returning true stops with PatchAssessment::ca...
Definition planning.hpp:94
std::function< double(const Box2 &)> maximumSize
Maximum cell size, XY units, for an XY bounding box, compared with sqrt(cell area).
Definition planning.hpp:82
double acrossSize
Largest mean length, XY units, of the other pair of opposite cell sides; see alongSize.
Definition planning.hpp:71
std::function< double(const Point2 *, const double *)> terrainBound
Certified maximum terrain error, Z units, of the planar triangle through three points.
Definition planning.hpp:91
double minimumAngleDegrees
Smallest permitted interior angle (quadQuality() minAngleDeg), degrees; must be < 180,...
Definition planning.hpp:60
double terrainTolerance
Constant terrain error tolerance, Z units, used when terrainToleranceForFootprint is empty.
Definition planning.hpp:74
double maximumAspect
Largest permitted quadQuality() aspect; 0 disables.
Definition planning.hpp:60
A generated patch in local indices.
Definition patch.hpp:94
Result of planQuadRegions(); patches are delivered only when ok is true.
Definition planning.hpp:183
std::uint64_t plannedCells
Total cells in patches; 0 unless ok.
Definition planning.hpp:207
Text error
Why ok is false; empty on success.
Definition planning.hpp:192
std::uint64_t sharedSides
Region sides found identical (same coordinates, either direction) to a side of an earlier region.
Definition planning.hpp:207
bool ok
True when planning completed, even if every region fell back to triangles.
Definition planning.hpp:191
Vector< PatchDecision > decisions
One decision per input region, indexed by region; kept, possibly incomplete, when ok is false.
Definition planning.hpp:199
bool cancelled
True when PatchLimits::cancelled stopped planning.
Definition planning.hpp:191
Vector< int > patchRegions
Region index of each entry of patches (parallel array).
Definition planning.hpp:196
std::uint64_t workUsed
Work units consumed; compare QuadPlanningOptions::workBudget.
Definition planning.hpp:207
bool resourceLimited
True when a work, workspace, cell or station budget stopped planning, including a required region ref...
Definition planning.hpp:191
Vector< PatchMesh > patches
Delivered patches with CCW cells, required regions first and then by region index; empty unless ok.
Definition planning.hpp:195
Source geometry that protects areas from mapped patches; XY units, finite coordinates.
Definition planning.hpp:168
Vector< Polygon > domains
Domain rings, closing vertex optional; a patch must lie inside one.
Definition planning.hpp:173
Vector< Vector< Point2 > > lines
Open protected polylines; patches may not cross or enclose.
Definition planning.hpp:174
Vector< PatchMesh > fixedPatches
Existing patches whose validated boundaries block new ones; an invalid fixed patch contributes no bou...
Definition planning.hpp:180
Vector< Point2 > pins
Protected points.
Definition planning.hpp:177
Vector< Polygon > holes
Hole rings, closing vertex optional; a patch may not lie inside one.
Definition planning.hpp:173
Settings, budgets and patch limits for planQuadRegions().
Definition planning.hpp:125
std::uint64_t maximumWorkspaceBytes
Estimated planning memory budget in bytes (about 160 per source segment, 32 per station and 192 per p...
Definition planning.hpp:152
bool allowQuads
False forces triangles everywhere: optional regions fall back and any required region fails the plan.
Definition planning.hpp:128
int maximumRepairRounds
Rounds (0..3) in which a repairable failure doubles the station counts of the candidate's sides; a va...
Definition planning.hpp:139
PatchLimits limits
Base patch limits.
Definition planning.hpp:136
std::uint64_t maximumCells
Cell budget for all planned patches together.
Definition planning.hpp:145
std::uint64_t maximumPatchCells
Cell budget for a single patch.
Definition planning.hpp:145
std::uint64_t workBudget
Maximum work units; 0 means maximumCells * 512 + 100000.
Definition planning.hpp:152
double defaultSize
Target spacing, XY units, for regions whose QuadRegion::spacing is not > 0; must be finite and > 0.
Definition planning.hpp:131
std::function< bool(const Polygon &)> excluded
Optional filter called with each candidate's CCW boundary ring (no repeated closing vertex); returnin...
Definition planning.hpp:158