pub struct PointCloud { /* private fields */ }Expand description
A point cloud.
§Layout
Coordinates live in three separate arrays rather than in an array of structs. At hundreds of millions of points that matters: filtering by a mask does not drag unused attributes along, and the coordinate arrays map directly onto SIMD registers and GPU buffers.
§Precision and origin
Coordinates are stored as f32 relative to origin,
which is kept in f64. The reason is georeferenced data: at a
coordinate of 500 000 m the f32 step is about 3 cm, so storing
absolute coordinates directly would destroy millimetre accuracy before
the first computation. Offset storage keeps both the halved memory and
the absolute accuracy.
point returns the absolute coordinate in f64;
local returns the offset one.
Implementations§
Source§impl PointCloud
impl PointCloud
Sourcepub fn with_origin(origin: Vector3<f64>) -> Self
pub fn with_origin(origin: Vector3<f64>) -> Self
An empty cloud with the given origin.
Sourcepub fn rebase(&mut self, new_origin: Vector3<f64>)
pub fn rebase(&mut self, new_origin: Vector3<f64>)
Moves the origin while preserving absolute point coordinates.
The operation loses precision, since coordinates are recomputed
through f32. It is worth calling once, right after reading a file.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
An empty cloud with capacity reserved.
Sourcepub fn from_columns(
origin: Vector3<f64>,
x: Vec<f32>,
y: Vec<f32>,
z: Vec<f32>,
) -> Result<Self, CloudError>
pub fn from_columns( origin: Vector3<f64>, x: Vec<f32>, y: Vec<f32>, z: Vec<f32>, ) -> Result<Self, CloudError>
Builds a cloud from three coordinate arrays.
Coordinates are interpreted as offsets from origin.
Sourcepub fn iter(&self) -> impl Iterator<Item = Vector3<f64>> + '_
pub fn iter(&self) -> impl Iterator<Item = Vector3<f64>> + '_
Iterator over absolute coordinates.
Sourcepub fn push(&mut self, point: Vector3<f64>)
pub fn push(&mut self, point: Vector3<f64>)
Appends a point given in absolute coordinates.
§Panics
If the cloud already carries attributes: appending a point without attribute values would break column consistency.
Sourcepub fn attributes(&self) -> &[Attribute]
pub fn attributes(&self) -> &[Attribute]
All attributes.
Sourcepub fn push_attribute(&mut self, attribute: Attribute) -> Result<(), CloudError>
pub fn push_attribute(&mut self, attribute: Attribute) -> Result<(), CloudError>
Appends an attribute column.
Sourcepub fn check_finite(&self) -> Result<(), CloudError>
pub fn check_finite(&self) -> Result<(), CloudError>
Checks that every coordinate is finite.
Called by algorithms for which a NaN means not “a bad point” but a
silently corrupted result — voxelisation, for instance, where
NaN as i64 yields zero and the point lands in an arbitrary cell.
Trait Implementations§
Source§impl Clone for PointCloud
impl Clone for PointCloud
Source§fn clone(&self) -> PointCloud
fn clone(&self) -> PointCloud
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PointCloud
impl Debug for PointCloud
Source§impl Default for PointCloud
impl Default for PointCloud
Source§fn default() -> PointCloud
fn default() -> PointCloud
Source§impl PartialEq for PointCloud
impl PartialEq for PointCloud
impl StructuralPartialEq for PointCloud
Auto Trait Implementations§
impl Freeze for PointCloud
impl RefUnwindSafe for PointCloud
impl Send for PointCloud
impl Sync for PointCloud
impl Unpin for PointCloud
impl UnsafeUnpin for PointCloud
impl UnwindSafe for PointCloud
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.