Skip to content

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:

Attributes

blend_width_factor pydantic-field

blend_width_factor: float = 1.2

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

decimation_depth: int = 0

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

decimation_tolerance_m: float = 1.0

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).

enabled pydantic-field

enabled: bool = True

Enable adaptive mesh refinement

flatten pydantic-field

flatten: bool = True

Flatten mesh vertices perpendicular to feature centerlines after refinement.

max_depth pydantic-field

max_depth: int = 2

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.

transition_buffer_m pydantic-field

transition_buffer_m: float = 20.0

Transition zone width outside feature edge (metres).