pointrain_core/
traits.rs

1use crate::types::{Float, Normal, Position, Rgb};
2
3pub trait PointCloud: Default {
4    type Point;
5
6    fn new() -> Self {
7        Self::default()
8    }
9    fn with_capacity(capacity: usize) -> Self;
10    fn positions(&self) -> &[Position];
11    fn add_point(&mut self, p: Self::Point) -> &mut Self;
12
13    fn len(&self) -> usize {
14        self.positions().len()
15    }
16    fn is_empty(&self) -> bool {
17        self.len() == 0
18    }
19}
20
21pub trait PointCloudWithIntensity: PointCloud {
22    fn intensities(&self) -> &[Float];
23}
24
25pub trait PointCloudWithNormal: PointCloud {
26    fn normals(&self) -> &[Normal];
27    fn curvatures(&self) -> &[Float];
28}
29
30pub trait PointCloudWithColor: PointCloud {
31    fn colors(&self) -> &[Rgb];
32}