pub struct SdfGrid {
pub nx: usize,
pub ny: usize,
pub nz: usize,
pub origin: [f64; 3],
pub spacing: f64,
pub data: Vec<f64>,
}Expand description
A dense 3-D grid of SDF samples.
Fields§
§nx: usizeNumber of grid cells along X.
ny: usizeNumber of cells along Y.
nz: usizeNumber of cells along Z.
origin: [f64; 3]World-space coordinates of cell (0,0,0).
spacing: f64Uniform voxel spacing.
data: Vec<f64>Flat SDF samples in (z, y, x) major order.
Implementations§
Source§impl SdfGrid
impl SdfGrid
Sourcepub fn new(
nx: usize,
ny: usize,
nz: usize,
origin: [f64; 3],
spacing: f64,
) -> Self
pub fn new( nx: usize, ny: usize, nz: usize, origin: [f64; 3], spacing: f64, ) -> Self
Create an empty grid of given resolution and spacing.
Sourcepub fn from_sdf<S: Sdf>(
sdf: &S,
nx: usize,
ny: usize,
nz: usize,
origin: [f64; 3],
spacing: f64,
) -> Self
pub fn from_sdf<S: Sdf>( sdf: &S, nx: usize, ny: usize, nz: usize, origin: [f64; 3], spacing: f64, ) -> Self
Sample an SDF and fill the grid.
Sourcepub fn cell_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
pub fn cell_center(&self, ix: usize, iy: usize, iz: usize) -> [f64; 3]
World-space position of cell centre (ix, iy, iz).
Sourcepub fn get(&self, ix: usize, iy: usize, iz: usize) -> f64
pub fn get(&self, ix: usize, iy: usize, iz: usize) -> f64
Get the SDF value at integer index (ix, iy, iz).
Sourcepub fn set(&mut self, ix: usize, iy: usize, iz: usize, v: f64)
pub fn set(&mut self, ix: usize, iy: usize, iz: usize, v: f64)
Set the SDF value at integer index (ix, iy, iz).
Sourcepub fn interpolate(&self, p: [f64; 3]) -> f64
pub fn interpolate(&self, p: [f64; 3]) -> f64
Trilinearly interpolate the SDF at world-space point p.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SdfGrid
impl RefUnwindSafe for SdfGrid
impl Send for SdfGrid
impl Sync for SdfGrid
impl Unpin for SdfGrid
impl UnsafeUnpin for SdfGrid
impl UnwindSafe for SdfGrid
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.