pub struct DenseField<T> { /* private fields */ }Expand description
3-dimensional dense field for scalar values.
A uniform grid representation that stores field values at every point in the sampling domain. The field geometry is defined by:
- An origin point defining the minimum corner of the field
- A uniform cell size for all dimensions
- The number of points in x, y, and z directions
The field stores values in a contiguous array, providing efficient access and parallel processing capabilities. This representation is memory-intensive but offers fast random access and is well-suited for operations like smoothing and iso-surface extraction.
Note: This type should not be constructed directly. Instead, use ~DenseSampler
to sample and extract a dense field from an implicit model.
Implementations§
Source§impl<T> DenseField<T>
impl<T> DenseField<T>
Sourcepub fn origin(&self) -> &Vec3<T>
pub fn origin(&self) -> &Vec3<T>
Returns a reference to the origin point of the field as a Vec3<T>.
Sourcepub fn num_points(&self) -> usize
pub fn num_points(&self) -> usize
Returns the total number of points in the field as the product of points in each direction.
Source§impl<T: Float> DenseField<T>
impl<T: Float> DenseField<T>
Sourcepub fn new(origin: Vec3<T>, cell_size: T, num_pts: Vec3i) -> Self
pub fn new(origin: Vec3<T>, cell_size: T, num_pts: Vec3i) -> Self
Create a new empty field.
§Arguments
origin- The base of the field, and the first data location.cell_size- The size of each cell in the field.num_pts- Number of points in each direction.
§Returns
A new DenseField initialized with zeros and the specified parameters.
Sourcepub fn from_bounds(bounds: BoundingBox<T>, cell_size: T) -> Self
pub fn from_bounds(bounds: BoundingBox<T>, cell_size: T) -> Self
Create a new empty field from bounds and a cell size.
§Arguments
bounds- The extents of the field.cell_size- The size of each cell in the field.
§Returns
A new DenseField initialized with zeros and dimensions derived from the bounds and cell size.
Sourcepub fn from_data(
origin: Vec3<T>,
cell_size: T,
num_pts: Vec3i,
data: Vec<T>,
) -> Result<Self, ModelError>
pub fn from_data( origin: Vec3<T>, cell_size: T, num_pts: Vec3i, data: Vec<T>, ) -> Result<Self, ModelError>
Create a new field from a data buffer.
The size of the data buffer must match the specified point count.
§Arguments
origin- The base of the field, and the first value location in space.cell_size- The size of each cell in the field.num_pts- Number of points in each direction.data- The data buffer.
§Returns
Ok with the generated DenseField if the data matches the point count, or Err if the data doesn’t match.
Sourcepub fn set_value(&mut self, index: usize, value: T)
pub fn set_value(&mut self, index: usize, value: T)
Sets the value at a specific index in the data buffer.
§Arguments
index- The 1D index in the data buffer.value- The new value to set.
Sourcepub fn threshold(&mut self, limit: T)
pub fn threshold(&mut self, limit: T)
Assigns 0 to any point with an absolute value below the limit.
§Arguments
limit- The limit threshold for non-zero values.
Sourcepub fn smooth(&mut self, factor: T, iterations: u32)
pub fn smooth(&mut self, factor: T, iterations: u32)
Performs a laplacian smoothing operation on the field data.
The value of each point will be updated based on the average of the adjacent points.
§Arguments
factor- Interpolation value between the average of the adjacent points and the current value.iterations- Number of successive smoothing iterations.
Source§impl<T: ModelFloat + 'static> DenseField<T>
impl<T: ModelFloat + 'static> DenseField<T>
Sourcepub fn smooth_par(&mut self, factor: T, iterations: u32)
pub fn smooth_par(&mut self, factor: T, iterations: u32)
Performs a laplacian smoothing operation on the field data using parallel iteration.
The value of each point will be updated based on the average of the adjacent points.
This is a parallel version of the smooth method.
§Arguments
factor- Interpolation value between the average of the adjacent points and the current value.iterations- Number of successive smoothing iterations.
Trait Implementations§
Source§impl<T: Float> CellGridIterator<T> for DenseField<T>
impl<T: Float> CellGridIterator<T> for DenseField<T>
Source§fn iter_cell_grid(&self) -> CellGridIter<T> ⓘ
fn iter_cell_grid(&self) -> CellGridIter<T> ⓘ
Returns an iterator that yields all cell coordinates in the field grid.
Source§type GridIter<'a> = CellGridIter<T>
where
Self: 'a
type GridIter<'a> = CellGridIter<T> where Self: 'a
'a.Source§impl<T: Float> CellIterator<T> for DenseField<T>
impl<T: Float> CellIterator<T> for DenseField<T>
Source§fn iter_cells(&self) -> CellGridIter<T> ⓘ
fn iter_cells(&self) -> CellGridIter<T> ⓘ
Returns an iterator that yields all cell coordinates in the field.
Source§type Iter<'a> = CellGridIter<T>
where
T: 'a
type Iter<'a> = CellGridIter<T> where T: 'a
Iterator<Item=BoundingBox<T>> for each borrow‐lifetime 'a.Source§impl<T: Float> CellValueIterator<T> for DenseField<T>
impl<T: Float> CellValueIterator<T> for DenseField<T>
Source§fn iter_cell_values<'a>(&'a self) -> Self::Iter<'a>
fn iter_cell_values<'a>(&'a self) -> Self::Iter<'a>
Returns an iterator that yields the values at each cell’s corners.
Source§type Iter<'a> = DenseCellValueIterator<'a, T>
where
Self: 'a
type Iter<'a> = DenseCellValueIterator<'a, T> where Self: 'a
Iterator<Item=[T;8]> for each borrow‐lifetime 'a.Source§impl<T: Clone> Clone for DenseField<T>
impl<T: Clone> Clone for DenseField<T>
Source§fn clone(&self) -> DenseField<T>
fn clone(&self) -> DenseField<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Debug> Debug for DenseField<T>
impl<T: Debug> Debug for DenseField<T>
Source§impl<'de, T> Deserialize<'de> for DenseField<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for DenseField<T>where
T: Deserialize<'de>,
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> GridIterator<T> for DenseField<T>
impl<T: Float> GridIterator<T> for DenseField<T>
Source§impl<T: Float> PointIterator<T> for DenseField<T>
impl<T: Float> PointIterator<T> for DenseField<T>
Source§fn iter_points(&self) -> PointGridIter<T> ⓘ
fn iter_points(&self) -> PointGridIter<T> ⓘ
Returns an iterator that yields all point coordinates in the field.
Source§type Iter<'a> = PointGridIter<T>
where
T: 'a
type Iter<'a> = PointGridIter<T> where T: 'a
Iterator<Item=Vec3<T>> for each borrow‐lifetime 'a.Source§impl<T: ModelFloat> Sampler<T, DenseField<T>> for DenseSampler<T>
impl<T: ModelFloat> Sampler<T, DenseField<T>> for DenseSampler<T>
Source§fn sample_field(
&mut self,
model: &ImplicitModel<T>,
) -> Result<&DenseField<T>, ModelError>
fn sample_field( &mut self, model: &ImplicitModel<T>, ) -> Result<&DenseField<T>, ModelError>
ImplicitModel::get_default_output Read moreSource§fn sample_field_for_component(
&mut self,
model: &ImplicitModel<T>,
component_tag: &str,
) -> Result<&DenseField<T>, ModelError>
fn sample_field_for_component( &mut self, model: &ImplicitModel<T>, component_tag: &str, ) -> Result<&DenseField<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) -> &DenseField<T>
fn field(&self) -> &DenseField<T>
Source§impl<T> Serialize for DenseField<T>where
T: Serialize,
impl<T> Serialize for DenseField<T>where
T: Serialize,
Source§impl<T: Float + 'static> ValueIterator<T> for DenseField<T>
impl<T: Float + 'static> ValueIterator<T> for DenseField<T>
Auto Trait Implementations§
impl<T> Freeze for DenseField<T>where
T: Freeze,
impl<T> RefUnwindSafe for DenseField<T>where
T: RefUnwindSafe,
impl<T> Send for DenseField<T>where
T: Send,
impl<T> Sync for DenseField<T>where
T: Sync,
impl<T> Unpin for DenseField<T>where
T: Unpin,
impl<T> UnwindSafe for DenseField<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