pub struct SparseField<T: Float> { /* private fields */ }Expand description
3-dimensional sparse field for scalar values.
The field uses a three-level hierarchical structure:
- A dynamic root node that can be subdivided arbitrarily (e.g., 1x1x2, 2x2x2, etc.)
- Internal nodes with a fixed subdivision pattern defined by
BlockSize - Dense leaf nodes containing the actual field data
This structure provides a balance between memory efficiency and computational performance, allowing dense sampling only in regions where the field is active. Empty or uniform regions can be efficiently represented at the internal node level.
Note: This type should not be constructed directly. Instead, use ~SparseSampler
to sample and extract a sparse field from an implicit model.
Implementations§
Source§impl<T: Float> SparseField<T>
impl<T: Float> SparseField<T>
Sourcepub fn new(config: SparseFieldConfig<T>) -> Self
pub fn new(config: SparseFieldConfig<T>) -> Self
Creates a new empty sparse field with the given configuration.
§Arguments
config- The configuration specifying block sizes and sampling mode.
Sourcepub fn init_bounds(&mut self, bounds: &BoundingBox<T>)
pub fn init_bounds(&mut self, bounds: &BoundingBox<T>)
Initializes the field’s bounds and activates the necessary internal nodes.
§Arguments
bounds- The bounding box defining the field’s extents.
Source§impl<T: ModelFloat + 'static + Default> SparseField<T>
impl<T: ModelFloat + 'static + Default> SparseField<T>
Sourcepub fn n_active_nodes(&self) -> usize
pub fn n_active_nodes(&self) -> usize
Compute the total number of active leaf nodes.
Trait Implementations§
Source§impl<T: Float + 'static> CellIterator<T> for SparseField<T>
impl<T: Float + 'static> CellIterator<T> for SparseField<T>
Source§fn iter_cells<'a>(&'a self) -> Self::Iter<'a>
fn iter_cells<'a>(&'a self) -> Self::Iter<'a>
Returns an iterator that yields all cell coordinates in the leaf nodes in the sparse field.
Source§impl<T: Float + 'static> CellValueIterator<T> for SparseField<T>
impl<T: Float + 'static> CellValueIterator<T> for SparseField<T>
Source§impl<T: Clone + Float> Clone for SparseField<T>
impl<T: Clone + Float> Clone for SparseField<T>
Source§fn clone(&self) -> SparseField<T>
fn clone(&self) -> SparseField<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de, T> Deserialize<'de> for SparseField<T>where
T: Deserialize<'de> + Float,
impl<'de, T> Deserialize<'de> for SparseField<T>where
T: Deserialize<'de> + Float,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: Float + 'static> PointIterator<T> for SparseField<T>
impl<T: Float + 'static> PointIterator<T> for SparseField<T>
Source§impl<T: ModelFloat + 'static + Default> Sampler<T, SparseField<T>> for SparseSampler<T>
impl<T: ModelFloat + 'static + Default> Sampler<T, SparseField<T>> for SparseSampler<T>
Source§fn sample_field(
&mut self,
model: &ImplicitModel<T>,
) -> Result<&SparseField<T>, ModelError>
fn sample_field( &mut self, model: &ImplicitModel<T>, ) -> Result<&SparseField<T>, ModelError>
ImplicitModel::get_default_output Read moreSource§fn sample_field_for_component(
&mut self,
model: &ImplicitModel<T>,
component_tag: &str,
) -> Result<&SparseField<T>, ModelError>
fn sample_field_for_component( &mut self, model: &ImplicitModel<T>, component_tag: &str, ) -> Result<&SparseField<T>, ModelError>
Source§fn iso_surface(&self, iso_val: T) -> Result<Mesh<T>, ModelError>
fn iso_surface(&self, iso_val: T) -> Result<Mesh<T>, ModelError>
Source§fn field(&self) -> &SparseField<T>
fn field(&self) -> &SparseField<T>
Source§impl<T> Serialize for SparseField<T>
impl<T> Serialize for SparseField<T>
Source§impl<T: Float + 'static> ValueIterator<T> for SparseField<T>
impl<T: Float + 'static> ValueIterator<T> for SparseField<T>
Auto Trait Implementations§
impl<T> Freeze for SparseField<T>where
T: Freeze,
impl<T> RefUnwindSafe for SparseField<T>where
T: RefUnwindSafe,
impl<T> Send for SparseField<T>where
T: Send,
impl<T> Sync for SparseField<T>where
T: Sync,
impl<T> Unpin for SparseField<T>where
T: Unpin,
impl<T> UnwindSafe for SparseField<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more