#point-cloud #points #pasture #lidar #macro-derive

pasture-derive

为 #[derive(PointType)] 提供宏实现

4 个版本 (重大变更)

0.5.0 2024年6月20日
0.4.0 2023年11月2日
0.2.0 2021年10月11日
0.1.0 2021年3月22日

#1832数据结构


3 个 crate 中使用

自定义许可证

34KB
491

牧场景

一个用于处理点云数据的 Rust 库。它具有

  • 对任意点属性的精细支持,类似于 PDAL,但增加了类型安全
  • 一个非常灵活的内存模型,原生支持 Array-of-Structs (AoS) 和 Struct-of-Arrays (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

特质结构也有所不同

  • PointBufferPointBufferWriteable 已被 BorrowedBufferBorrowedMutBufferOwningBuffer 替换,这些定义了缓冲区内存的所有权模型。
  • InterleavedPointBufferInterleavedPointBufferMut 现在是 InterleavedBufferInterleavedBufferMut
  • PerAttributePointBufferPerAttributePointBufferMut 现在是 ColumnarBufferColumnarBufferMut。一般来说,术语 PerAttribute 被更常见的术语 Columnar 替换。

不再有扩展特质(例如 PointBufferExt)。为了获取/设置强类型点数据,您现在可以使用 视图,这些视图可以通过 BorrowedBufferBorrowedBufferMut 特质获得。

let view = buffer.view_attribute::<Vector3<f64>>(&POSITION_3D);

视图支持对数据的强类型访问,并且可以转换为迭代器。

读者和作者的新接口

PointReaderPointWriter 特质不再对象安全。相反,它们具有 readread_into 方法,这些方法对缓冲区类型进行强类型化,以提高效率。存在一个 GenericPointReader 类型,它使用静态分派并封装了 LAS、LAZ 和 3D Tiles 的读取器。

开发

pasture 处于早期开发阶段,可能出现错误。

许可

pasture 根据 Apache 许可协议(版本 2.0)进行分发。有关详细信息,请参阅 LICENSE

依赖关系

~1.5MB
~38K SLoC