SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
EditGeometry Namespace Reference

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.
 

Enumeration Type Documentation

◆ RingValidity

enum class EditGeometry::RingValidity
strong

Validity classes for a RingPolygon (in-house checks, no GEOS).

Enumerator
Ok 
TooFewVertices 

Exterior or a hole has < 3 vertices.

SelfIntersecting 

Exterior or a hole crosses itself.

HoleOutsideExterior 

A hole escapes / crosses the exterior.

HolesOverlap 

Two holes overlap or nest.

Function Documentation

◆ cleanPolygonRing()

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).

Parameters
vOrdered polygon vertices (open or explicitly closed).
tolCoincidence tolerance in the input coordinate units.
Returns
Cleaned open ring. May contain fewer than three distinct points when the input is degenerate — the caller decides how to handle it.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanPolyline()

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.

Parameters
vOrdered polyline vertices.
tolCoincidence tolerance in the input coordinate units. Two points are coincident when their squared distance is <= tol*tol.
Returns
Cleaned polyline. May contain fewer than two distinct points when the whole input collapses — the caller decides how to handle that.
Here is the caller graph for this function:

◆ containsPoint()

bool EditGeometry::containsPoint ( const RingPolygon p,
const QPointF &  pt 
)

True when pt is inside the exterior and outside every hole.

Here is the call graph for this function:

◆ distanceToPolyline()

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.

Parameters
[out]segmentIndexWhen non-null, receives the index of the closest segment (0 = first segment between vertices[0] and vertices[1]).
[out]closestPointWhen non-null, receives the closest point on the polyline.
Returns
Distance in the same units as the input coordinates. Returns std::numeric_limits<double>::infinity() for fewer than two vertices.
Here is the caller graph for this function:

◆ insertedAt()

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.

Here is the caller graph for this function:

◆ interiorPoint()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ netArea()

double EditGeometry::netArea ( const RingPolygon p)

Net area = |exterior| − Σ|holes|, clamped to >= 0.

Here is the call graph for this function:

◆ normalizeRingPolygon()

RingPolygon EditGeometry::normalizeRingPolygon ( RingPolygon  p,
double  tol = kCoincidenceTol 
)

Clean every ring (dedupe + de-close), drop degenerate interior rings, and orient exterior CCW / interiors CW.

Here is the call graph for this function:

◆ orientInteriorToEndpoints()

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).

Parameters
interiorInterior bend points only (no node endpoints).
fromFrom-node coordinate (polyline start).
toTo-node coordinate (polyline end).
Returns
interior, reversed iff it was stored to→from.
Here is the caller graph for this function:

◆ pointInRing()

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.

Here is the caller graph for this function:

◆ polygonArea()

double EditGeometry::polygonArea ( const QVector< QPointF > &  polygon)

Compute the area of a polygon using the shoelace formula.

Parameters
polygonOrdered polygon vertices (open or closed; if the last vertex equals the first, the closing edge is not doubled).
Returns
Absolute area in the squared units of the input coordinates. Returns 0 for fewer than 3 vertices.
Here is the caller graph for this function:

◆ polylineLength()

double EditGeometry::polylineLength ( const QVector< QPointF > &  vertices)

Compute the total length of a polyline.

Parameters
verticesOrdered 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).
Returns
Sum of Euclidean segment lengths, or 0 for <2 vertices.
Here is the caller graph for this function:

◆ removedAt()

QVector< QPointF > EditGeometry::removedAt ( const QVector< QPointF > &  vertices,
int  index 
)

Remove the vertex at index, producing a new polyline of size-1.

Returns
A copy of vertices when index is out of range or when removal would leave fewer than two vertices.
Here is the caller graph for this function:

◆ replacedAt()

QVector< QPointF > EditGeometry::replacedAt ( const QVector< QPointF > &  vertices,
int  index,
const QPointF &  newPt 
)

Replace one endpoint of a polyline, producing a new vector.

Parameters
verticesOriginal polyline (read-only).
indexEndpoint to replace (0 = first, vertices.size()-1 = last).
newPtReplacement point.
Returns
New polyline, or a copy of vertices if index is out of range.
Here is the caller graph for this function:

◆ signedRingArea()

double EditGeometry::signedRingArea ( const QVector< QPointF > &  ring)

Signed area of a ring via the shoelace formula.

Returns
Positive for counter-clockwise winding, negative for clockwise, 0 for fewer than 3 vertices. Handles open or explicitly-closed rings.
Here is the caller graph for this function:

◆ validateRingPolygon()

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).

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ kCoincidenceTol

constexpr double EditGeometry::kCoincidenceTol = 1e-6
constexpr

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.