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
mesh::MeshGenerator Class Reference

Generate a 2D triangular mesh. More...

#include <meshgenerator.h>

Collaboration diagram for mesh::MeshGenerator:

Public Member Functions

 MeshGenerator ()=default
 
void setDomain (const QPolygonF &outerBoundary)
 Replace the domain with a single closed boundary polygon.
 
void setDomains (const QVector< QPolygonF > &outerBoundaries)
 Replace the domain with multiple disjoint closed polygons. Each polygon becomes its own boundary ring; Triangle meshes the interior of every ring and leaves the gaps unmeshed. Useful when the meshing region is a multi-catchment area or a layer containing several non-overlapping polygons.
 
void addDomain (const QPolygonF &outerBoundary)
 Append one more closed boundary polygon to the current domain set. Equivalent to building up via setDomains.
 
void addConstraintSegment (const ConstraintSegment &seg)
 
void addSteinerPoint (const SteinerPoint &pt)
 
void reserveSteinerPoints (qsizetype additional)
 Pre-reserve capacity for additional upcoming addSteinerPoint calls. Avoids the transient ~2x peak of geometric growth when bulk- adding terrain points; callers should cap the request.
 
void addHole (const QPointF &interiorPointInsideHole)
 
void addRegion (const RegionMarker &region)
 
void addPatch (const PatchMesh &patch)
 Stitch a structured quad patch (mesh/meshpatch.h) into the domain. Its boundary segments become PSLG constraints, its interior a hole (seed = the first quad's centroid), and after Triangle runs its quads are appended after every triangle with vertices merged by coordinate against the Triangle output (GenerationOptions::patchSnapEps). Patch vertices receive whatever elevation fill the caller applies to MeshResult::vertices afterwards — same path as Triangle's own.
 
void addQuadRegion (const QuadRegion &region)
 Register a PSLG quad region (mesh/meshquadregion.h). Resolved in generate(): the ring becomes a constraint loop; Mapped / Submapped regions are meshed directly (as an internal patch); Free regions get a cross-field aligned lattice of Steiner points, no Triangle refinement inside (the -u hook returns "unconstrained" there), template + gap pairing, cleanup and smoothing after Triangle. Marker-0 Steiner points (terrain / aux) inside a Free ring are dropped; marker != 0 points (junctions) are kept and pin the lattice. User RegionMarkers inside a quad ring are dropped (their tag is inherited when the region's tag is empty). Regions failing validation are skipped with a report line.
 
const QVector< QuadRegionReport > & quadRegionReports () const
 One report per addQuadRegion() call, filled by generate().
 
void setOptions (const GenerationOptions &opts)
 
void setRefineHook (const RefineHook &hook)
 Install cancellation / progress / graded-sizing callbacks.
 
MeshResult generate () const
 Run Triangle. Returns a result with ok=false + errorMsg on failure.
 
QString tagForVertexMarker (int marker) const
 Translate an output point's marker back to a tag string. Used by clients that don't want to maintain their own map. The generator builds this from SteinerPoint::marker→tag during generate().
 
QString tagForEdgeMarker (int marker) const
 Translate an output edge's marker back to a tag string.
 

Detailed Description

Generate a 2D triangular mesh.

Usage:

MeshGenerator g;
g.setDomain(boundaryPolygon);
g.addSteinerPoint({junctionXY, 1, "J1"});       // marker = 1
g.addConstraintSegment({conduitPath, 100, "C5"}); // marker = 100
g.setOptions({.maxArea = 50.0, .minAngle = 28.0});
const MeshResult r = g.generate();

Constructor & Destructor Documentation

◆ MeshGenerator()

mesh::MeshGenerator::MeshGenerator ( )
default

Member Function Documentation

◆ addConstraintSegment()

void mesh::MeshGenerator::addConstraintSegment ( const ConstraintSegment seg)

◆ addDomain()

void mesh::MeshGenerator::addDomain ( const QPolygonF &  outerBoundary)

Append one more closed boundary polygon to the current domain set. Equivalent to building up via setDomains.

◆ addHole()

void mesh::MeshGenerator::addHole ( const QPointF &  interiorPointInsideHole)

◆ addPatch()

void mesh::MeshGenerator::addPatch ( const PatchMesh patch)

Stitch a structured quad patch (mesh/meshpatch.h) into the domain. Its boundary segments become PSLG constraints, its interior a hole (seed = the first quad's centroid), and after Triangle runs its quads are appended after every triangle with vertices merged by coordinate against the Triangle output (GenerationOptions::patchSnapEps). Patch vertices receive whatever elevation fill the caller applies to MeshResult::vertices afterwards — same path as Triangle's own.

◆ addQuadRegion()

void mesh::MeshGenerator::addQuadRegion ( const QuadRegion region)

Register a PSLG quad region (mesh/meshquadregion.h). Resolved in generate(): the ring becomes a constraint loop; Mapped / Submapped regions are meshed directly (as an internal patch); Free regions get a cross-field aligned lattice of Steiner points, no Triangle refinement inside (the -u hook returns "unconstrained" there), template + gap pairing, cleanup and smoothing after Triangle. Marker-0 Steiner points (terrain / aux) inside a Free ring are dropped; marker != 0 points (junctions) are kept and pin the lattice. User RegionMarkers inside a quad ring are dropped (their tag is inherited when the region's tag is empty). Regions failing validation are skipped with a report line.

◆ addRegion()

void mesh::MeshGenerator::addRegion ( const RegionMarker region)

◆ addSteinerPoint()

void mesh::MeshGenerator::addSteinerPoint ( const SteinerPoint pt)

◆ generate()

MeshResult mesh::MeshGenerator::generate ( ) const

Run Triangle. Returns a result with ok=false + errorMsg on failure.

Here is the call graph for this function:

◆ quadRegionReports()

const QVector< QuadRegionReport > & mesh::MeshGenerator::quadRegionReports ( ) const
inline

One report per addQuadRegion() call, filled by generate().

◆ reserveSteinerPoints()

void mesh::MeshGenerator::reserveSteinerPoints ( qsizetype  additional)

Pre-reserve capacity for additional upcoming addSteinerPoint calls. Avoids the transient ~2x peak of geometric growth when bulk- adding terrain points; callers should cap the request.

◆ setDomain()

void mesh::MeshGenerator::setDomain ( const QPolygonF &  outerBoundary)

Replace the domain with a single closed boundary polygon.

◆ setDomains()

void mesh::MeshGenerator::setDomains ( const QVector< QPolygonF > &  outerBoundaries)

Replace the domain with multiple disjoint closed polygons. Each polygon becomes its own boundary ring; Triangle meshes the interior of every ring and leaves the gaps unmeshed. Useful when the meshing region is a multi-catchment area or a layer containing several non-overlapping polygons.

◆ setOptions()

void mesh::MeshGenerator::setOptions ( const GenerationOptions opts)

◆ setRefineHook()

void mesh::MeshGenerator::setRefineHook ( const RefineHook hook)

Install cancellation / progress / graded-sizing callbacks.

Passing a hook with any member set makes generate() add Triangle's -u switch, which routes refinement decisions through the hook. A hook whose members are all empty changes nothing. See trirefinehook.h.

When hook.targetAreaAt is set it supersedes GenerationOptions::maxArea and the global -a<area> switch is omitted.

If the hook reports cancellation, generate() returns ok=false with errorMsg set rather than a partially refined mesh.

◆ tagForEdgeMarker()

QString mesh::MeshGenerator::tagForEdgeMarker ( int  marker) const

Translate an output edge's marker back to a tag string.

◆ tagForVertexMarker()

QString mesh::MeshGenerator::tagForVertexMarker ( int  marker) const

Translate an output point's marker back to a tag string. Used by clients that don't want to maintain their own map. The generator builds this from SteinerPoint::marker→tag during generate().


The documentation for this class was generated from the following files: