55 return _SelectBy(CInterface.peak_icv_Region_SelectByArea_GetCount,
56 CInterface.peak_icv_Region_SelectByArea,
57 new Backend.Types.peak_icv_interval_u { minimum = interval.Minimum, maximum = interval.Maximum });
76 return _SelectBy(CInterface.peak_icv_Region_SelectByCenterOfGravityX_GetCount,
77 CInterface.peak_icv_Region_SelectByCenterOfGravityX,
78 new Backend.Types.peak_icv_interval_f { minimum = interval.Minimum, maximum = interval.Maximum });
97 return _SelectBy(CInterface.peak_icv_Region_SelectByCenterOfGravityY_GetCount,
98 CInterface.peak_icv_Region_SelectByCenterOfGravityY,
99 new Backend.Types.peak_icv_interval_f { minimum = interval.Minimum, maximum = interval.Maximum });
126 return _SelectBy(CInterface.peak_icv_Region_SelectByCenterOfGravityRect_GetCount,
127 CInterface.peak_icv_Region_SelectByCenterOfGravityRect,
128 new Backend.Types.peak_common_rectangle_f
156 private RegionSelector _SelectBy<T>(GetCountDelegate<T> getCountFunc, SelectByDelegate<T> selectByFunc,
164 IntPtr[] handles = SafeHandles.ExtractHandles(
Regions, out Action release);
169 DllHelper.ExecuteAndMapReturnCodes(() =>
170 getCountFunc(handles, (nuint) handles.Length, criteria, out count));
172 if ((uint) count == 0)
177 var selectedHandles =
new IntPtr[(uint) count];
178 DllHelper.ExecuteAndMapReturnCodes(() =>
179 selectByFunc(handles, (nuint) handles.Length, criteria, selectedHandles, count));
181 var selectedRegions =
193 private static class CInterface
195 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
196 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByArea_GetCount(
197 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_u area,
200 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
201 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByArea(
202 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_u area,
203 [Out] IntPtr[] outputRegions,
204 nuint numOutputRegions);
206 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
207 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityX_GetCount(
208 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_f x,
211 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
212 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityX(
213 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_f x,
214 [Out] IntPtr[] outputRegions,
215 nuint numOutputRegions);
217 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
218 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityY_GetCount(
219 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_f y,
222 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
223 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityY(
224 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_icv_interval_f y,
225 [Out] IntPtr[] outputRegions,
226 nuint numOutputRegions);
228 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
229 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityRect_GetCount(
230 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_common_rectangle_f rect,
233 [DllImport(Global.LibraryName, CallingConvention = Global.CallingConvention)]
234 public static extern Backend.Types.peak_icv_status peak_icv_Region_SelectByCenterOfGravityRect(
235 IntPtr[] inputRegions, nuint numInputRegions, Backend.Types.peak_common_rectangle_f rect,
236 [Out] IntPtr[] outputRegions, nuint numOutputRegions);
239 private delegate Backend.Types.peak_icv_status GetCountDelegate<in T>(IntPtr[] inputRegions,
240 nuint numInputRegions,
244 private delegate Backend.Types.peak_icv_status SelectByDelegate<in T>(IntPtr[] inputRegions,
245 nuint numInputRegions,
247 [Out] IntPtr[] outputRegions, nuint numOutputRegions);