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
impl SpzGaussiansHeader
Sourcepub const SUPPORTED_VERSIONS: RangeInclusive<u32>
pub const SUPPORTED_VERSIONS: RangeInclusive<u32>
The supported SPZ versions.
Sourcepub const SUPPORTED_SH_DEGREES: RangeInclusive<u8>
pub const SUPPORTED_SH_DEGREES: RangeInclusive<u8>
The supported SH degrees.
Sourcepub fn new(
version: u32,
num_points: u32,
sh_degree: SpzGaussianShDegree,
fractional_bits: u8,
antialiased: bool,
) -> Result<Self, Error>
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.
Sourcepub fn try_from_pod(pod: SpzGaussiansHeaderPod) -> Result<Self, Error>
pub fn try_from_pod(pod: SpzGaussiansHeaderPod) -> Result<Self, Error>
Validate and create a validated SPZ Gaussians header.
Sourcepub fn default(num_points: u32) -> Result<Self, Error>
pub fn default(num_points: u32) -> Result<Self, Error>
Create a default SpzGaussiansHeader from number of points and SH degree.
Sourcepub fn as_pod(&self) -> &SpzGaussiansHeaderPod
pub fn as_pod(&self) -> &SpzGaussiansHeaderPod
Get the SpzGaussiansHeaderPod.
Sourcepub fn set_num_points(&mut self, num_points: u32)
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.
Sourcepub fn num_points(&self) -> usize
pub fn num_points(&self) -> usize
Get the number of points in the SPZ file.
Examples found in repository?
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}Sourcepub fn sh_degree(&self) -> SpzGaussianShDegree
pub fn sh_degree(&self) -> SpzGaussianShDegree
Get the SH degree of the SPZ file.
Sourcepub fn sh_num_coefficients(&self) -> usize
pub fn sh_num_coefficients(&self) -> usize
Get the number of SH coefficients.
Sourcepub fn fractional_bits(&self) -> u8
pub fn fractional_bits(&self) -> u8
Get the number of fractional bits.
Sourcepub fn is_antialiased(&self) -> bool
pub fn is_antialiased(&self) -> bool
Check if the antialiased flag is set.
Sourcepub fn uses_float16(&self) -> bool
pub fn uses_float16(&self) -> bool
Check if float16 encoding is used.
Sourcepub fn uses_quat_smallest_three(&self) -> bool
pub fn uses_quat_smallest_three(&self) -> bool
Check if quaternion smallest three encoding is used.
Trait Implementations§
Source§impl Clone for SpzGaussiansHeader
impl Clone for SpzGaussiansHeader
Source§fn clone(&self) -> SpzGaussiansHeader
fn clone(&self) -> SpzGaussiansHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpzGaussiansHeader
impl Debug for SpzGaussiansHeader
Source§impl PartialEq for SpzGaussiansHeader
impl PartialEq for SpzGaussiansHeader
impl Copy for SpzGaussiansHeader
impl Eq for SpzGaussiansHeader
impl StructuralPartialEq for SpzGaussiansHeader
Auto Trait Implementations§
impl Freeze for SpzGaussiansHeader
impl RefUnwindSafe for SpzGaussiansHeader
impl Send for SpzGaussiansHeader
impl Sync for SpzGaussiansHeader
impl Unpin for SpzGaussiansHeader
impl UnwindSafe for SpzGaussiansHeader
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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