gausplat_loader/source/colmap/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! COLMAP source.
//!
//! For more information, see the COLMAP [website](https://colmap.github.io/).

pub mod camera;
pub mod image;
pub mod point;

pub use super::file::*;
pub use camera::*;
pub use image::*;
pub use point::*;

use std::fmt;

/// Colmap source.
#[derive(Clone, PartialEq)]
pub struct ColmapSource<S> {
    /// Cameras.
    pub cameras: Cameras,
    /// Images.
    pub images: Images,
    /// Images' file.
    pub images_file: Files<S>,
    /// Points.
    pub points: Points,
}

impl<S> fmt::Debug for ColmapSource<S> {
    #[inline]
    fn fmt(
        &self,
        f: &mut fmt::Formatter<'_>,
    ) -> fmt::Result {
        f.debug_struct("ColmapSource")
            .field("cameras.len()", &self.cameras.len())
            .field("images.len()", &self.images.len())
            .field("images_file.len()", &self.images_file.len())
            .field("points.len()", &self.points.len())
            .finish()
    }
}

impl<S: Default> Default for ColmapSource<S> {
    #[inline]
    fn default() -> Self {
        Self {
            cameras: Default::default(),
            images_file: Default::default(),
            images: Default::default(),
            points: Default::default(),
        }
    }
}

#[cfg(test)]
mod tests {
    #[test]
    fn debug_and_default() {
        use super::*;

        let target = ColmapSource::<&[u8]> {
            cameras: Default::default(),
            images: Default::default(),
            images_file: Default::default(),
            points: Default::default(),
        };
        let output = ColmapSource::<&[u8]>::default();
        assert_eq!(output, target);

        let target = true;
        let output = format!("{:?}", output).starts_with("ColmapSource");
        assert_eq!(output, target);
    }
}