Loading...
Searching...
No Matches
mesh::SizeField Class Reference

Distance-to-feature field sampled as a max-area function. More...

#include <mesh/sizefield.h>

Collaboration diagram for mesh::SizeField:

Public Member Functions

double minimumSizeInBox (const QRectF &) const
 Smallest target edge length any point of a rectangle can read, for footprint (verified) sizing.
 
double minimumTerrainSizeInBox (const QRectF &) const
 Includes finer directional source bounds without changing nominal sizing.
 
bool build (const QRectF &bbox, const QVector< ConstraintSegment > &segs, const QVector< QVector< QPointF > > &rings, const QVector< SteinerPoint > &pts, const SizeFieldOptions &opt)
 Replace this field with sampled feature-distance, terrain and region size bounds.
 
double targetAreaAt (double x, double y) const
 Read the sampled equilateral-triangle area cap at a mesh coordinate.
 
double sizeAt (double x, double y) const
 Bilinearly read the combined gradation-relaxed target edge length.
 
bool isValid () const
 Check whether stored grid dimensions are positive.
 
bool hasSizeBound () const
 Check whether the valid field reports a positive size at its first grid-center coordinate.
 
double pitch () const
 Read the background grid spacing retained by the latest layout attempt.
 
int cols () const
 Read the number of grid columns.
 
int rows () const
 Read the number of grid rows.
 
double distanceAt (double x, double y) const
 Bilinearly read the approximate chamfer distance-to-feature grid.
 

Detailed Description

Distance-to-feature field sampled as a max-area function.

Build once per generation, then install hook.targetAreaAt = [&f](double x, double y){ return f.targetAreaAt(x,y); }. The field must outlive the mesh generation call that samples it.

Member Function Documentation

◆ build()

bool mesh::SizeField::build ( const QRectF & bbox,
const QVector< ConstraintSegment > & segs,
const QVector< QVector< QPointF > > & rings,
const QVector< SteinerPoint > & pts,
const SizeFieldOptions & opt )

Replace this field with sampled feature-distance, terrain and region size bounds.

Parameters
[in]bboxBorrowed finite valid positive-width/height rectangle in mesh planar units, unchanged.
[in]segsBorrowed feature paths, every consecutive segment seeds; finite coordinates and all grid/segment-step integer conversions must be representable, including features outside bbox.
[in]ringsBorrowed additional paths, consecutive segments seed; repeat the first point to close a ring, because no implicit closing segment is added. Empty/one-point paths contribute nothing.
[in]ptsBorrowed Steiner points; only nonzero-marker points seed, unchanged.
[in]optBorrowed sizing policy: positive finite nearSize/gradation, maxGridCells>=9; lengths in mesh units and areaFloor in squared units. Positive finite maxSize is an upper source bound; nonpositive/nonfinite maxSize is disabled. Terrain callback executes synchronously per grid center, returns a positive finite size or no bound, must not mutate/reenter this object; exceptions propagate.
Returns
False with cleared arrays/zero dimensions for invalid grid layout/budget, true after size construction, including valid unbounded seedless fields. Grid allocation may reach twice maxGridCells under the layout's border allowance, and no cancellation/error-text channel is provided. Old field is discarded at entry; allocation/callback exceptions can leave partial state that must be rebuilt. Copies numeric grids, retains no feature/policy/callback references; no geometry/engine mutation. Read-only queries may run concurrently only after successful build and without mutation.

Build the field. Returns false (and leaves the field invalid) for a degenerate bbox or nonsensical options. Without seeds each cell starts at maxSize or unbounded; terrain and region terms can supply local sizes. No size sources is a valid unbounded field.

segs constraint segments (conduits, aux lines) — every edge seeds. rings additional ring paths to seed (valid hole rings). pts Steiner points; only tagged ones (marker != 0) seed.

◆ cols()

int mesh::SizeField::cols ( ) const
inlinenodiscard

Read the number of grid columns.

Returns
Positive count after successful build, zero initially or after checked layout refusal. No allocation, geometry lookup or state mutation.

◆ distanceAt()

double mesh::SizeField::distanceAt ( double x,
double y ) const
nodiscard

Bilinearly read the approximate chamfer distance-to-feature grid.

Parameters
[in]xFinite mesh-coordinate x; normalized floor and +1 neighbor must fit int.
[in]yFinite mesh-coordinate y with the same precondition; outside queries clamp to grid edges.
Returns
Distance in planar mesh units, zero for invalid field and unseeded sentinel corner values. Thus zero can mean no seed information as well as coincidence. Sampled chamfer approximation is not an exact Euclidean distance or conservative refinement bound. No allocation/callback/state mutation.

Distance to the nearest seed at (x, y), bilinear over cell centres. Exposed for tests and diagnostics.

◆ hasSizeBound()

bool mesh::SizeField::hasSizeBound ( ) const
inlinenodiscard

Check whether the valid field reports a positive size at its first grid-center coordinate.

Returns
isValid() and sizeAt(m_x0,m_y0)>0. Under a successful connected-grid build, a finite source propagates throughout; this is not a geometry-wide exact constraint/coverage certificate. No allocation, callback or mutation; requires stable completed field data.

◆ isValid()

bool mesh::SizeField::isValid ( ) const
inlinenodiscard

Check whether stored grid dimensions are positive.

Returns
True for positive rows/columns, including a successfully built unbounded field; false initially or after checked build refusal. Does not verify arrays after an exception, source freshness or size bounds. Constant read-only query; require a completed successful build before sampling.

◆ minimumSizeInBox()

double mesh::SizeField::minimumSizeInBox ( const QRectF & b) const

Smallest target edge length any point of a rectangle can read, for footprint (verified) sizing.

Takes the minimum stored grid size over the cells covering the rectangle (clamped to the grid, including the extra bilinear support column/row), raises a positive result to the area-floor size, then takes the minimum with the h (also raised to that floor) of every positive regions entry whose bounding box intersects the rectangle. terrainRegions are ignored here (see minimumTerrainSizeInBox). Uses the min pyramid when SizeFieldOptions::footprintBounds was set, else scans cells.

Returns
Length in mesh units; 0 when the field is invalid, a rectangle coordinate is not finite, or nothing bounds the size there.

◆ minimumTerrainSizeInBox()

double mesh::SizeField::minimumTerrainSizeInBox ( const QRectF & b) const

Includes finer directional source bounds without changing nominal sizing.

◆ pitch()

double mesh::SizeField::pitch ( ) const
inlinenodiscard

Read the background grid spacing retained by the latest layout attempt.

Returns
Pitch in mesh planar units, initially zero; after failed build it may retain a prior/partial layout value. Check successful build/isValid() before interpreting it. Constant read-only query.

◆ rows()

int mesh::SizeField::rows ( ) const
inlinenodiscard

Read the number of grid rows.

Returns
Positive count after successful build, zero initially or after checked layout refusal. No allocation, geometry lookup or state mutation.

◆ sizeAt()

double mesh::SizeField::sizeAt ( double x,
double y ) const
nodiscard

Bilinearly read the combined gradation-relaxed target edge length.

Parameters
[in]xFinite mesh-coordinate x, normalized floor index must fit int with +1 headroom.
[in]yFinite mesh-coordinate y under the same index constraint; outside-grid samples clamp.
Returns
Mesh-unit target length, zero for invalid/missing grid or any unbounded interpolation-corner sentinel. Terrain/region/source minima and area floor affect stored values; floor can exceed maxSize. Uses float stored grid values and sampled octile grading, not an exact Euclidean or final-cell guarantee. No allocation, callback invocation or mutation; concurrent stable-field reads are safe.

Target edge length h(x, y) in map units: min over the feature-distance term, the terrain term and region overrides, clamped to [size of areaFloor, maxSize] and gradation-limited so that h(p) <= h(q) + gradation·|p − q| on the grid metric. Bilinear over cell centres. 0 on an invalid field.

◆ targetAreaAt()

double mesh::SizeField::targetAreaAt ( double x,
double y ) const
nodiscard

Read the sampled equilateral-triangle area cap at a mesh coordinate.

Parameters
[in]xFinite query x in the build's planar units; normalized floor and neighboring integer indices must fit int with +1 headroom. Outside-grid positions clamp to boundary samples.
[in]yFinite y coordinate under the same representable-query precondition.
Returns
sqrt(3)/4*h*h in squared mesh units raised to nonnegative areaFloor; zero for invalid or unbounded field. A minimum floor alone imposes no maximum on a field with no size source. No exact final-mesh refinement guarantee, coordinate conversion, allocation or state mutation.

Maximum permitted triangle area at (x, y) — the RefineHook contract. Returns 0 on an unbounded field; a minimum target does not impose a maximum area when no size source exists.


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