39 lines
2.0 KiB
C#
39 lines
2.0 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
public class PclPointCloud : IDisposable {
|
|
private IntPtr handle;
|
|
|
|
public PclPointCloud() => handle = create_point_cloud();
|
|
// 构造函数用于内部封装 handle 对象
|
|
public PclPointCloud(IntPtr handle) => this.handle = handle;
|
|
public void Dispose() { delete_point_cloud(handle); handle = IntPtr.Zero; }
|
|
|
|
public int Load(string path) => load_point_cloud(handle, path);
|
|
public int Save(string path) => save_point_cloud(handle, path);
|
|
public IntPtr Handle => handle;
|
|
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_point_cloud();
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_point_cloud(IntPtr ptr);
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern int load_point_cloud(IntPtr ptr, string path);
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern int save_point_cloud(IntPtr ptr, string path);
|
|
}
|
|
|
|
public class PclVoxelGrid : IDisposable {
|
|
private IntPtr handle;
|
|
|
|
public PclVoxelGrid() => handle = create_voxel_filter();
|
|
public void Dispose() { delete_voxel_filter(handle); handle = IntPtr.Zero; }
|
|
|
|
public void SetLeafSize(float x, float y, float z) => set_voxel_leaf_size(handle, x, y, z);
|
|
public void SetInputCloud(PclPointCloud cloud) => set_voxel_input_cloud(handle, cloud.Handle);
|
|
public PclPointCloud Filter() => new PclPointCloud(apply_voxel_filter(handle));
|
|
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr create_voxel_filter();
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void delete_voxel_filter(IntPtr ptr);
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_leaf_size(IntPtr ptr, float x, float y, float z);
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern void set_voxel_input_cloud(IntPtr filterPtr, IntPtr cloudPtr);
|
|
[DllImport("./pcl/libpclwrapper.dylib")] private static extern IntPtr apply_voxel_filter(IntPtr filterPtr);
|
|
|
|
|
|
} |