Grid3

Struct Grid3 

Source
pub struct Grid3<T = f32> { /* private fields */ }
Expand description

Stores values on a 3D cube lattice on the coordinates [0,0,0] - [w-1, h-1, d-1]. A 3D tensor, basically.

TODO (nummelin): Should we separate storage so we can store just a bitset of inside/outside (which is enough for most uses).

Implementations§

Source§

impl<T> Grid3<T>

Source

pub fn data(&self) -> &[T]

flat data

Source

pub fn size(&self) -> Index3

Source§

impl<T: SignedDistance + Copy + Clone + Default> Grid3<T>

Source

pub fn new(size: Index3) -> Self

Source

pub fn set(&mut self, f: impl FnMut(Index3) -> T)

Set the grid values using the given function.

Source§

impl<T> Grid3<T>
where T: SignedDistance,

Source

pub fn gradient_clamped(&self, p: Index3) -> Vec3

Returns the distance gradient at the given coordinate. Coordinate must be within the grid.

Source

pub fn fast_gradient( &self, x: usize, y: usize, z: usize, i: usize, ys: usize, zs: usize, ) -> Vec3

Returns a fast approximation of the distance gradient at the given coordinate.

Coordinate must be within the grid.

Source

pub fn set_truncated_sync( &mut self, sdf: impl Fn(Index3) -> T + Send + Sync, truncate_dist: f32, )

Will set all values closer than the given truncate distance

Cells outside the given truncate distance will have approximated distances.

Will run synchronously regardless of with_rayon feature availability.

Source

pub fn set_truncated( &mut self, sdf: impl Fn(Index3) -> T + Send + Sync, truncate_dist: f32, )

Will set all values closer than the given truncate distance

Cells outside the given truncate distance will have approximated distances.

Source§

impl<T> Grid3<T>
where T: SignedDistance,

Source

pub fn marching_cubes_with_color( &self, color: impl Fn(Vec3) -> Vec3 + Send + Sync, ) -> TriangleMesh

Gives a mesh using colors from the given function

Source

pub fn marching_cubes(&self) -> TriangleMesh

Does NOT return colors

Trait Implementations§

Source§

impl<T> Index<[usize; 3]> for Grid3<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, p: Index3) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<[usize; 3]> for Grid3<T>

Source§

fn index_mut(&mut self, p: Index3) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: PartialEq> PartialEq for Grid3<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T> Freeze for Grid3<T>

§

impl<T> RefUnwindSafe for Grid3<T>
where T: RefUnwindSafe,

§

impl<T> Send for Grid3<T>
where T: Send,

§

impl<T> Sync for Grid3<T>
where T: Sync,

§

impl<T> Unpin for Grid3<T>
where T: Unpin,

§

impl<T> UnwindSafe for Grid3<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.