Struct parry3d_f64::transformation::voxelization::VoxelSet

source ·
pub struct VoxelSet {
    pub origin: Point<Real>,
    pub scale: Real,
    /* private fields */
}
Expand description

A sparse set of voxels.

It only contains voxels that are considered as “full” after a voxelization.

Fields§

§origin: Point<Real>

The 3D origin of this voxel-set.

§scale: Real

The scale factor between the voxel integer coordinates and their actual float world-space coordinates.

Implementations§

source§

impl VoxelSet

source

pub fn new() -> Self

Creates a new empty set of voxels.

source

pub fn voxel_volume(&self) -> Real

The volume of a single voxel of this voxel set.

source

pub fn voxelize( points: &[Point<Real>], indices: &[[u32; 3]], resolution: u32, fill_mode: FillMode, keep_voxel_to_primitives_map: bool ) -> Self

Voxelizes the given shape described by its boundary: a triangle mesh (in 3D) or polyline (in 2D).

§Parameters
  • points - The vertex buffer of the boundary of the shape to voxelize.
  • indices - The index buffer of the boundary of the shape to voxelize.
  • resolution - Controls the number of subdivision done along each axis. This number is the number of subdivisions along the axis where the input shape has the largest extent. The other dimensions will have a different automatically-determined resolution (in order to keep the voxels cubic).
  • fill_mode - Controls what is being voxelized.
  • keep_voxel_to_primitives_map - If set to true a map between the voxels and the primitives (3D triangles or 2D segments) it intersects will be computed.
source

pub fn min_bb_voxels(&self) -> Point<u32>

The minimal coordinates of the integer bounding-box of the voxels in this set.

source

pub fn max_bb_voxels(&self) -> Point<u32>

The maximal coordinates of the integer bounding-box of the voxels in this set.

source

pub fn compute_volume(&self) -> Real

Computes the total volume of the voxels contained by this set.

source

pub fn is_empty(&self) -> bool

Does this voxel not contain any element?

source

pub fn len(&self) -> usize

The number of voxels in this set.

source

pub fn voxels(&self) -> &[Voxel]

The set of voxels.

source

pub fn compute_bb(&mut self)

Update the bounding box of this voxel set.

source

pub fn compute_exact_convex_hull( &self, points: &[Point<Real>], indices: &[[u32; 3]] ) -> (Vec<Point<Real>>, Vec<[u32; 3]>)

Compute the convex-hull of this voxel set after cutting each voxel by the primitives (3D triangle or 2D segments) it intersects.

This will panic if this VoxelSet was created with keep_voxel_to_primitives_map = false.

source

pub fn compute_primitive_intersections( &self, points: &[Point<Real>], indices: &[[u32; 3]] ) -> Vec<Point<Real>>

Computes the intersections between all the voxels of this voxel set, and all the primitives (triangle or segments) it intersected (as per the voxel-to-primitives-map computed during voxelization).

Panics if the voxelization was performed without setting the parameter voxel_to_primitives_map = true.

source

pub fn compute_convex_hull( &self, sampling: u32 ) -> (Vec<Point<Real>>, Vec<[u32; 3]>)

Compute the convex-hull of the voxels in this set.

§Parameters
  • sampling - The convex-hull computation will ignore sampling voxels at regular intervals. Useful to save some computation times if an exact result isn’t need. Use 0 to make sure no voxel is being ignored.
source

pub fn to_trimesh( &self, base_index: u32, is_on_surface: bool ) -> (Vec<Point<Real>>, Vec<[u32; 3]>)

Convert self into a mesh, including only the voxels on the surface or only the voxel inside of the volume.

Trait Implementations§

source§

impl Default for VoxelSet

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<VoxelizedVolume> for VoxelSet

source§

fn from(shape: VoxelizedVolume) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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.