5个版本 (破坏性)
0.5.0 | 2024年6月20日 |
---|---|
0.4.0 | 2023年11月2日 |
0.3.0 | 2022年1月13日 |
0.2.0 | 2021年10月11日 |
0.1.0 | 2021年3月22日 |
#428 在 解析器实现
每月274次下载
770KB
16K SLoC
pasture
一个用于处理点云数据的Rust库。它具有
- 对任意点属性的细粒度支持,类似于PDAL,但增加了类型安全性
- 一个非常灵活的内存模型,原生支持数组和结构体数组(AoS)以及结构体数组(SoA)内存布局(pasture称为'交错'和'列式')
- 使用
pasture-io
crate支持读取和写入各种点云格式(如LAS
、LAZ
、3D Tiles
以及ASCII文件) - 带有
pasture-algorithms
crate的算法集
为此,pasture
选择了灵活性而非简单性。如果你在寻找一些小而简单的工具,例如处理LAS文件,尝试像las
这样的crate。如果你打算实现高性能的工具和服务,将处理非常大的点云数据,pasture
就是你要找的!
用法
将此添加到你的Cargo.toml
[dependencies]
pasture-core = "0.4.0"
# You probably also want I/O support
pasture-io = "0.4.0"
以下是如何从LAS文件中加载点云并进行操作的示例
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(())
}
有关更多示例,请参阅pasture_core
示例和pasture_io
示例。
从版本<0.4以下迁移
从版本0.4
开始,pasture-core
的缓冲区API被重写。如果你从早期版本迁移,以下是一些迁移指南。同时,请查看containers
模块的文档。
新的缓冲区类型
主要的缓冲区类型已被重命名
InterleavedVecPointStorage
现在是VectorBuffer
PerAttributeVecPointStorage
现在是HashMapBuffer
特质的结构也不同
PointBuffer
和PointBufferWriteable
已被替换为BorrowedBuffer
、BorrowedMutBuffer
和OwningBuffer
,它们定义了缓冲区内存的所有权模型。InterleavedPointBuffer
和InterleavedPointBufferMut
现在是InterleavedBuffer
和InterleavedBufferMut
。PerAttributePointBuffer
和PerAttributePointBufferMut
现在是ColumnarBuffer
和ColumnarBufferMut
。一般来说,术语PerAttribute
被更常见的术语Columnar
替换。
不再有扩展特性(例如 PointBufferExt
)。要获取/设置强类型点数据,您现在使用 视图,这些视图可以通过 BorrowedBuffer
和 BorrowedBufferMut
特性获取。
let view = buffer.view_attribute::<Vector3<f64>>(&POSITION_3D);
视图支持对数据的强类型访问,并且可以转换为迭代器。
新的读写接口
PointReader
和 PointWriter
特性不再安全地作为对象。相反,它们具有 read
和 read_into
方法,这些方法在缓冲区类型上强类型化,以提高效率。有一个 GenericPointReader
类型,它使用静态分派并封装了LAS、LAZ和3D Tiles的读取器。
开发
pasture
处于开发初期阶段,可能会出现错误。
许可
pasture
根据 Apache 许可协议(版本 2.0)进行分发。有关详细信息,请参阅 LICENSE。
依赖项
~9MB
~176K SLoC