Adaptive Mesh
Configuration for the adaptive quadtree terrain mesh. See Adaptive terrain mesh for the concept and Adaptive mesh configuration for usage.
s2gos_generator.core.config.mesh_refinement.MeshRefinementConfig
pydantic-model
Bases: BaseModel
Adaptive quadtree mesh refinement configuration.
When enabled, the terrain mesh is refined under feature polygons (e.g. roads) and a surrounding transition buffer. Feature vertices are optionally flattened after refinement.
Presence (non-None) in SceneGenConfig does not enable refinement by
itself — enabled must also be True.
Fields:
-
enabled(bool) -
max_depth(int) -
flatten(bool) -
transition_buffer_m(float) -
blend_width_factor(float) -
decimation_depth(int) -
decimation_tolerance_m(float)
Attributes
blend_width_factor
pydantic-field
Width multiplier for the blend zone at feature polygon edges. Vertices beyond factor × half_feature_width blend back to original elevation.
decimation_depth
pydantic-field
Base-grid coarsening factor (powers of 2). 0 = no decimation (base grid = DEM resolution). n = base cells are 2^n × DEM pitch; cells are refined back toward DEM resolution where elevation variation within a cell exceeds decimation_tolerance_m.
decimation_tolerance_m
pydantic-field
Maximum plane-residual (metres) within a coarse cell that triggers subdivision during decimation. Measured as the largest absolute deviation from the least-squares plane fitted to the DEM block — smooth sloped terrain has near-zero residual and stays coarse, while genuinely rough terrain is subdivided. Lower = more detail, bigger mesh. 0 disables the tolerance check (always refine). Note: this replaced the former peak-to-peak metric; re-tune existing values (typical: 0.1–1.0 m for most scenes).
flatten
pydantic-field
Flatten mesh vertices perpendicular to feature centerlines after refinement.
max_depth
pydantic-field
Maximum quadtree refinement depth (each level doubles resolution). Ceiling of 4 is enforced by the uint64 cell encoding: each cell packs depth (4 bits), column i (30 bits), and row j (30 bits). At depth 4 the effective grid is nx<<4 × ny<<4; a DEM larger than ~67 k cells per axis would overflow the 30-bit field. Typical scenes (≤1000 cells/axis) are safe well beyond depth 4, but the cap prevents accidental memory blowup.