pub struct SdfGrid {
pub dimensions: [usize; 3],
pub spacing: f64,
pub origin: [f64; 3],
pub data: Vec<f32>,
}Expand description
A regular 3-D grid that stores SDF values as f32.
Voxel (i, j, k) is centred at
origin + spacing * [i + 0.5, j + 0.5, k + 0.5].
Fields§
§dimensions: [usize; 3]Number of voxels along [x, y, z].
spacing: f64Uniform spacing between voxel centres.
origin: [f64; 3]World-space position of the grid’s lower-left-front corner.
data: Vec<f32>Flattened SDF values in x-major order (z slowest).
data[i + dims[0\] * (j + dims[1] * k)] corresponds to voxel (i,j,k).
Implementations§
Source§impl SdfGrid
impl SdfGrid
Sourcepub fn new(dimensions: [usize; 3], spacing: f64, origin: [f64; 3]) -> Self
pub fn new(dimensions: [usize; 3], spacing: f64, origin: [f64; 3]) -> Self
Allocate a new grid, filling every voxel with f32::MAX.
Sourcepub fn voxel_center(&self, i: usize, j: usize, k: usize) -> [f64; 3]
pub fn voxel_center(&self, i: usize, j: usize, k: usize) -> [f64; 3]
Return the world-space centre of voxel (i, j, k).
Sourcepub fn index(&self, i: usize, j: usize, k: usize) -> usize
pub fn index(&self, i: usize, j: usize, k: usize) -> usize
Flat linear index for voxel (i, j, k).
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<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>
Converts
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>
Converts
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