Crates.io | pasture-core |
lib.rs | pasture-core |
version | 0.5.0 |
source | src |
created_at | 2021-03-22 10:21:20.002792 |
updated_at | 2024-06-20 08:27:38.613697 |
description | A framework for working with point cloud data |
homepage | https://github.com/Mortano/pasture |
repository | https://github.com/Mortano/pasture |
max_upload_size | |
id | 372069 |
size | 416,237 |
A Rust library for working with point cloud data. It features:
pasture
calls 'interleaved' and 'columnar')pasture-io
crate (such as LAS
, LAZ
, 3D Tiles
, as well as ASCII files)pasture-algorithms
crateTo this end, pasture
chooses flexibility over simplicity. If you are looking for something small and simple, for example to work with LAS files, try a crate like las
. If you are planning to implement high-performance tools and services that will work with very large point cloud data, pasture
is what you are looking for!
Add this to your Cargo.toml
:
[dependencies]
pasture-core = "0.4.0"
# You probably also want I/O support
pasture-io = "0.4.0"
Here is an example on how to load a pointcloud from an LAS file and do something with it:
use anyhow::{bail, Context, Result};
use pasture_core::{
containers::{BorrowedBuffer, VectorBuffer},
layout::attributes::POSITION_3D,
nalgebra::Vector3,
};
use pasture_io::base::{read_all};
fn main() -> Result<()> {
// Reading a point cloud file is as simple as calling `read_all`
let points = read_all::<VectorBuffer, _>("pointcloud.las").context("Failed to read points")?;
if points.point_layout().has_attribute(&POSITION_3D) {
for position in points
.view_attribute::<Vector3<f64>>(&POSITION_3D)
.into_iter()
.take(10)
{
println!("({};{};{})", position.x, position.y, position.z);
}
} else {
bail!("Point cloud files has no positions!");
}
Ok(())
}
For more examples, check out the pasture_core
examples and the pasture_io
examples.
With version 0.4
, the buffer API of pasture-core
was rewritten. If you are migrating from an earlier version, here are some guidelines for migration. Also check out the documentation of the containers
module.
The main buffer types were renamed:
InterleavedVecPointStorage
is now VectorBuffer
PerAttributeVecPointStorage
is now HashMapBuffer
The trait structure is also different:
PointBuffer
and PointBufferWriteable
are replaced by BorrowedBuffer
, BorrowedMutBuffer
, and OwningBuffer
, which define the ownership model of the buffer memoryInterleavedPointBuffer
and InterleavedPointBufferMut
are now InterleavedBuffer
and InterleavedBufferMut
PerAttributePointBuffer
and PerAttributePointBufferMut
are now ColumnarBuffer
and ColumnarBufferMut
. In general, the term PerAttribute
is replaced by the more common term Columnar
There are no more extension traits (e.g. PointBufferExt
). To get/set strongly typed point data, you now use views which can be obtained through the BorrowedBuffer
and BorrowedBufferMut
traits:
let view = buffer.view_attribute::<Vector3<f64>>(&POSITION_3D);
Views support strongly typed access to the data and are convertible to iterators.
The PointReader
and PointWriter
traits are no longer object safe. Instead, they have read
and read_into
methods that are strongly typed over the buffer type for improved efficiency. There is a GenericPointReader
type, which uses static dispatch and encapsulates readers for LAS, LAZ, and 3D Tiles.
pasture
is in the early stages of development and bugs may occur.
pasture
is distributed under the terms of the Apache License (Version 2.0). See LICENSE for details.