Loading...
Searching...
No Matches
sizefield.hpp
Go to the documentation of this file.
1
48
49#ifndef MESHKIT_NATIVE_SIZEFIELD_HPP
50#define MESHKIT_NATIVE_SIZEFIELD_HPP
51
52#include <functional>
53
54namespace meshkit::plan
55{
56
60 bool footprintBounds = false;
64 double nearSize = 0.0;
65
71 double gradation = 0.25;
72
76 double areaFloor = 0.0;
77
81 std::int64_t maxGridCells = 4'000'000;
82
83 // ── Overhaul additions (MESH_OVERHAUL_PLAN_2026-09-29.md §3 Stage 2) ──
86 double maxSize = 0.0;
91 std::function<double(double, double)> terrainSizeAt;
93 struct Region {
99 double h = 0.0;
100 };
101
106
116};
117
126{
127public:
128 // Conservative bound on every bilinear target over this rectangle. Zero
129 // means unbounded/invalid field. Includes all interpolation support nodes.
141 double minimumSizeInBox(const Box2 &) const;
142 double minimumTerrainSizeInBox(const Box2 &)
143 const;
144
181 bool build(const Box2 &bbox, const Vector<ConstraintSegment> &segs,
182 const Vector<Vector<Point2>> &rings, const Vector<SteinerPoint> &pts,
183 const SizeFieldOptions &opt);
184
200 [[nodiscard]] double targetAreaAt(double x, double y) const;
218 [[nodiscard]] double sizeAt(double x, double y) const;
226 [[nodiscard]] bool isValid() const { return m_cols > 0 && m_rows > 0; }
234 [[nodiscard]] bool hasSizeBound() const { return isValid() && sizeAt(m_x0, m_y0) > 0.0; }
241 [[nodiscard]] double pitch() const { return m_pitch; }
247 [[nodiscard]] int cols() const { return m_cols; }
253 [[nodiscard]] int rows() const { return m_rows; }
254
268 [[nodiscard]] double distanceAt(double x, double y) const;
269
270private:
280 [[nodiscard]] double cellDist(int cx, int cy) const;
289 [[nodiscard]] double cellSize(int cx, int cy) const;
305 void buildSizeGrid(const SizeFieldOptions &opt, const Vector<float> &stepDist);
317 void stampSeedPoint(const Point2 &p, Vector<float> &into);
331 void stampSeedSegment(const Point2 &a, const Point2 &b, Vector<float> &into);
332
333 Vector<float> m_dist;
334 Vector<float> m_h;
335 struct MinLevel {
336 int columns, rows;
337 Vector<float> values;
338 };
339 Vector<MinLevel> m_minLevels;
340 double minimumSizeInBoxImpl(const Box2 &, bool includeTerrain) const;
341 struct RegionBound {
342 Box2 box;
343 double size = 0;
344 int end = 0;
345 bool terrainOnly = false;
346 };
347 Vector<RegionBound> m_regionBounds;
348 int m_cols = 0, m_rows = 0;
349 double m_x0 = 0.0, m_y0 = 0.0;
350 double m_pitch = 0.0;
351 double m_near = 0.0, m_g = 0.0, m_floor = 0.0;
352};
353
354} // namespace meshkit::plan
355
356#endif // MESHKIT_NATIVE_SIZEFIELD_HPP
Axis-aligned rectangle in the XY plane, stored as an origin corner and a signed size.
Definition geometry.hpp:167
Point or displacement vector in the horizontal (XY) plane.
Definition geometry.hpp:21
std::vector<T> with the QVector-style member names the CDT kernel and plan model use.
Definition storage.hpp:31
Point sequence in XY units used for polygon rings and polylines.
Definition planmodel.hpp:83
Distance-to-feature field sampled as a max-area function.
Definition sizefield.hpp:126
double sizeAt(double x, double y) const
Bilinearly read the combined gradation-relaxed target edge length.
Definition sizefield.cpp:415
double minimumSizeInBox(const Box2 &) const
Conservative lower bound on the target edge length over a box.
Definition sizefield.cpp:288
bool isValid() const
Check whether stored grid dimensions are positive.
Definition sizefield.hpp:226
bool hasSizeBound() const
Check whether the valid field reports a positive size at its first grid-center coordinate.
Definition sizefield.hpp:234
double targetAreaAt(double x, double y) const
Read the sampled equilateral-triangle area cap at a mesh coordinate.
Definition sizefield.cpp:507
double pitch() const
Read the background grid spacing retained by the latest layout attempt.
Definition sizefield.hpp:241
int cols() const
Read the number of grid columns.
Definition sizefield.hpp:247
bool build(const Box2 &bbox, const Vector< ConstraintSegment > &segs, const Vector< Vector< Point2 > > &rings, const Vector< SteinerPoint > &pts, const SizeFieldOptions &opt)
Replace this field with sampled feature-distance, terrain and region size bounds.
Definition sizefield.cpp:173
double minimumTerrainSizeInBox(const Box2 &) const
Includes finer directional source bounds without changing nominal sizing.
Definition sizefield.cpp:292
int rows() const
Read the number of grid rows.
Definition sizefield.hpp:253
double distanceAt(double x, double y) const
Bilinearly read the approximate chamfer distance-to-feature grid.
Definition sizefield.cpp:490
Box2 box(const Point2 *p, int n)
Axis-aligned bounding box of a point array.
Definition operation.hpp:131
Planning algorithms on standard containers: quad patch planning and placement, size fields,...
Polygon overrides: inside ring the size is min'd with h.
Definition sizefield.hpp:93
double h
Size cap in mesh units.
Definition sizefield.hpp:99
Polygon ring
Implicitly closed polygon.
Definition sizefield.hpp:96
Inputs to SizeField::build(): feature grading, caps, floor, terrain term and polygon overrides.
Definition sizefield.hpp:59
double areaFloor
Refinement floor A_min (map units², from MinSizePolicy).
Definition sizefield.hpp:76
bool footprintBounds
Build a compact min pyramid for verified sizing.
Definition sizefield.hpp:60
double maxSize
Upper clamp on the size (h_max, map units); 0 = unbounded.
Definition sizefield.hpp:86
Vector< Vector< Point2 > > steps
Terrain break lines (mesh coordinates) that the generator lays mesh edges along (MESH_TRIANGLE_ENGINE...
Definition sizefield.hpp:115
Vector< Region > terrainRegions
Finer prescribed directional scales; footprint terrain queries only.
Definition sizefield.hpp:105
double nearSize
Element size (edge length, map units) AT a feature.
Definition sizefield.hpp:64
Vector< Region > regions
Size caps applied at grid centres inside each ring, and by bounding box in SizeField::minimumSizeInBo...
Definition sizefield.hpp:103
std::function< double(double, double)> terrainSizeAt
Terrain-error size bound in mesh units at a mesh coordinate (mesh::TerrainSizeField through the worke...
Definition sizefield.hpp:91
std::int64_t maxGridCells
Nominal background-grid cell budget.
Definition sizefield.hpp:81
double gradation
Lipschitz slope g: how fast the target size may grow per unit of distance from a feature.
Definition sizefield.hpp:71