Loading...
Searching...
No Matches
pslgprep.cpp File Reference

PSLG preparation utilities shared by the mesh-generation pipeline and its tests: RDP simplification, ring densification, hole-ring preparation (simplify → validate → densify → interior seed, parallel across rings), and a y-banded odd-even point-in-rings index. More...

#include "mesh/pslgprep.h"
#include "mesh/meshcdt.h"
#include "core/editgeometry.h"
#include <QSet>
#include <QtConcurrent/QtConcurrent>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
Include dependency graph for pslgprep.cpp:

Namespaces

namespace  mesh
 The Qt-facing MeshKit API (meshkit::core_qt, meshkit::model_qt, meshkit::io_qt): mesh value types and cell attributes, the mesh generator, quad regions, matching and cleanup, mesh statistics, and the INP and 2DM mesh codecs.
 
namespace  mesh::pslg
 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.
 

Functions

QVector< QPointF > mesh::pslg::simplifyPolyline (const QVector< QPointF > &pts, double epsilon)
 Return an endpoint-preserving Ramer-Douglas-Peucker subsequence of an open path.
 
QVector< QPointF > mesh::pslg::simplifyRing (const QVector< QPointF > &ring, double epsilon)
 Simplify a ring's open vertex sequence and restore its existing closure convention.
 
QVector< QPointF > mesh::pslg::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 > mesh::pslg::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 > mesh::pslg::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 > mesh::pslg::densifyRing (const QVector< QPointF > &ring, double maxLen)
 Insert equal-length subdivisions along every explicitly present consecutive path edge.
 
double mesh::pslg::polylineLength (const QVector< QPointF > &pts)
 Sum Euclidean lengths of consecutive explicitly stored path edges.
 
double mesh::pslg::ringSignedArea (const QVector< QPointF > &ring)
 Compute the ordinary double-precision shoelace area of an implicitly closed ring.
 
QVector< QPointF > mesh::pslg::unfoldPolyline (const QVector< QPointF > &pts, double maxTurnDeg=150.0, bool *changedOut=nullptr)
 Heuristically reorder reversed interior alignments and drop excessive backtracking turns.
 
QVector< QPointF > mesh::pslg::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 > mesh::pslg::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 mesh::pslg::distSqToSegment (const QPointF &p, const QPointF &a, const QPointF &b)
 Compute squared point-to-closed-segment distance using clamped projection.
 
void mesh::pslg::snapAndDedupe (QVector< mesh::SteinerPoint > &pts, double snapEps)
 Drop duplicate untagged Steiner points by rounded spatial-grid key without moving coordinates.
 
QVector< bool > mesh::pslg::greedyMinSeparation (const QVector< QPointF > &pts, double minSep)
 Keep points in priority order when no previously kept point is strictly closer than minSep.
 
PreparedRing mesh::pslg::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 mesh::pslg::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.
 

Detailed Description

PSLG preparation utilities shared by the mesh-generation pipeline and its tests: RDP simplification, ring densification, hole-ring preparation (simplify → validate → densify → interior seed, parallel across rings), and a y-banded odd-even point-in-rings index.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License
Apache-2.0

The RDP / densify / dedupe helpers are moved verbatim from meshgenerationdialog.cpp's anonymous namespace so the pipeline, collectInputs, and tests share one implementation.