Loading...
Searching...
No Matches
mesh::MeshTriangle Struct Reference

A cell in the mesh — a triangle or (since the engine's mixed tri-quad meshes, workplans/TRI_QUAD_MESHING_PLAN_2026-09-06.md) a convex quadrilateral — indices into MeshResult::vertices. More...

#include <mesh/meshresult.h>

Collaboration diagram for mesh::MeshTriangle:

Public Member Functions

bool isQuad () const noexcept
 Classify the cell solely by whether a fourth vertex identifier is present.
 
int vertexCount () const noexcept
 Report the logical corner count selected by the fourth-vertex sentinel.
 
int vertex (int k) const noexcept
 Fetch one stored corner identifier without a vertex-array lookup.
 
void setVertex (int k, int v) noexcept
 Replace a stored corner identifier, leaving every other cell attribute unchanged.
 
bool hasVertex (int v) const noexcept
 Check whether an identifier equals a stored logical corner.
 

Public Attributes

int v0 = 0
 First corner: index into MeshResult::vertices (not range-checked here).
 
int v1 = 0
 Second corner, cyclically after v0.
 
int v2 = 0
 Third corner, cyclically after v1.
 
int v3 = -1
 Fourth vertex of a quadrilateral; -1 = triangle.
 
QString tag
 Region tag, for example a subcatchment ID; empty if untagged.
 
double mannings = std::numeric_limits<double>::quiet_NaN()
 Manning's roughness ([2D_TRIANGLES] MANNINGS_N).
 
double initDepth = std::numeric_limits<double>::quiet_NaN()
 Initial water depth in m ([2D_TRIANGLES] INIT_DEPTH, written between MANNINGS_N and TAG).
 
double initHgl = std::numeric_limits<double>::quiet_NaN()
 Initial water-surface elevation in mesh length units on the vertex Z datum ([2D_INITIAL_HGL]).
 
double initU = 0.0
 Initial velocity components in m/s whatever the project units ([2D_INITIAL_VELOCITY] U and V).
 
double initV = 0.0
 [2D_INITIAL_VELOCITY] V: map-Y velocity in m/s; see initU.
 

Detailed Description

A cell in the mesh — a triangle or (since the engine's mixed tri-quad meshes, workplans/TRI_QUAD_MESHING_PLAN_2026-09-06.md) a convex quadrilateral — indices into MeshResult::vertices.

The historical name is kept: every consumer that reads v0/v1/v2 still compiles, and a quad simply carries a fourth vertex v3 >= 0 (cyclic order, either orientation). Use vertexCount / vertex and the helpers in mesh/meshcellgeom.h (edgeEndpoints, edgeSlot, cellGeom) instead of hard-coding 3.

Engine contract (plans/2D_TRI_QUAD_MESH_PLAN_2026-09-06.md): cells are written triangles first, then quads ([2D_TRIANGLES] then [2D_QUADS]); local edge k has endpoints v[(k+1)nv], v[(k+2)nv] — for a triangle the old "edge opposite vertex" rule. MeshResult::triangles keeps the engine's cell order.

Member Function Documentation

◆ hasVertex()

bool mesh::MeshTriangle::hasVertex ( int v) const
inlinenoexcept

Check whether an identifier equals a stored logical corner.

Parameters
[in]vIdentifier to compare, including negative values; no mesh bounds validation.
Returns
True for equality with v0, v1 or v2, or with a nonnegative v3; false otherwise. Negative values in the first three slots can match, while an absent fourth corner cannot. Constant read-only work, with no geometry lookup or allocation.
Here is the caller graph for this function:

◆ isQuad()

bool mesh::MeshTriangle::isQuad ( ) const
inlinenoexcept

Classify the cell solely by whether a fourth vertex identifier is present.

Returns
True when v3 is nonnegative, false otherwise; no bounds, distinctness or geometry validation. Constant read-only work, with no allocation or topology mutation.
Here is the caller graph for this function:

◆ setVertex()

void mesh::MeshTriangle::setVertex ( int k,
int v )
inlinenoexcept

Replace a stored corner identifier, leaving every other cell attribute unchanged.

Parameters
[in]kStorage slot 0..3; values outside this range are ignored.
[in]vIdentifier to store, not checked against mesh bounds or other corners. Setting slot 3 nonnegative classifies the cell as a quad; a negative value classifies it as a triangle.
Note
Mutates this cell only; does not repair orientation, adjacency or associated mesh arrays. No allocation, ownership retention or error reporting.
Here is the caller graph for this function:

◆ vertex()

int mesh::MeshTriangle::vertex ( int k) const
inlinenoexcept

Fetch one stored corner identifier without a vertex-array lookup.

Parameters
[in]kStorage slot 0..3; ordinary callers use [0,vertexCount()).
Returns
Stored v0/v1/v2/v3 for slots 0/1/2/3 respectively, or -1 for all other slots. For a triangle, slot 3 returns its actual negative sentinel, which need not equal -1. No identifier validation, allocation or mutation.

Stored vertex slot k (0..3); -1 outside that storage range.

Here is the caller graph for this function:

◆ vertexCount()

int mesh::MeshTriangle::vertexCount ( ) const
inlinenoexcept

Report the logical corner count selected by the fourth-vertex sentinel.

Returns
Four when v3>=0, otherwise three, irrespective of the validity of stored identifiers. Constant read-only work; does not inspect the vertex array.
Here is the caller graph for this function:

Member Data Documentation

◆ initDepth

double mesh::MeshTriangle::initDepth = std::numeric_limits<double>::quiet_NaN()

Initial water depth in m ([2D_TRIANGLES] INIT_DEPTH, written between MANNINGS_N and TAG).

NaN = unset (column absent on load) — treated as the engine default 0 (dry) and omitted on write unless any triangle carries a depth or a tag (TAG position must stay unambiguous).

◆ initHgl

double mesh::MeshTriangle::initHgl = std::numeric_limits<double>::quiet_NaN()

Initial water-surface elevation in mesh length units on the vertex Z datum ([2D_INITIAL_HGL]).

NaN = not prescribed: the cell starts from initDepth. A finite value overrides initDepth; the engine converts it to a depth and clamps it at the cell invert when the run starts.

◆ initU

double mesh::MeshTriangle::initU = 0.0

Initial velocity components in m/s whatever the project units ([2D_INITIAL_VELOCITY] U and V).

0, 0 = at rest, the engine default; only moving cells are written.

◆ initV

double mesh::MeshTriangle::initV = 0.0

[2D_INITIAL_VELOCITY] V: map-Y velocity in m/s; see initU.

◆ mannings

double mesh::MeshTriangle::mannings = std::numeric_limits<double>::quiet_NaN()

Manning's roughness ([2D_TRIANGLES] MANNINGS_N).

NaN = unset, so the writer falls back to the caller's default (mesh generation uses a uniform value); a loaded mesh carries the per-triangle value.

◆ tag

QString mesh::MeshTriangle::tag

Region tag, for example a subcatchment ID; empty if untagged.

◆ v0

int mesh::MeshTriangle::v0 = 0

First corner: index into MeshResult::vertices (not range-checked here).

◆ v1

int mesh::MeshTriangle::v1 = 0

Second corner, cyclically after v0.

◆ v2

int mesh::MeshTriangle::v2 = 0

Third corner, cyclically after v1.

◆ v3

int mesh::MeshTriangle::v3 = -1

Fourth vertex of a quadrilateral; -1 = triangle.


The documentation for this struct was generated from the following file: