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.h File Reference

Pure geometry helpers used by the map-edit tools and commands. More...

#include <QPointF>
#include <QVector>
Include dependency graph for editgeometry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EditGeometry::RingPolygon
 A polygon: exactly one exterior ring + zero-or-more interior rings. More...
 

Namespaces

namespace  EditGeometry
 

Enumerations

enum class  EditGeometry::RingValidity {
  EditGeometry::Ok ,
  EditGeometry::TooFewVertices ,
  EditGeometry::SelfIntersecting ,
  EditGeometry::HoleOutsideExterior ,
  EditGeometry::HolesOverlap
}
 Validity classes for a RingPolygon (in-house checks, no GEOS). More...
 

Functions

QVector< QPointF > EditGeometry::cleanPolyline (const QVector< QPointF > &v, double tol=kCoincidenceTol)
 Drop consecutive coincident points from a polyline.
 
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.
 
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.
 
double EditGeometry::polylineLength (const QVector< QPointF > &vertices)
 Compute the total length of a polyline.
 
QVector< QPointF > EditGeometry::replacedAt (const QVector< QPointF > &vertices, int index, const QPointF &newPt)
 Replace one endpoint of a polyline, producing a new vector.
 
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.
 
QVector< QPointF > EditGeometry::removedAt (const QVector< QPointF > &vertices, int index)
 Remove the vertex at index, producing a new polyline of size-1.
 
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.
 
double EditGeometry::polygonArea (const QVector< QPointF > &polygon)
 Compute the area of a polygon using the shoelace formula.
 
double EditGeometry::signedRingArea (const QVector< QPointF > &ring)
 Signed area of a ring via the shoelace formula.
 
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.
 
RingPolygon EditGeometry::normalizeRingPolygon (RingPolygon p, double tol=kCoincidenceTol)
 Clean every ring (dedupe + de-close), drop degenerate interior rings, and orient exterior CCW / interiors CW.
 
double EditGeometry::netArea (const RingPolygon &p)
 Net area = |exterior| − Σ|holes|, clamped to >= 0.
 
bool EditGeometry::containsPoint (const RingPolygon &p, const QPointF &pt)
 True when pt is inside the exterior and outside every hole.
 
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.
 
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).
 

Variables

constexpr double EditGeometry::kCoincidenceTol = 1e-6
 Default coincidence tolerance, in layer-CRS units.
 

Detailed Description

Pure geometry helpers used by the map-edit tools and commands.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026

These helpers live in a leaf module with no Qt-GUI, OGR, or engine dependencies so they can be exercised directly by a lightweight QtTest binary without dragging in the full SWMMModelLayer / MapCanvas graph.