pub struct SpzGaussians {
pub header: SpzGaussiansHeader,
pub positions: SpzGaussiansPositions,
pub scales: Vec<[u8; 3]>,
pub rotations: SpzGaussiansRotations,
pub alphas: Vec<u8>,
pub colors: Vec<[u8; 3]>,
pub shs: SpzGaussiansShs,
}Expand description
A collection of Gaussians in SPZ format.
Fields§
§header: SpzGaussiansHeader§positions: SpzGaussiansPositions§scales: Vec<[u8; 3]>(x, y, z) each as 8-bit log-encoded integer.
rotations: SpzGaussiansRotations§alphas: Vec<u8>8-bit unsigned integer.
colors: Vec<[u8; 3]>(r, g, b) each as 8-bit unsigned integer.
shs: SpzGaussiansShsImplementations§
Source§impl SpzGaussians
impl SpzGaussians
Sourcepub fn read_decompressed(reader: &mut impl Read) -> Result<Self, Error>
pub fn read_decompressed(reader: &mut impl Read) -> Result<Self, Error>
Read a SPZ from a decompressed buffer.
reader should be decompressed SPZ buffer.
Sourcepub fn read_header(reader: &mut impl Read) -> Result<SpzGaussiansHeader, Error>
pub fn read_header(reader: &mut impl Read) -> Result<SpzGaussiansHeader, Error>
Read a SPZ header.
reader should be decompressed SPZ buffer.
Sourcepub fn read_gaussians(
reader: &mut impl Read,
header: SpzGaussiansHeader,
) -> Result<Self, Error>
pub fn read_gaussians( reader: &mut impl Read, header: SpzGaussiansHeader, ) -> Result<Self, Error>
Read the SPZ Gaussians.
reader should be decompressed SPZ buffer positioned after the header.
header may be parsed by calling SpzGaussians::read_header.
Sourcepub fn write_decompressed(&self, writer: &mut impl Write) -> Result<(), Error>
pub fn write_decompressed(&self, writer: &mut impl Write) -> Result<(), Error>
Write the Gaussians to a SPZ buffer.
writer will receive the decompressed SPZ buffer.
Sourcepub fn from_gaussians(
gaussians: impl IntoIterator<Item = impl AsRef<Gaussian>>,
) -> Self
pub fn from_gaussians( gaussians: impl IntoIterator<Item = impl AsRef<Gaussian>>, ) -> Self
Convert from a slice of Gaussians.
Sourcepub fn from_gaussians_with_options(
gaussians: impl IntoIterator<Item = impl AsRef<Gaussian>>,
options: &SpzGaussiansFromGaussianSliceOptions,
) -> Result<Self, Error>
pub fn from_gaussians_with_options( gaussians: impl IntoIterator<Item = impl AsRef<Gaussian>>, options: &SpzGaussiansFromGaussianSliceOptions, ) -> Result<Self, Error>
Convert from a slice of Gaussians with options.
Examples found in repository?
examples/write_spz.rs (lines 42-48)
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 from_iter(
header: SpzGaussiansHeader,
iter: impl IntoIterator<Item = SpzGaussian>,
) -> Result<Self, SpzGaussiansFromIterError>
pub fn from_iter( header: SpzGaussiansHeader, iter: impl IntoIterator<Item = SpzGaussian>, ) -> Result<Self, SpzGaussiansFromIterError>
Convert from an IntoIterator of SpzGaussians.
Sourcepub fn iter<'a>(
&'a self,
) -> impl ExactSizeIterator<Item = SpzGaussianRef<'a>> + 'a
pub fn iter<'a>( &'a self, ) -> impl ExactSizeIterator<Item = SpzGaussianRef<'a>> + 'a
Get an iterator over Gaussian references.
Trait Implementations§
Source§impl Clone for SpzGaussians
impl Clone for SpzGaussians
Source§fn clone(&self) -> SpzGaussians
fn clone(&self) -> SpzGaussians
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpzGaussians
impl Debug for SpzGaussians
Source§impl From<SpzGaussians> for Gaussians
impl From<SpzGaussians> for Gaussians
Source§fn from(value: SpzGaussians) -> Self
fn from(value: SpzGaussians) -> Self
Converts to this type from the input type.
Source§impl<G: AsRef<Gaussian>> FromIterator<G> for SpzGaussians
impl<G: AsRef<Gaussian>> FromIterator<G> for SpzGaussians
Source§fn from_iter<T: IntoIterator<Item = G>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = G>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl IterGaussian for SpzGaussians
impl IterGaussian for SpzGaussians
Source§fn iter_gaussian(&self) -> impl ExactSizeIterator<Item = Gaussian> + '_
fn iter_gaussian(&self) -> impl ExactSizeIterator<Item = Gaussian> + '_
Iterate over
Gaussian.Source§impl PartialEq for SpzGaussians
impl PartialEq for SpzGaussians
Source§impl ReadIterGaussian for SpzGaussians
impl ReadIterGaussian for SpzGaussians
Source§impl WriteIterGaussian for SpzGaussians
impl WriteIterGaussian for SpzGaussians
impl StructuralPartialEq for SpzGaussians
Auto Trait Implementations§
impl Freeze for SpzGaussians
impl RefUnwindSafe for SpzGaussians
impl Send for SpzGaussians
impl Sync for SpzGaussians
impl Unpin for SpzGaussians
impl UnwindSafe for SpzGaussians
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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