IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
PointCloud.cs
Go to the documentation of this file.
1using System.Runtime.InteropServices;
3using Microsoft.Win32.SafeHandles;
4
6
11public abstract class PointCloud : IDisposable, IHasSafeHandle
12{
13 internal Handle _handle;
14
19 protected PointCloud()
20 {
21 var handle = new Handle();
22 DllHelper.ExecuteAndMapReturnCodes(() => CInterface.peak_icv_PointCloud_Create(out handle));
23 _handle = handle;
24 }
25
26 internal PointCloud(Handle handle)
27 {
28 _handle = handle;
29 }
30
35 public void Dispose()
36 {
37 _handle.Dispose();
38 GC.SuppressFinalize(this);
39 }
40
41 SafeHandle IHasSafeHandle.Handle => _handle;
42
43 internal sealed class Handle : SafeHandleZeroOrMinusOneIsInvalid
44 {
45 internal Handle() : base(true)
46 {
47 }
48
49 protected override bool ReleaseHandle()
50 {
51 return CInterface.peak_icv_PointCloud_Destroy(handle) ==
52 Backend.Types.peak_icv_status.PEAK_ICV_STATUS_SUCCESS;
53 }
54 }
55
56 internal class CInterface
57 {
58 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
59 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_Create(
60 out Handle pointCloudHandle);
61
62 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
63 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_Destroy(IntPtr pointCloudHandle);
64
65 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
66 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_IncreaseUseCount(
67 Handle pointCloudHandle);
68
69 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
70 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_CreateFromXYZImage(
71 out Handle pointCloudHandle, Image.Handle imageHandle);
72
73 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
74 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_CreateFromFile(
75 out Handle pointCloudHandle, Backend.Types.peak_icv_point_type pointType, byte[] filePath);
76
77 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
78 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_CreateFromPoints(
79 out Handle pointCloudHandle, Backend.Types.peak_icv_point_xyz[] points, nuint numPoints,
80 Backend.Types.peak_icv_point_type pointType);
81
82 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
83 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_CreateFromXYZImageAndIntensityImage(
84 out Handle pointCloudHandle, Image.Handle imageHandle, Image.Handle intensityImageHandle);
85
86 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
87 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_CreateFromPoints(
88 out Handle pointCloudHandle, Backend.Types.peak_icv_point_xyzi[] points, nuint numPoints,
89 Backend.Types.peak_icv_point_type pointType);
90
91 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
92 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_GetPoints_GetCount(
93 Handle pointCloudHandle, out nuint count);
94
95 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
96 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_GetPoints(
97 Handle pointCloudHandle, IntPtr points, nuint numPoints);
98
99 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
100 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_Transform(
101 Handle pointCloudHandle, float[] matrix,
102 ref Handle outputHandle);
103
104 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
105 public static extern Backend.Types.peak_icv_status peak_icv_PointCloud_TransformToWorkspace(
106 Handle pointCloudHandle, Backend.Types.peak_icv_extrinsic_parameters extrinsicParameters,
107 nuint sizeOfExtrinsicParameters,
108 ref Handle outputHandle);
109 }
110}
111
116public abstract class PointCloudT<TPoint> : PointCloud
117{
122 protected TPoint[]? _points;
123
124 internal PointCloudT(Handle handle) : base(handle)
125 {
126 }
127
132 protected PointCloudT()
133 {
134 }
135
140 public abstract TPoint[] Points { get; }
141
146 public override string ToString()
147 {
148 return string.Join(", ", Points.Select(item => $"({item})"));
149 }
150}
Represents the base for all point clouds.
Definition PointCloud.cs:12
void Dispose()
Releases the resources used by the PointCloud class.
Definition PointCloud.cs:35
TPoint[] Points
Abstract method to provide the points of the point cloud.
override string ToString()
Returns a string representation of the point cloud.