20#include <peak_icv_c/types/peak_icv_point_cloud.h>
42template <
typename Po
intCloudType,
typename InnerPo
intType>
44 :
private detail::IBackendAccessible<PointCloud<PointCloudType, InnerPointType>>
45 ,
private detail::IBackendExchangeable<PointCloud<PointCloudType, InnerPointType>>
47 static_assert(std::is_base_of<experimental::PointXYZ, InnerPointType>::value,
48 "The given PointType is invalid. Please use a class which derives from Point3d");
133 typename std::vector<PointType>::const_iterator
cbegin()
const;
138 typename std::vector<PointType>::const_iterator
cend()
const;
142 explicit PointCloud(peak_icv_point_cloud_handle handle);
154 peak_icv_point_cloud_handle m_pointCloudHandle{};
155 mutable std::unique_ptr<std::vector<PointType>> m_points{};
157 peak_icv_point_cloud_handle CreateEmptyPointCloud();
160template <
typename Po
intCloudType,
typename InnerPo
intType>
163 if (m_pointCloudHandle !=
nullptr)
165 PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
169template <
typename Po
intCloudType,
typename InnerPo
intType>
171 : m_pointCloudHandle{ handle }
174template <
typename Po
intCloudType,
typename InnerPo
intType>
177 if (m_pointCloudHandle != other.m_pointCloudHandle)
180 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_IncreaseUseCount(other.m_pointCloudHandle);
182 m_pointCloudHandle = other.m_pointCloudHandle;
186template <
typename Po
intCloudType,
typename InnerPo
intType>
189 if (m_pointCloudHandle != other.m_pointCloudHandle)
191 m_pointCloudHandle = other.m_pointCloudHandle;
192 other.m_pointCloudHandle =
nullptr;
196template <
typename Po
intCloudType,
typename InnerPo
intType>
199 if (m_pointCloudHandle != other.m_pointCloudHandle)
201 if (m_pointCloudHandle !=
nullptr)
204 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
208 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_IncreaseUseCount(other.m_pointCloudHandle);
210 m_pointCloudHandle = other.m_pointCloudHandle;
211 m_points = std::make_unique<std::vector<InnerPointType>>(other.GetPoints());
217template <
typename Po
intCloudType,
typename InnerPo
intType>
220 if (m_pointCloudHandle != other.m_pointCloudHandle)
222 if (m_pointCloudHandle !=
nullptr)
225 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
229 m_pointCloudHandle = other.m_pointCloudHandle;
230 m_points = std::make_unique<std::vector<InnerPointType>>(other.GetPoints());
231 other.m_pointCloudHandle =
nullptr;
232 other.m_points =
nullptr;
238template <
typename Po
intCloudType,
typename InnerPo
intType>
241 if (m_pointCloudHandle == rhs.m_pointCloudHandle)
246 auto pointLhs = this->GetPoints();
247 auto pointRhs = rhs.GetPoints();
249 if (pointLhs.size() != pointRhs.size())
254 return std::is_permutation(pointLhs.begin(), pointLhs.end(), pointRhs.begin());
257template <
typename Po
intCloudType,
typename InnerPo
intType>
260 return !(*
this == rhs);
263template <
typename Po
intCloudType,
typename InnerPo
intType>
271 size_t numPoints = 0;
273 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_GetPoints_GetCount(m_pointCloudHandle, &numPoints);
278 m_points = std::make_unique<std::vector<PointType>>(0);
282 std::vector<PointTypeC> points(numPoints);
284 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_GetPoints(m_pointCloudHandle, points.data(),
sizeof(PointTypeC) * numPoints);
287 m_points = std::make_unique<std::vector<PointType>>(numPoints);
288 std::transform(points.begin(), points.end(), m_points->begin(), [](
const auto& point) {
289 return peak::common::detail::BackendAccessor<PointType>::CreateInstance(point);
295template <
typename Po
intCloudType,
typename InnerPo
intType>
298 peak_icv_transformation_matrix_3d cMatrix{};
299 std::memcpy(&cMatrix, matrix.
GetData(),
sizeof(cMatrix));
301 PointCloudType outputPointCloud{};
302 auto outputHandle = peak::common::detail::BackendAccessor<PointCloudType>::BackendHandleAddress(outputPointCloud);
304 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Transform(this->GetHandle(), cMatrix, outputHandle);
306 return outputPointCloud;
309template <
typename Po
intCloudType,
typename InnerPo
intType>
313 const auto extrinsicParametersC = peak::common::detail::BackendAccessor<experimental::ExtrinsicParameters>::CreateCType(
314 extrinsicParameters);
316 PointCloudType outputPointCloud{};
317 auto outputHandle = peak::common::detail::BackendAccessor<PointCloudType>::BackendHandleAddress(outputPointCloud);
319 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_TransformToWorkspace(this->GetHandle(), extrinsicParametersC, outputHandle);
321 return outputPointCloud;
324template <
typename Po
intCloudType,
typename InnerPo
intType>
327 return GetPoints().cbegin();
330template <
typename Po
intCloudType,
typename InnerPo
intType>
333 return GetPoints().cend();
336template <
typename Po
intCloudType,
typename InnerPo
intType>
338 : m_pointCloudHandle{ CreateEmptyPointCloud() }
341template <
typename Po
intCloudType,
typename InnerPo
intType>
344 return m_pointCloudHandle;
347template <
typename Po
intCloudType,
typename InnerPo
intType>
350 return &m_pointCloudHandle;
353template <
typename Po
intCloudType,
typename InnerPo
intType>
354peak_icv_point_cloud_handle PointCloud<PointCloudType, InnerPointType>::CreateEmptyPointCloud()
356 peak_icv_point_cloud_handle handle{};
358 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Create(&handle);
constexpr const Type * GetData() const
Returns a pointer to the underlying data of the array.
A point cloud base class.
PointCloudType Transform(const experimental::TransformationMatrix3D &matrix) const
Applies a transformation to a point cloud based on the given matrix.
PointCloud & operator=(const PointCloud &other)
PointCloudType TransformToWorkspace(const experimental::ExtrinsicParameters &extrinsicParameters) const
Transforms a point cloud to the workspace coordinate system using the extrinsic parameters.
PointCloud(const PointCloud &other)
bool operator==(const PointCloud &rhs) const
bool operator!=(const PointCloud &rhs) const
std::vector< PointType >::const_iterator cbegin() const
Returns an iterator to the first point.
const std::vector< PointType > & GetPoints() const
Returns the points from a point cloud.
PointCloud(PointCloud &&other) noexcept
PointCloud & operator=(PointCloud &&other) noexcept
std::vector< PointType >::const_iterator cend() const
Returns an iterator to the end of the points (the point after the last point).
This class stores and provides access to the extrinsic parameters, which include the translation,...
typename c_type_of_< Type >::type c_type_of_t
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
peak::common::detail::c_type_of_t< Type > * handle_of_t