![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
Classes | |
| struct | RingPolygon |
| A polygon: exactly one exterior ring + zero-or-more interior rings. More... | |
Enumerations | |
| enum class | RingValidity { Ok , TooFewVertices , SelfIntersecting , HoleOutsideExterior , HolesOverlap } |
| Validity classes for a RingPolygon (in-house checks, no GEOS). More... | |
Functions | |
| QVector< QPointF > | cleanPolyline (const QVector< QPointF > &v, double tol=kCoincidenceTol) |
| Drop consecutive coincident points from a polyline. | |
| QVector< QPointF > | cleanPolygonRing (const QVector< QPointF > &v, double tol=kCoincidenceTol) |
| Normalize a polygon ring: collapse coincident points and drop a redundant explicit closing vertex. | |
| QVector< QPointF > | orientInteriorToEndpoints (QVector< QPointF > interior, const QPointF &from, const QPointF &to) |
Orient a link's interior bend points to run from from toward to. | |
| double | polylineLength (const QVector< QPointF > &vertices) |
| Compute the total length of a polyline. | |
| QVector< QPointF > | replacedAt (const QVector< QPointF > &vertices, int index, const QPointF &newPt) |
| Replace one endpoint of a polyline, producing a new vector. | |
| QVector< QPointF > | insertedAt (const QVector< QPointF > &vertices, int index, const QPointF &newPt) |
Insert a vertex at index, producing a new polyline of size+1. | |
| QVector< QPointF > | removedAt (const QVector< QPointF > &vertices, int index) |
Remove the vertex at index, producing a new polyline of size-1. | |
| double | distanceToPolyline (const QVector< QPointF > &vertices, const QPointF &point, int *segmentIndex=nullptr, QPointF *closestPoint=nullptr) |
| Distance from a point to the nearest point on a polyline segment. | |
| double | polygonArea (const QVector< QPointF > &polygon) |
| Compute the area of a polygon using the shoelace formula. | |
| double | signedRingArea (const QVector< QPointF > &ring) |
| Signed area of a ring via the shoelace formula. | |
| bool | pointInRing (const QVector< QPointF > &ring, const QPointF &pt) |
| Even-odd point-in-ring test (boundary result is unspecified but stable). Returns false for rings with fewer than 3 vertices. | |
| RingPolygon | normalizeRingPolygon (RingPolygon p, double tol=kCoincidenceTol) |
| Clean every ring (dedupe + de-close), drop degenerate interior rings, and orient exterior CCW / interiors CW. | |
| double | netArea (const RingPolygon &p) |
| Net area = |exterior| − Σ|holes|, clamped to >= 0. | |
| bool | containsPoint (const RingPolygon &p, const QPointF &pt) |
True when pt is inside the exterior and outside every hole. | |
| QPointF | interiorPoint (const QVector< QPointF > &ring) |
| A point guaranteed strictly interior to a simple ring — robust for non-convex rings — suitable as a Triangle hole/region seed. | |
| RingValidity | validateRingPolygon (const RingPolygon &p) |
| Validate a RingPolygon with in-house geometry checks (O(n^2) edge tests; intended for hand-digitized / GIS-sourced rings). | |
Variables | |
| constexpr double | kCoincidenceTol = 1e-6 |
| Default coincidence tolerance, in layer-CRS units. | |
|
strong |
Validity classes for a RingPolygon (in-house checks, no GEOS).
| QVector< QPointF > EditGeometry::cleanPolygonRing | ( | const QVector< QPointF > & | v, |
| double | tol = kCoincidenceTol |
||
| ) |
Normalize a polygon ring: collapse coincident points and drop a redundant explicit closing vertex.
Runs the same consecutive-duplicate collapse as cleanPolyline(), then strips a trailing point that coincides with the first vertex so the result is an OPEN ring (matching the SWMM [POLYGONS] storage convention, where the closing edge is implicit).
| v | Ordered polygon vertices (open or explicitly closed). |
| tol | Coincidence tolerance in the input coordinate units. |
| QVector< QPointF > EditGeometry::cleanPolyline | ( | const QVector< QPointF > & | v, |
| double | tol = kCoincidenceTol |
||
| ) |
Drop consecutive coincident points from a polyline.
Each point within tol of the previous kept point is removed, so a run of three or more duplicates collapses to one. The first point is always kept; order and shape are otherwise preserved. Inputs with fewer than two points are returned unchanged.
| v | Ordered polyline vertices. |
| tol | Coincidence tolerance in the input coordinate units. Two points are coincident when their squared distance is <= tol*tol. |
| bool EditGeometry::containsPoint | ( | const RingPolygon & | p, |
| const QPointF & | pt | ||
| ) |
True when pt is inside the exterior and outside every hole.
| double EditGeometry::distanceToPolyline | ( | const QVector< QPointF > & | vertices, |
| const QPointF & | point, | ||
| int * | segmentIndex = nullptr, |
||
| QPointF * | closestPoint = nullptr |
||
| ) |
Distance from a point to the nearest point on a polyline segment.
| [out] | segmentIndex | When non-null, receives the index of the closest segment (0 = first segment between vertices[0] and vertices[1]). |
| [out] | closestPoint | When non-null, receives the closest point on the polyline. |
| QVector< QPointF > EditGeometry::insertedAt | ( | const QVector< QPointF > & | vertices, |
| int | index, | ||
| const QPointF & | newPt | ||
| ) |
Insert a vertex at index, producing a new polyline of size+1.
Pass index = vertices.size() to append, 0 to prepend. Out-of-range indices are clamped.
| QPointF EditGeometry::interiorPoint | ( | const QVector< QPointF > & | ring | ) |
A point guaranteed strictly interior to a simple ring — robust for non-convex rings — suitable as a Triangle hole/region seed.
Scans a horizontal line through the ring's vertical midpoint and returns the midpoint of the widest interior span (even-odd rule). Falls back to the vertex centroid only for degenerate input. This replaces the naive vertex-centroid seed, which can fall outside a non-convex ring.
| double EditGeometry::netArea | ( | const RingPolygon & | p | ) |
Net area = |exterior| − Σ|holes|, clamped to >= 0.
| RingPolygon EditGeometry::normalizeRingPolygon | ( | RingPolygon | p, |
| double | tol = kCoincidenceTol |
||
| ) |
Clean every ring (dedupe + de-close), drop degenerate interior rings, and orient exterior CCW / interiors CW.
| QVector< QPointF > EditGeometry::orientInteriorToEndpoints | ( | QVector< QPointF > | interior, |
| const QPointF & | from, | ||
| const QPointF & | to | ||
| ) |
Orient a link's interior bend points to run from from toward to.
GIS-imported SWMM models frequently digitize a link in the opposite sense to its from/to-node assignment, so the [VERTICES] are stored running to→from. The assembled polyline [from, interior…, to] then doubles back on itself and renders as self-crossing "loop" artifacts. This reverses interior when its endpoints sit closer to the opposite nodes (i.e. the first bend is nearer to and the last bend nearer from). Correctly-ordered interiors are returned unchanged, as are inputs with fewer than two points (no ordering ambiguity).
| interior | Interior bend points only (no node endpoints). |
| from | From-node coordinate (polyline start). |
| to | To-node coordinate (polyline end). |
interior, reversed iff it was stored to→from. | bool EditGeometry::pointInRing | ( | const QVector< QPointF > & | ring, |
| const QPointF & | pt | ||
| ) |
Even-odd point-in-ring test (boundary result is unspecified but stable). Returns false for rings with fewer than 3 vertices.
| double EditGeometry::polygonArea | ( | const QVector< QPointF > & | polygon | ) |
Compute the area of a polygon using the shoelace formula.
| polygon | Ordered polygon vertices (open or closed; if the last vertex equals the first, the closing edge is not doubled). |
| double EditGeometry::polylineLength | ( | const QVector< QPointF > & | vertices | ) |
Compute the total length of a polyline.
| vertices | Ordered polyline vertices (any coordinate frame — the caller is responsible for passing points in the frame whose Euclidean distance matches the desired length unit; for SWMM auto-length this is the layer CRS). |
| QVector< QPointF > EditGeometry::removedAt | ( | const QVector< QPointF > & | vertices, |
| int | index | ||
| ) |
Remove the vertex at index, producing a new polyline of size-1.
vertices when index is out of range or when removal would leave fewer than two vertices. | QVector< QPointF > EditGeometry::replacedAt | ( | const QVector< QPointF > & | vertices, |
| int | index, | ||
| const QPointF & | newPt | ||
| ) |
Replace one endpoint of a polyline, producing a new vector.
| vertices | Original polyline (read-only). |
| index | Endpoint to replace (0 = first, vertices.size()-1 = last). |
| newPt | Replacement point. |
vertices if index is out of range. | double EditGeometry::signedRingArea | ( | const QVector< QPointF > & | ring | ) |
Signed area of a ring via the shoelace formula.
| RingValidity EditGeometry::validateRingPolygon | ( | const RingPolygon & | p | ) |
Validate a RingPolygon with in-house geometry checks (O(n^2) edge tests; intended for hand-digitized / GIS-sourced rings).
Default coincidence tolerance, in layer-CRS units.
Targets true / near-exact coincidence and floating-point round-trip noise (e.g. duplicate map clicks, a polygon closing point that repeats the first vertex), NOT visual simplification. Collinear / shape-preserving vertices are intentionally left untouched.