pub struct ScalarField2D {
pub rows: usize,
pub cols: usize,
pub data: Vec<f32>,
pub min: f32,
pub max: f32,
pub nan_value: Option<f32>,
pub generation: u64,
pub value_generation: u64,
}Expand description
A 2D scalar field aligned to a GeoGrid.
Values are stored row-major. Each cell stores a single f32 value.
The field tracks two generation counters:
generation– bumped when the grid topology changes (rows, cols).value_generation– bumped when only values change (same topology).
Renderers use these to choose between a full mesh rebuild and a texture-only upload.
Fields§
§rows: usizeNumber of rows.
cols: usizeNumber of columns.
data: Vec<f32>Row-major scalar values. Length must equal rows * cols.
min: f32Minimum value in the field (user-provided or computed).
max: f32Maximum value in the field (user-provided or computed).
nan_value: Option<f32>Optional sentinel value treated as missing data / NaN.
generation: u64Structural generation counter. Bump when rows/cols change.
value_generation: u64Value-only generation counter. Bump when values change but topology is unchanged.
Implementations§
Source§impl ScalarField2D
impl ScalarField2D
Sourcepub fn from_data(rows: usize, cols: usize, data: Vec<f32>) -> Self
pub fn from_data(rows: usize, cols: usize, data: Vec<f32>) -> Self
Create a field from raw data with automatic min/max computation.
nan_value samples are excluded from the min/max scan.
Sourcepub fn from_data_with_range(
rows: usize,
cols: usize,
data: Vec<f32>,
min: f32,
max: f32,
) -> Self
pub fn from_data_with_range( rows: usize, cols: usize, data: Vec<f32>, min: f32, max: f32, ) -> Self
Create a field with an explicit min/max range.
Sourcepub fn sample(&self, row: usize, col: usize) -> Option<f32>
pub fn sample(&self, row: usize, col: usize) -> Option<f32>
Sample the raw value at (row, col).
Returns None if out of bounds or if the value matches nan_value.
Sourcepub fn normalized(&self, row: usize, col: usize) -> Option<f32>
pub fn normalized(&self, row: usize, col: usize) -> Option<f32>
Sample the value at (row, col) normalized to [0.0, 1.0]
using the field min / max range.
Returns None if the sample is missing or if min == max.
Sourcepub fn update_values(&mut self, new_data: Vec<f32>)
pub fn update_values(&mut self, new_data: Vec<f32>)
Replace values in place, bump value_generation, and recompute
min/max.
Panics if new_data.len() != rows * cols.
Trait Implementations§
Source§impl Clone for ScalarField2D
impl Clone for ScalarField2D
Source§fn clone(&self) -> ScalarField2D
fn clone(&self) -> ScalarField2D
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more