SpzGaussiansHeader

Struct SpzGaussiansHeader 

Source
pub struct SpzGaussiansHeader(/* private fields */);
Expand description

Header of SPZ Gaussians file.

This is the validated version of SpzGaussiansHeaderPod. This is simply a wrapper around SpzGaussiansHeaderPod that ensures the values are valid, we could also implement specialized structs for each field but it would be overkill for now.

Implementations§

Source§

impl SpzGaussiansHeader

Source

pub const MAGIC: u32 = 1_347_635_022u32

The magic number for SPZ Gaussians files.

Source

pub const SUPPORTED_VERSIONS: RangeInclusive<u32>

The supported SPZ versions.

Source

pub const SUPPORTED_SH_DEGREES: RangeInclusive<u8>

The supported SH degrees.

Source

pub fn new( version: u32, num_points: u32, sh_degree: SpzGaussianShDegree, fractional_bits: u8, antialiased: bool, ) -> Result<Self, Error>

Create a SpzGaussiansHeader.

Returns an error if the header is invalid.

Source

pub fn try_from_pod(pod: SpzGaussiansHeaderPod) -> Result<Self, Error>

Validate and create a validated SPZ Gaussians header.

Source

pub fn default(num_points: u32) -> Result<Self, Error>

Create a default SpzGaussiansHeader from number of points and SH degree.

Source

pub fn as_pod(&self) -> &SpzGaussiansHeaderPod

Source

pub fn version(&self) -> u32

Get the version of the SPZ file.

Source

pub fn set_num_points(&mut self, num_points: u32)

Set the number of points.

Setting the number of points does not invalidate the header.

Source

pub fn num_points(&self) -> usize

Get the number of points in the SPZ file.

Examples found in repository?
examples/write_spz.rs (line 55)
12fn main() {
13    let model_path = std::env::args()
14        .nth(1)
15        .unwrap_or_else(|| "target/output.spz".to_string());
16
17    let gaussians = [
18        gs::Gaussian {
19            rot: Quat::from_axis_angle((Vec3::X + Vec3::Y / 2.0 + Vec3::Z).normalize(), 0.5),
20            pos: Vec3::ZERO,
21            scale: Vec3::new(0.5, 1.0, 0.75),
22            color: U8Vec4::new(255, 0, 0, 255),
23            sh: [Vec3::ZERO; 15],
24        },
25        gs::Gaussian {
26            rot: Quat::from_axis_angle((Vec3::X + Vec3::Z / 3.0).normalize(), 0.3),
27            pos: Vec3::new(0.0, 8.0, 4.0),
28            scale: Vec3::new(1.0, 1.9, 0.75),
29            color: U8Vec4::new(0, 255, 0, 255),
30            sh: [Vec3::ZERO; 15],
31        },
32        gs::Gaussian {
33            rot: Quat::from_axis_angle((Vec3::X - Vec3::Z).normalize(), 0.2),
34            pos: Vec3::new(4.0, 0.0, 6.0),
35            scale: Vec3::new(1.0, 1.1, 0.8),
36            color: U8Vec4::new(0, 0, 255, 255),
37            sh: [Vec3::ZERO; 15],
38        },
39    ];
40
41    // Alternatively, use `SpzGaussians::from_gaussians` for default options.
42    let gaussians = gs::SpzGaussians::from_gaussians_with_options(
43        gaussians.as_slice(),
44        &gs::SpzGaussiansFromGaussianSliceOptions {
45            version: 2,
46            ..Default::default()
47        },
48    )
49    .expect("valid options");
50
51    println!("Header: {:?}", gaussians.header);
52
53    println!(
54        "Writing {} gaussians to {}",
55        gaussians.header.num_points(),
56        model_path
57    );
58
59    gaussians
60        .write_to_file(&model_path)
61        .expect("write SPZ file");
62}
Source

pub fn sh_degree(&self) -> SpzGaussianShDegree

Get the SH degree of the SPZ file.

Source

pub fn sh_num_coefficients(&self) -> usize

Get the number of SH coefficients.

Source

pub fn fractional_bits(&self) -> u8

Get the number of fractional bits.

Source

pub fn is_antialiased(&self) -> bool

Check if the antialiased flag is set.

Source

pub fn uses_float16(&self) -> bool

Check if float16 encoding is used.

Source

pub fn uses_quat_smallest_three(&self) -> bool

Check if quaternion smallest three encoding is used.

Trait Implementations§

Source§

impl Clone for SpzGaussiansHeader

Source§

fn clone(&self) -> SpzGaussiansHeader

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 SpzGaussiansHeader

Source§

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

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

impl PartialEq for SpzGaussiansHeader

Source§

fn eq(&self, other: &SpzGaussiansHeader) -> 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.
Source§

impl Copy for SpzGaussiansHeader

Source§

impl Eq for SpzGaussiansHeader

Source§

impl StructuralPartialEq for SpzGaussiansHeader

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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> 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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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