pub struct GpuVoxelGrid {
pub nx: usize,
pub ny: usize,
pub nz: usize,
pub voxel_size: f64,
pub occupancy: Vec<bool>,
pub sdf: Vec<f64>,
}Expand description
A 3-D voxel grid storing binary occupancy and an SDF.
Dimensions are [nx, ny, nz] with voxel size voxel_size.
Data is stored in Z-major order: index = x + nx*(y + ny*z).
Fields§
§nx: usizeNumber of voxels along X.
ny: usizeNumber of voxels along Y.
nz: usizeNumber of voxels along Z.
voxel_size: f64Physical size of each voxel (assumed isotropic).
occupancy: Vec<bool>Binary occupancy: true = filled.
sdf: Vec<f64>Signed Distance Field values (positive = outside, negative = inside).
Implementations§
Source§impl GpuVoxelGrid
impl GpuVoxelGrid
Sourcepub fn new(nx: usize, ny: usize, nz: usize, voxel_size: f64) -> Self
pub fn new(nx: usize, ny: usize, nz: usize, voxel_size: f64) -> Self
Allocate an empty voxel grid of size nx × ny × nz.
Sourcepub fn index(&self, x: usize, y: usize, z: usize) -> usize
pub fn index(&self, x: usize, y: usize, z: usize) -> usize
Flatten (x, y, z) grid coordinates to a linear index.
§Panics
In debug builds, panics if any coordinate is out of range.
Sourcepub fn coords(&self, idx: usize) -> (usize, usize, usize)
pub fn coords(&self, idx: usize) -> (usize, usize, usize)
Convert a linear index back to (x, y, z) coordinates.
Sourcepub fn occupied_count(&self) -> usize
pub fn occupied_count(&self) -> usize
Count occupied voxels.
Trait Implementations§
Source§impl Clone for GpuVoxelGrid
impl Clone for GpuVoxelGrid
Source§fn clone(&self) -> GpuVoxelGrid
fn clone(&self) -> GpuVoxelGrid
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GpuVoxelGrid
impl RefUnwindSafe for GpuVoxelGrid
impl Send for GpuVoxelGrid
impl Sync for GpuVoxelGrid
impl Unpin for GpuVoxelGrid
impl UnsafeUnpin for GpuVoxelGrid
impl UnwindSafe for GpuVoxelGrid
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