Preparation of planar straight-line graphs (PSLG) for meshing: Ramer–Douglas–Peucker simplification, straightness trimming, densification and resampling of paths and rings, hole-ring preparation, and point-in-rings tests.
More...
|
| QVector< QPointF > | simplifyPolyline (const QVector< QPointF > &pts, double epsilon) |
| | Return an endpoint-preserving Ramer-Douglas-Peucker subsequence of an open path.
|
| |
| QVector< QPointF > | simplifyRing (const QVector< QPointF > &ring, double epsilon) |
| | Simplify a ring's open vertex sequence and restore its existing closure convention.
|
| |
| QVector< QPointF > | trimByStraightness (const QVector< QPointF > &pts, double maxTurnDeg, double maxDeviation, const QVector< bool > &protectedFlags={}, bool closed=false, int *removedOut=nullptr) |
| | Remove flattest eligible vertices while preserving original-span chord deviation limits.
|
| |
| QVector< QPointF > | resampleAtSize (const QVector< QPointF > &path, const std::function< double(double, double)> &hAt, bool canonicalSegments=false) |
| | Insert collinear samples according to a numerically integrated local target-size callback.
|
| |
| QVector< bool > | flagsForCoincidentVertices (const QVector< QPointF > &pts, const QVector< QVector< QPointF > > &others, double tol) |
| | Flag query vertices within an inclusive tolerance of any vertex in other paths.
|
| |
| QVector< QPointF > | densifyRing (const QVector< QPointF > &ring, double maxLen) |
| | Insert equal-length subdivisions along every explicitly present consecutive path edge.
|
| |
| double | polylineLength (const QVector< QPointF > &pts) |
| | Sum Euclidean lengths of consecutive explicitly stored path edges.
|
| |
| QVector< QPointF > | unfoldPolyline (const QVector< QPointF > &pts, double maxTurnDeg=150.0, bool *changedOut=nullptr) |
| | Heuristically reorder reversed interior alignments and drop excessive backtracking turns.
|
| |
| QVector< QPointF > | resampleMinLength (const QVector< QPointF > &pts, double minLen, double maxDeviation, int *flaggedOut=nullptr) |
| | Remove intermediate path vertices while respecting an original-point chord-deviation cap.
|
| |
| QVector< QPointF > | resampleRingMinLength (const QVector< QPointF > &ring, double minLen, double maxDeviation, int *flaggedOut=nullptr) |
| | Apply minimum-length decimation to a ring while preserving at least three corners.
|
| |
| double | ringSignedArea (const QVector< QPointF > &ring) |
| | Compute the ordinary double-precision shoelace area of an implicitly closed ring.
|
| |
| double | distSqToSegment (const QPointF &p, const QPointF &a, const QPointF &b) |
| | Compute squared point-to-closed-segment distance using clamped projection.
|
| |
| void | snapAndDedupe (QVector< mesh::SteinerPoint > &pts, double snapEps) |
| | Drop duplicate untagged Steiner points by rounded spatial-grid key without moving coordinates.
|
| |
| QVector< bool > | greedyMinSeparation (const QVector< QPointF > &pts, double minSep) |
| | Keep points in priority order when no previously kept point is strictly closer than minSep.
|
| |
| PreparedRing | prepareHoleRing (const QVector< QPointF > &raw, double simplifyEps, double maxEdgeLen, double trimTurnDeg=0.0, double trimDeviation=0.0) |
| | Trim, simplify, validate, densify and seed one borrowed hole boundary.
|
| |
| bool | prepareHoleRings (const QVector< QVector< QPointF > > &raw, double simplifyEps, double maxEdgeLen, QVector< PreparedRing > *out, const std::function< bool()> &isCancelled={}, const std::function< void(int, int)> &onChunk={}, int *skippedOut=nullptr, double trimTurnDeg=0.0, double trimDeviation=0.0) |
| | Prepare hole rings in order-preserving synchronous parallel chunks of at most 4096.
|
| |
Preparation of planar straight-line graphs (PSLG) for meshing: Ramer–Douglas–Peucker simplification, straightness trimming, densification and resampling of paths and rings, hole-ring preparation, and point-in-rings tests.
| QVector< QPointF > mesh::pslg::resampleMinLength |
( |
const QVector< QPointF > & | pts, |
|
|
double | minLen, |
|
|
double | maxDeviation, |
|
|
int * | flaggedOut = nullptr ) |
|
nodiscard |
Remove intermediate path vertices while respecting an original-point chord-deviation cap.
- Parameters
-
| [in] | pts | Borrowed finite planar path, unchanged; sizes/products/differences must be representable. |
| [in] | minLen | Finite target minimum chord length in planar units; <=0 or <=2 points returns input. |
| [in] | maxDeviation | Finite maximum original-point distance to each replacement segment in planar units, clamped to >=0. Unlike straightness trimming, zero here enforces zero allowed deviation. |
| [in,out] | flaggedOut | Optional borrowed initialized tally, incremented by retained short/deviation exceptions, not reset; unchanged on no-op. The diagnostic is heuristic and does not certify every chord. |
- Returns
- Owned retained subsequence with both endpoints, original order/coordinates preserved. Mandatory endpoints/deviation constraints can leave segments shorter than minLen; tail pullback is rechecked against original points. Allocates retained-index/output storage, no source/engine mutation.
Length-based decimation — the inverse of densifyRing().
Drops intermediate vertices so that every retained chord is at least minLen long, but never moves the polyline further than maxDeviation from its original path: when dropping a run would exceed that, the offending vertex is retained instead and a short segment survives. RDP (simplifyPolyline) cannot do this — it is keyed on perpendicular deviation, so a tight zig-zag keeps every vertex however short the segments.
First and last points are always retained; for a conduit alignment they carry the coupling identity. No-op when minLen <= 0 or size <= 2.
| QVector< QPointF > mesh::pslg::trimByStraightness |
( |
const QVector< QPointF > & | pts, |
|
|
double | maxTurnDeg, |
|
|
double | maxDeviation, |
|
|
const QVector< bool > & | protectedFlags = {}, |
|
|
bool | closed = false, |
|
|
int * | removedOut = nullptr ) |
|
nodiscard |
Remove flattest eligible vertices while preserving original-span chord deviation limits.
- Parameters
-
| [in] | pts | Borrowed finite planar path, unchanged; size/coordinate products must be representable. |
| [in] | maxTurnDeg | Finite turn threshold in degrees, normally (0,180]; <=0 disables trimming. Actual comparison includes equality and treats zero-length adjacent edges as straight. |
| [in] | maxDeviation | Finite chord-distance cap in planar units; <=0 disables this cap. Every original vertex spanned by a proposed removal is checked against the closed replacement segment. |
| [in] | protectedFlags | Borrowed protection flags; may be empty/short, missing entries mean unprotected. Open endpoints are always protected; repeated closing duplicate uses its first corner's flag. |
| [in] | closed | True forces circular treatment; exact first==last also selects ring behavior. |
| [out] | removedOut | Optional borrowed count, reset to zero first and set to removed open vertices. |
- Returns
- Owned retained subsequence, unchanged for no-op/no removals. Preserves explicit closing duplicate, keeps at least three ring vertices, never moves coordinates. Deviation-rejected candidates become permanently protected; no global self-intersection/topology guarantee. Allocates linked-index/heap/output storage, retains no inputs and does not modify geometry or engine state.
Straightness trimming (MESH_OVERHAUL_PLAN_2026-09-29.md Stage 1).
Drops a vertex when the polyline turns by less than maxTurnDeg there, provided the chord that replaces it stays within maxDeviation of every ORIGINAL vertex it spans (so error never accumulates across removals). Vertices are taken flattest-first from a heap; a vertex whose removal would breach the deviation cap is kept for good. Protected vertices (protectedFlags, one per input point; may be empty) are never removed; the endpoints of an open polyline are always protected.
Closed rings (first == last, or closed) are treated circularly, keep their closing duplicate if they had one, and never drop below 3 distinct vertices. No-op when maxTurnDeg <=
- maxDeviation <= 0 = no cap.
| QVector< QPointF > mesh::pslg::unfoldPolyline |
( |
const QVector< QPointF > & | pts, |
|
|
double | maxTurnDeg = 150.0, |
|
|
bool * | changedOut = nullptr ) |
|
nodiscard |
Heuristically reorder reversed interior alignments and drop excessive backtracking turns.
- Parameters
-
| [in] | pts | Borrowed finite planar path, unchanged; coordinate/length/angle arithmetic must be representable. |
| [in] | maxTurnDeg | Finite maximum allowed interior turn in degrees, normally [0,180], default 150. No clamp/no-op sentinel is applied; negative values can remove all interior points, while interior reversal can occur even at 180 degrees. |
| [out] | changedOut | Optional borrowed flag, initialized false and set true on any reversal/removal. |
- Returns
- Owned path retaining original endpoints. With >=4 points reverses all interior points only if total length decreases; repeatedly removes the largest turn strictly above threshold. Zero-length adjacent edges count as zero turn. Heuristic can change route topology and has no deviation/shape preservation guarantee; allocates copies, no source mutation or engine update.
Undo two digitising faults in a link alignment that fold it back on itself (MESH_TRIANGLE_ENGINE_PLAN_2026-09-30.md, Bellinge).
A vertex list stored from the to-node to the from-node runs the path out to the far end and back; when the interior vertices in reverse order give a shorter path, they are reversed. Then any interior vertex where the path turns back by more than maxTurnDeg (a stray or out-of-order vertex) is dropped, sharpest first, until none is left. A pipe never doubles back, and a folded line leaves a sliver band the mesh cannot fill with good cells. The end points are always kept.