Skip to main content

DynVolume

Enum DynVolume 

Source
#[non_exhaustive]
pub enum DynVolume { U8(Volume<u8>), I8(Volume<i8>), U16(Volume<u16>), I16(Volume<i16>), U32(Volume<u32>), I32(Volume<i32>), F32(Volume<f32>), F64(Volume<f64>), }
Expand description

A volume whose scalar type is determined at runtime.

This enum lets a consumer store any supported scalar flavour behind one handle without carrying T as a generic parameter.

§VTK Equivalent

vtkImageData::GetScalarType() — a runtime tag rather than a compile-time type.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

U8(Volume<u8>)

Unsigned 8-bit integer voxels.

§

I8(Volume<i8>)

Signed 8-bit integer voxels.

§

U16(Volume<u16>)

Unsigned 16-bit integer voxels.

§

I16(Volume<i16>)

Signed 16-bit integer voxels (most common for CT Hounsfield units).

§

U32(Volume<u32>)

Unsigned 32-bit integer voxels.

§

I32(Volume<i32>)

Signed 32-bit integer voxels.

§

F32(Volume<f32>)

32-bit floating-point voxels.

§

F64(Volume<f64>)

64-bit floating-point voxels.

Implementations§

Source§

impl DynVolume

Source

pub fn as_bytes(&self) -> &[u8]

Raw byte slice of the underlying voxel data, suitable for GPU upload.

Source

pub fn scalar_range(&self) -> (f64, f64)

The (min, max) scalar range, normalised to f64.

Source

pub fn sample_linear(&self, ijk: DVec3) -> Option<f64>

Sample with trilinear interpolation at a continuous voxel index.

Source

pub fn bytes_per_component(&self) -> usize

Number of bytes per scalar component.

Trait Implementations§

Source§

impl Clone for DynVolume

Source§

fn clone(&self) -> DynVolume

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DynVolume

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Volume<f32>> for DynVolume

Source§

fn from(v: Volume<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<f64>> for DynVolume

Source§

fn from(v: Volume<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<i16>> for DynVolume

Source§

fn from(v: Volume<i16>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<i32>> for DynVolume

Source§

fn from(v: Volume<i32>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<i8>> for DynVolume

Source§

fn from(v: Volume<i8>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<u16>> for DynVolume

Source§

fn from(v: Volume<u16>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<u32>> for DynVolume

Source§

fn from(v: Volume<u32>) -> Self

Converts to this type from the input type.
Source§

impl From<Volume<u8>> for DynVolume

Source§

fn from(v: Volume<u8>) -> Self

Converts to this type from the input type.
Source§

impl VolumeInfo for DynVolume

Source§

fn dimensions(&self) -> UVec3

Number of voxels along each axis: [nx, ny, nz].
Source§

fn spacing(&self) -> DVec3

Physical size of each voxel in world units (typically millimetres).
Source§

fn origin(&self) -> DVec3

World-space position of voxel (0, 0, 0).
Source§

fn direction(&self) -> DMat3

3×3 orientation matrix whose columns are the axis directions. For axis-aligned volumes this is the identity matrix.
Source§

fn components(&self) -> u32

Number of scalar values stored per voxel (1 for grayscale).
Source§

fn index_to_world(&self, ijk: DVec3) -> DVec3

Convert a continuous voxel index (i, j, k) to world coordinates. Read more
Source§

fn world_to_index(&self, xyz: DVec3) -> DVec3

Convert world coordinates to a continuous voxel index. Read more
Source§

fn world_bounds(&self) -> Aabb

Axis-aligned bounding box enclosing all voxel centres in world space.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.