Skip to main content

ScalarField2D

Struct ScalarField2D 

Source
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: usize

Number of rows.

§cols: usize

Number of columns.

§data: Vec<f32>

Row-major scalar values. Length must equal rows * cols.

§min: f32

Minimum value in the field (user-provided or computed).

§max: f32

Maximum value in the field (user-provided or computed).

§nan_value: Option<f32>

Optional sentinel value treated as missing data / NaN.

§generation: u64

Structural generation counter. Bump when rows/cols change.

§value_generation: u64

Value-only generation counter. Bump when values change but topology is unchanged.

Implementations§

Source§

impl ScalarField2D

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> ScalarField2D

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScalarField2D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.