From 44a47e6541c20f665f701221015aecdf31246dbe Mon Sep 17 00:00:00 2001 From: 12345qiupeng Date: Sat, 12 Apr 2025 17:34:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=82=B9=E4=BA=91?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=92=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=B4=A2=E5=BC=95=E7=9A=84=E8=AE=BF=E9=97=AE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/pcl_wrapper/pcl_wrapper_api.hpp | 6 ++++++ wrapper.cpp | 26 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/pcl_wrapper/pcl_wrapper_api.hpp b/include/pcl_wrapper/pcl_wrapper_api.hpp index 9274551..5593658 100644 --- a/include/pcl_wrapper/pcl_wrapper_api.hpp +++ b/include/pcl_wrapper/pcl_wrapper_api.hpp @@ -17,6 +17,12 @@ void reserve_pointcloud_xyz(void* cloud, int count); void set_point_xyz(void* cloud, int index, float x, float y, float z); void set_point_xyzi(void* cloud, int index, float x, float y, float z, float intensity); void delete_pointcloud(void* cloud); +// 统一接口:获取点数量 +int get_pointcloud_size(void* cloud); +// 读取 PointXYZ +bool get_point_xyz(void* cloud, int index, float* x, float* y, float* z); +// 读取 PointXYZI +bool get_point_xyzi(void* cloud, int index, float* x, float* y, float* z, float* intensity); // ========== Voxel Filter ========== diff --git a/wrapper.cpp b/wrapper.cpp index 229c866..4f03a5b 100644 --- a/wrapper.cpp +++ b/wrapper.cpp @@ -40,6 +40,32 @@ void delete_pointcloud(void* cloud) { delete static_cast(cloud); // 可根据类型再区分 } +int get_pointcloud_size(void* cloud) { + auto* pc = static_cast(cloud); + return static_cast(pc->cloud->size()); +} + +bool get_point_xyz(void* cloud, int index, float* x, float* y, float* z) { + auto* pc = static_cast(cloud); + if (index < 0 || index >= pc->cloud->size()) return false; + const auto& pt = (*pc->cloud)[index]; + *x = pt.x; + *y = pt.y; + *z = pt.z; + return true; +} + +bool get_point_xyzi(void* cloud, int index, float* x, float* y, float* z, float* intensity) { + auto* pc = static_cast(cloud); + if (index < 0 || index >= pc->cloud->size()) return false; + const auto& pt = (*pc->cloud)[index]; + *x = pt.x; + *y = pt.y; + *z = pt.z; + *intensity = pt.intensity; + return true; +} + // === 滤波器相关 === void* create_voxel_filter_xyz() {