13#include <peak_common_c/detail/peak_common_defines.h>
20#include <peak_icv_c/types/peak_icv_point_cloud.h>
57template <
typename Po
intCloudType,
typename InnerPo
intType>
59 :
private detail::IBackendAccessible<PointCloud<PointCloudType, InnerPointType>>
60 ,
private detail::IBackendExchangeable<PointCloud<PointCloudType, InnerPointType>>
63 std::is_base_of<PointXYZ, InnerPointType>::value,
"The given PointType is invalid. Please use a class which derives from Point3d");
112 typename std::vector<PointType>::const_iterator
cbegin()
const;
117 typename std::vector<PointType>::const_iterator
cend()
const;
121 explicit PointCloud(peak_icv_point_cloud_handle handle);
135 peak_icv_point_cloud_handle m_pointCloudHandle{};
136 mutable std::unique_ptr<std::vector<PointType>> m_points{};
138 peak_icv_point_cloud_handle CreateEmptyPointCloud();
141template <
typename Po
intCloudType,
typename InnerPo
intType>
144 if (m_pointCloudHandle !=
nullptr)
146 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
150template <
typename Po
intCloudType,
typename InnerPo
intType>
152 : m_pointCloudHandle{ handle }
155template <
typename Po
intCloudType,
typename InnerPo
intType>
158 if (m_pointCloudHandle != other.m_pointCloudHandle)
161 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_IncreaseUseCount(other.m_pointCloudHandle);
163 m_pointCloudHandle = other.m_pointCloudHandle;
167template <
typename Po
intCloudType,
typename InnerPo
intType>
170 if (m_pointCloudHandle != other.m_pointCloudHandle)
172 m_pointCloudHandle = other.m_pointCloudHandle;
173 other.m_pointCloudHandle =
nullptr;
177template <
typename Po
intCloudType,
typename InnerPo
intType>
180 if (m_pointCloudHandle != other.m_pointCloudHandle)
182 if (m_pointCloudHandle !=
nullptr)
185 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
189 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_IncreaseUseCount(other.m_pointCloudHandle);
191 m_pointCloudHandle = other.m_pointCloudHandle;
192 m_points = std::make_unique<std::vector<InnerPointType>>(other.
GetPoints());
198template <
typename Po
intCloudType,
typename InnerPo
intType>
201 if (m_pointCloudHandle != other.m_pointCloudHandle)
203 if (m_pointCloudHandle !=
nullptr)
206 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Destroy(m_pointCloudHandle);
210 m_pointCloudHandle = other.m_pointCloudHandle;
211 m_points = std::make_unique<std::vector<InnerPointType>>(other.GetPoints());
212 other.m_pointCloudHandle =
nullptr;
213 other.m_points =
nullptr;
219template <
typename Po
intCloudType,
typename InnerPo
intType>
222 if (m_pointCloudHandle == rhs.m_pointCloudHandle)
227 auto pointLhs = this->GetPoints();
230 if (pointLhs.size() != pointRhs.size())
235 return std::is_permutation(pointLhs.begin(), pointLhs.end(), pointRhs.begin());
238template <
typename Po
intCloudType,
typename InnerPo
intType>
241 return !(*
this == rhs);
244template <
typename Po
intCloudType,
typename InnerPo
intType>
252 size_t numPoints = 0;
254 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_GetPoints_GetCount(m_pointCloudHandle, &numPoints);
259 m_points = std::make_unique<std::vector<PointType>>(0);
263 std::vector<PointTypeC> points(numPoints);
265 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_GetPoints(m_pointCloudHandle, points.data(),
sizeof(PointTypeC) * numPoints);
268 m_points = std::make_unique<std::vector<PointType>>(numPoints);
269 std::transform(points.begin(), points.end(), m_points->begin(), [](
const auto& point) {
270 return peak::common::detail::BackendAccessor<PointType>::CreateInstance(point);
276template <
typename Po
intCloudType,
typename InnerPo
intType>
279 peak_icv_transformation_matrix_3d cMatrix{};
280 std::memcpy(&cMatrix, matrix.
GetData(),
sizeof(cMatrix));
282 PointCloudType outputPointCloud{};
283 auto outputHandle = peak::common::detail::BackendAccessor<PointCloudType>::BackendHandleAddress(outputPointCloud);
285 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_Transform(this->GetHandle(), cMatrix, outputHandle);
287 return outputPointCloud;
290template <
typename Po
intCloudType,
typename InnerPo
intType>
293 const auto extrinsicParametersC = peak::common::detail::BackendAccessor<ExtrinsicParameters>::CreateCType(extrinsicParameters);
295 PointCloudType outputPointCloud{};
296 auto outputHandle = peak::common::detail::BackendAccessor<PointCloudType>::BackendHandleAddress(outputPointCloud);
298 return PEAK_ICV_C_ABI_PREFIX peak_icv_PointCloud_TransformToWorkspace(
299 this->GetHandle(), extrinsicParametersC,
sizeof(peak_icv_extrinsic_parameters), outputHandle);
301 return outputPointCloud;
304template <
typename Po
intCloudType,
typename InnerPo
intType>
307 return GetPoints().cbegin();
310template <
typename Po
intCloudType,
typename InnerPo
intType>
313 return GetPoints().cend();
316template <
typename Po
intCloudType,
typename InnerPo
intType>
318 : m_pointCloudHandle{ CreateEmptyPointCloud() }
321template <
typename Po
intCloudType,
typename InnerPo
intType>
324 return m_pointCloudHandle;
327template <
typename Po
intCloudType,
typename InnerPo
intType>
330 return &m_pointCloudHandle;
333template <
typename Po
intCloudType,
typename InnerPo
intType>
334peak_icv_point_cloud_handle PointCloud<PointCloudType, InnerPointType>::CreateEmptyPointCloud()
336 peak_icv_point_cloud_handle handle{};
338 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.
This class stores and provides access to the extrinsic parameters, which include the translation,...
Represents a generic point cloud interface for spatial data types.
PointCloudType TransformToWorkspace(const ExtrinsicParameters &extrinsicParameters) const
Transforms the point cloud to workspace coordinates using the specified extrinsic parameters.
PointCloud & operator=(const PointCloud &other)
PointCloud(const PointCloud &other)
PointCloudType Transform(const TransformationMatrix3D &matrix) const
Applies the specified transformation matrix to the point cloud.
bool operator==(const PointCloud &rhs) const
bool operator!=(const PointCloud &rhs) const
std::vector< PointType >::const_iterator cbegin() const
const std::vector< PointType > & GetPoints() const
PointCloud(PointCloud &&other) noexcept
PointCloud & operator=(PointCloud &&other) noexcept
std::vector< PointType >::const_iterator cend() const
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