CVB++ 15.0
detail_point_cloud.hpp
1#pragma once
2
3#include "../_decl/decl_point_cloud.hpp"
4
5#include "../dense_point_cloud.hpp"
6#include "../sparse_point_cloud.hpp"
7
8#include "detail_composite.hpp"
9
10namespace Cvb
11{
12
13 CVB_BEGIN_INLINE_NS
14
15 inline PointCloudPtr PointCloud::FromHandle(HandleGuard<PointCloud> &&guard)
16 {
17 if (!guard.Handle())
18 throw std::runtime_error("handle must not be null");
19
20 if (IsDense(guard.Handle()))
21 return std::make_shared<DensePointCloud>(std::move(guard), PrivateTag{});
22 else
23 return std::make_shared<SparsePointCloud>(std::move(guard), PrivateTag{});
24 }
25
26 template <class T>
28 {
29 static_assert(std::is_base_of<PointCloud, T>::value, "CVB: T must be derived from PointCloud");
30 CVB_CALL_CAPI(ShareObject(object->Handle()));
31 return FromHandle<T>(HandleGuard<PointCloud>(object->Handle()));
32 }
33
34 inline PointCloudPtr PointCloud::FromMemory(void *buffer, size_t size, PointCloudFlags flags,
36 {
37 return Internal::DoResCallShareOut<PointCloud>([&](void *&handle) {
38 return CVB_CALL_CAPI(CVC3DMemoryToPointCloud(buffer, size, static_cast<CExports::cvbval_t>(flags),
39 static_cast<CExports::CVC3DPointCloudFileFormat>(format), handle));
40 });
41 }
42
43 inline SparsePointCloudPtr PointCloud::Transform(const AffineMatrix3D &transformation) const
44 {
45 return Internal::DoResCallShareOut<SparsePointCloud>([&](void *&handle) {
46 return CVB_CALL_CAPI(CVC3DCreateTransformedPointCloud(
47 Handle(), *reinterpret_cast<const CExports::CVC3DTransformation *>(&transformation), handle));
48 });
49 }
50
51 inline void PointCloud::Transform(const AffineMatrix3D &affineTransformation, SparsePointCloud &pointCloud)
52 {
53 Internal::DoResCall([&]() {
54 return CVB_CALL_CAPI(CVC3DTransformPointCloud(
55 Handle(), *reinterpret_cast<const CExports::CVC3DTransformation *>(&affineTransformation),
56 pointCloud.Handle()));
57 });
58 }
59
60 inline SparsePointCloudPtr PointCloud::Transform(const Matrix3DH &transformation) const
61 {
62 return Internal::DoResCallShareOut<SparsePointCloud>([&](void *&handle) {
63 return CVB_CALL_CAPI(CVC3DCreateTransformedPointCloudH(
64 Handle(), *reinterpret_cast<const CExports::CVC3DMatrixH *>(&transformation), handle));
65 });
66 }
67
68 inline void PointCloud::Transform(const Cvb::Matrix3DH &transformation, SparsePointCloud &pointCloud)
69 {
70 Internal::DoResCall([&]() {
71 return CVB_CALL_CAPI(CVC3DTransformPointCloudH(
72 Handle(), *reinterpret_cast<const CExports::CVC3DMatrixH *>(&transformation), pointCloud.Handle()));
73 });
74 }
75
76 CVB_END_INLINE_NS
77
78} // namespace Cvb
Affine transformation for 3D containing a transformation matrix and a translation vector.
Definition affine_matrix_3d.hpp:140
Double precision row-major 4x4 matrix.
Definition matrix_3d_h.hpp:44
static PointCloudPtr FromHandle(HandleGuard< PointCloud > &&guard)
Creates a point cloud from a classic API handle.
Definition detail_point_cloud.hpp:15
SparsePointCloudPtr Transform(const AffineMatrix3D &transformation) const
Creates a new point cloud with all points being transformed by the given transformation.
Definition detail_point_cloud.hpp:43
static std::shared_ptr< T > FromComposite(CompositePtr object)
Creates a point cloud from a composite.
Definition detail_point_cloud.hpp:27
static PointCloudPtr FromMemory(void *buffer, size_t size, PointCloudFlags flags, Cvb::PointCloudFileFormat format)
Creates a point cloud reading memory from buffer.
Definition detail_point_cloud.hpp:34
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_point_cloud.hpp:764
An unorganized sparse Cartesian 3D point cloud object.
Definition decl_sparse_point_cloud.hpp:34
cvbbool_t ShareObject(OBJ Object)
T make_shared(T... args)
T move(T... args)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
PointCloudFileFormat
Supported point cloud point formats.
Definition core_3d.hpp:141
PointCloudFlags
Flags for creating point clouds.
Definition core_3d.hpp:90
std::shared_ptr< PointCloud > PointCloudPtr
Convenience shared pointer for PointCloud.
Definition core_3d.hpp:40
std::shared_ptr< SparsePointCloud > SparsePointCloudPtr
Convenience shared pointer for SparsePointCloud.
Definition core_3d.hpp:48
std::shared_ptr< Composite > CompositePtr
Convenience shared pointer for Composite.
Definition global.hpp:102