Loading...
Searching...
No Matches
regions.hpp
Go to the documentation of this file.
24
25#ifndef MESHKIT_NATIVE_MESHQUADREGION_HPP
26#define MESHKIT_NATIVE_MESHQUADREGION_HPP
27
28namespace meshkit::plan
29{
30
39
42struct QuadRegion {
46 std::int32_t attribute = 0;
59 bool isBackground = false;
64 bool requireMapped = false;
65 bool automaticCandidate = false;
66 double spacing = 0.0;
68 false;
72 double hAlong = 0.0,
74 0.0;
76 0.0;
77 double aspectMax =
78 -1.0;
79 bool hasAlignAngle = false;
82 double alignAngleDeg = 0.0;
86};
87
102{
103 if (region.aspectMax >= 0.0)
104 global.maxAspect = region.aspectMax;
105 return global;
106}
107
121Polygon normalizeRingCCW(const Polygon &ring);
122
138bool polylineIntersectsRect(const Vector<Point2> &path, const Box2 &rect);
139
151double ringSignedArea(const Polygon &ring);
152
164bool pointInRing(const Polygon &ring, const Point2 &p);
165
179bool pointInRegion(const Polygon &ring, const Vector<Polygon> &holes, const Point2 &p);
180
191bool ringIsSimple(const Polygon &ring);
192
216Text validateQuadRegion(const QuadRegion &r, const Vector<Polygon> &domains,
217 const Vector<Polygon> &holes);
218
235Text validateQuadRegionsDisjoint(const Vector<QuadRegion> &regions);
236
262QuadRegionMode classifyQuadRegion(const Polygon &ring, Vector<int> *corners,
263 double cornerTolDeg = 25.0, double rectilinearTolDeg = 2.0);
264
284Polygon resampleRing(const Polygon &ring, double h, double keepTurnDeg = 0.0);
285
298double ringTurnDeg(const Polygon &ring, int i);
299
300} // namespace meshkit::plan
301
302#endif // MESHKIT_NATIVE_MESHQUADREGION_HPP
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,...
QuadRegionMode classifyQuadRegion(const Polygon &ring, Vector< int > *corners, double cornerTolDeg=25.0, double rectilinearTolDeg=2.0)
Heuristically classify normalized ring turns as Mapped, Submapped or Free.
Definition regions.cpp:493
bool ringIsSimple(const Polygon &ring)
Reject proper nonadjacent edge crossings using plain double orientation signs.
Definition regions.cpp:335
double ringTurnDeg(const Polygon &ring, int i)
Compute a signed exterior turn at one ring corner using adjacent edge cross/dot products.
Definition regions.cpp:352
QuadRegionMode
Requested meshing scheme for a QuadRegion's interior.
Definition regions.hpp:32
@ Auto
classifyQuadRegion() decides: Mapped → Submapped → Free.
Definition regions.hpp:33
@ Mapped
Four logical sides (polylines) → transfinite quads. Needs 4 corners.
Definition regions.hpp:34
@ Submapped
Exactly rectilinear ring → grid-based structured quads.
Definition regions.hpp:35
@ Free
Cross-field aligned lattice + template pairing (quad-dominant).
Definition regions.hpp:36
@ TrianglesOnly
Region ring is still a constraint loop, interior stays triangles.
Definition regions.hpp:37
bool pointInRing(const Polygon &ring, const Point2 &p)
Test a point using a strict horizontal-ray odd-even crossing rule.
Definition regions.cpp:318
Polygon normalizeRingCCW(const Polygon &ring)
Copy a ring while dropping scale-fuzzy consecutive/closing duplicates and reversing negative area.
Definition regions.cpp:259
bool pointInRegion(const Polygon &ring, const Vector< Polygon > &holes, const Point2 &p)
Combine outer-ring parity with exclusion by every supplied hole-ring parity.
Definition regions.cpp:308
Text validateQuadRegionsDisjoint(const Vector< QuadRegion > &regions)
Check explicit region pairs for proper crossings or strictly interior sampled vertices.
Definition regions.cpp:449
double ringSignedArea(const Polygon &ring)
Compute oriented shoelace area after translating corners to the first vertex.
Definition regions.cpp:247
Polygon resampleRing(const Polygon &ring, double h, double keepTurnDeg=0.0)
Normalize a ring and insert equal-part subdivisions along all implicit closing edges.
Definition regions.cpp:538
bool polylineIntersectsRect(const Vector< Point2 > &path, const Box2 &rect)
Test whether any consecutive path segment meets a normalized closed rectangle.
Definition regions.cpp:280
QuadQualityBounds quadRegionQualityBounds(const QuadRegion &region, QuadQualityBounds global)
Copy global quality bounds and apply an explicitly nonnegative region aspect override.
Definition regions.hpp:101
Text validateQuadRegion(const QuadRegion &r, const Vector< Polygon > &domains, const Vector< Polygon > &holes)
Check region authoring policy, normalized ring and sampled domain/hole containment.
Definition regions.cpp:367
Quadrilateral quality metrics (workplans/QUAD_MESHING_REDESIGN_PLAN_2026-09-06.md §5).
Acceptance bounds shared by pairing, cleanup, smoothing and the legacy tri-pair merge.
Definition quadquality.hpp:35
double maxAspect
longest / shortest side (opposite-side means). <= 0 = unbounded.
Definition quadquality.hpp:39
A closed polygon whose interior should be meshed with quadrilaterals, with its holes,...
Definition regions.hpp:42
bool hasAlignAngle
Free: constant cross field at alignAngleDeg (from +x, CCW).
Definition regions.hpp:79
Text tag
MeshTriangle::tag for every cell inside; empty = inherit region marker's.
Definition regions.hpp:85
double hAcross
Positive spacings in mesh CRS units, used only when directionalSpacing.
Definition regions.hpp:73
std::int32_t attribute
Cell region id (Cell::region) the native job writes on quads of patches planned from this region; 0 =...
Definition regions.hpp:46
double alignAngleDeg
Free: cross-field angle in degrees from +x, counterclockwise; meaningful only when hasAlignAngle.
Definition regions.hpp:82
double mappedAlongAngleDeg
Physical undirected along-axis, degrees from +x CCW; independent of ring start.
Definition regions.hpp:75
double aspectMax
Free: opposite-side mean ratio cap; < 0 inherits global, 0 unbounded, >= 1 explicit.
Definition regions.hpp:77
QuadRegionMode mode
Requested scheme (default Auto).
Definition regions.hpp:63
bool automaticCandidate
Derived candidate; no outline constraint on fallback.
Definition regions.hpp:65
Vector< int > corners
Mapped: 4 ring vertex indices in ring order; empty = auto-pick.
Definition regions.hpp:84
bool isBackground
True when ring IS a domain outline rather than a ring drawn inside one — the "toggle quads on for the...
Definition regions.hpp:59
bool requireMapped
Explicit hard requirement, used by unified planning.
Definition regions.hpp:64
Vector< Polygon > holes
Areas subtracted from ring (QUAD_EVERYWHERE_PLAN_2026-09-07.md §3.1): domain hole rings,...
Definition regions.hpp:52
Polygon ring
Closed (last == first optional), simple, any orientation.
Definition regions.hpp:47
double spacing
Target quad edge length h; 0 = derive from the size field / max area.
Definition regions.hpp:66
bool directionalSpacing
Explicit Mapped spacing; failure must not fall back to isotropic cells.
Definition regions.hpp:67
Vector< Point2 > alignGuide
Free: optional polyline the field aligns to (streets, channels).
Definition regions.hpp:83
double hAlong
Spacing for the pair of opposite mapped sides more nearly parallel to the mappedAlongAngleDeg axis; p...
Definition regions.hpp:72