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
OpenSWMM::Contour Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  IsoBandPolygon
 One filled-isoband polygon in scene space. Convex (Sutherland- Hodgman of a triangle yields a convex polygon with ≤ 5 vertices). More...
 
struct  IsoLineSegment
 A single contour iso-line segment in scene space. More...
 

Functions

QVector< QPolygonF > chainIsoSegments (const QVector< QLineF > &segs, double quantum)
 Chain unordered iso-line segments into polylines.
 
QColor viridisAt (double t)
 Sample a 5-stop Viridis-inspired colour ramp at t in [0, 1].
 
template<typename TriRange , typename Extract >
std::vector< IsoLineSegmentmarchingTriangles (const TriRange &tris, const std::vector< double > &levels, Extract extract)
 Generate iso-line segments for every (triangle, level) pair where the level crosses the triangle's value range.
 
std::vector< doubleevenlySpacedLevels (double vMin, double vMax, int count)
 Convenience helper that generates N evenly-spaced contour levels between vMin and vMax (exclusive of the endpoints).
 
std::vector< doubleevenlySpacedLevelsInclusive (double vMin, double vMax, int levelCount)
 Convenience helper that returns levelCount evenly-spaced break levels INCLUSIVE of both endpoints (vMin and vMax).
 
template<typename TriRange , typename Extract >
std::vector< IsoBandPolygonmarchingTrianglesIsobands (const TriRange &tris, const std::vector< double > &levels, Extract extract, bool clampUniformOutsideRange=true)
 Generate filled iso-band polygons for every (triangle, band) pair.
 

Function Documentation

◆ chainIsoSegments()

QVector< QPolygonF > OpenSWMM::Contour::chainIsoSegments ( const QVector< QLineF > &  segs,
double  quantum 
)
inline

Chain unordered iso-line segments into polylines.

Parameters
segssegments of a single iso-level, any order/orientation
quantumscene-space snap tolerance — shared triangle edges produce endpoints identical up to floating-point op order, so a tolerance a few orders below the cell size links them reliably.
Here is the caller graph for this function:

◆ evenlySpacedLevels()

std::vector< double > OpenSWMM::Contour::evenlySpacedLevels ( double  vMin,
double  vMax,
int  count 
)
inline

Convenience helper that generates N evenly-spaced contour levels between vMin and vMax (exclusive of the endpoints).

Returns an empty vector if N < 1 or the range is degenerate. Endpoints are excluded because a level exactly equal to vMin or vMax produces either no segments (above/below flip never happens) or coincident-edge artifacts that aren't useful visually.

Here is the caller graph for this function:

◆ evenlySpacedLevelsInclusive()

std::vector< double > OpenSWMM::Contour::evenlySpacedLevelsInclusive ( double  vMin,
double  vMax,
int  levelCount 
)
inline

Convenience helper that returns levelCount evenly-spaced break levels INCLUSIVE of both endpoints (vMin and vMax).

Used by the filled-isoband path: N bands need N+1 break levels including the data-range endpoints, otherwise the boundary triangles get clipped away. Returns an empty vector if levelCount < 2 or the range is degenerate.

Here is the caller graph for this function:

◆ marchingTriangles()

template<typename TriRange , typename Extract >
std::vector< IsoLineSegment > OpenSWMM::Contour::marchingTriangles ( const TriRange &  tris,
const std::vector< double > &  levels,
Extract  extract 
)

Generate iso-line segments for every (triangle, level) pair where the level crosses the triangle's value range.

Template Parameters
TriRangeForward-iterable range of opaque "triangle handles". The caller's Extract functor turns each handle into vertex positions + per-vertex scalar values.
ExtractCallable with signature void(const TriHandle &h, QPointF &p0, QPointF &p1, QPointF &p2, double &v0, double &v1, double &v2)
Parameters
trisforward range of triangles (anything with begin()/end())
levelsiso-levels (sorted ascending is convenient for the caller but not required by the algorithm)
extractper-triangle vertex/value extractor

Complexity O(|tris| * |levels|) with an early-out per triangle when the level lies outside [min(v0,v1,v2), max(v0,v1,v2)]. Typical fill rate on real meshes is well under 30% so the constant factor stays small.

Here is the caller graph for this function:

◆ marchingTrianglesIsobands()

template<typename TriRange , typename Extract >
std::vector< IsoBandPolygon > OpenSWMM::Contour::marchingTrianglesIsobands ( const TriRange &  tris,
const std::vector< double > &  levels,
Extract  extract,
bool  clampUniformOutsideRange = true 
)

Generate filled iso-band polygons for every (triangle, band) pair.

levels is interpreted as N break levels defining N-1 bands; consecutive pairs [levels[k], levels[k+1]] define band k. For best results pass an inclusive level vector (see evenlySpacedLevelsInclusive) so boundary triangles aren't clipped away.

Implementation: each triangle is clipped twice per band via two Sutherland-Hodgman passes (one for value >= L1, one for value <= L2). The output convex polygon has up to 5 vertices and is suitable for fan triangulation by the caller.

Complexity O(|tris| * |bands|) with an early-out per (triangle, band) when the band lies entirely outside the triangle's value range.

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

◆ viridisAt()

QColor OpenSWMM::Contour::viridisAt ( double  t)
inline

Sample a 5-stop Viridis-inspired colour ramp at t in [0, 1].

Used by BJ.2-filled as the default isoband palette until Slice BB lands ColorRamp (at which point this helper becomes a fallback for the legacy-no-ramp case). Stops follow matplotlib's Viridis closely enough for an engineering audience to read elevation rank correctly without the colour-vision-deficiency pitfalls of jet/rainbow.

Here is the caller graph for this function: