CVB++ 15.0
decl_dense_point_cloud.hpp
1#pragma once
2
3#include "decl_point_cloud.hpp"
4
5#include "../image_plane.hpp"
6#include "../dense_components_pointers_3d.hpp"
7
8namespace Cvb
9{
10 CVB_BEGIN_INLINE_NS
11
34 class DensePointCloud : public PointCloud
35 {
36
37 friend class PointCloud;
38
39 public:
40 static DensePointCloudPtr FromHandle(HandleGuard<PointCloud> &&guard)
41 {
42 if (!IsDense(guard.Handle()))
43 throw std::runtime_error("handle is not a dense point cloud");
44 return std::make_shared<DensePointCloud>(std::move(guard), PrivateTag{});
45 }
46
47 template <class T>
48 static DensePointCloudPtr FromHandle(HandleGuard<PointCloud> &&guard)
49 {
50 return FromHandle(std::move(guard));
51 }
52
53 DensePointCloud(HandleGuard<PointCloud> &&guard, PrivateTag) noexcept
54 : PointCloud(std::move(guard))
55 {
56 }
57
59
68
70
77
79
84 {
85 CExports::cvbdim_t width = 0;
86 CExports::cvbdim_t height = 0;
87 Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVC3DPointCloudGetLatticeSize(Handle(), width, height)); });
88 return Size2D<int>(static_cast<int>(width), static_cast<int>(height));
89 }
90
93
100 {
101 return Internal::DoResCallShareOut<DensePointCloud>(
102 [&](void *&handle) { return CVB_CALL_CAPI(CVC3DCreateShrinkedDensePointCloud(Handle(), handle)); });
103 }
104
106
111 DensePointCloudPtr Crop(const Cuboid &clipBox) const
112 {
113 return Internal::DoResCallShareOut<DensePointCloud>([&](void *&handle) {
114 return CVB_CALL_CAPI(
115 CVC3DCreateCroppedPointCloud(Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), handle));
116 });
117 }
118
122
141 DensePointCloudPtr FrustumCrop(const Cuboid &clipBox, Angle theta, Angle phi) const
142 {
143 return Internal::DoResCallShareOut<DensePointCloud>([&](void *&handle) {
144 return CVB_CALL_CAPI(CVC3DCreateFrustumCroppedPointCloud(
145 Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), theta.Deg(), phi.Deg(), handle));
146 });
147 }
148
151
179 DensePointCloudPtr PlaneCrop(const Plane3D &plane, const ValueRange<double> &range, CropRange cropRange) const
180 {
181 return PointCloud::PlaneCrop<DensePointCloud>(plane, range, cropRange);
182 }
183
186
216 DensePointCloudPtr PlaneCrop(const Plane3D &plane, double threshold,
217 CropDirection cropBelowAbove = CropDirection::Below) const
218 {
219 return PointCloud::PlaneCrop<DensePointCloud>(plane, threshold, cropBelowAbove);
220 }
221
223
227 template <class T>
229 {
230 ComponentsPointers3D rawComponents;
231 auto error = PointCloud::TryPointComponents<T>(rawComponents);
232 if (error)
234 return DenseComponentsPointers3D<T>(rawComponents, LatticeSize());
235 }
236
238
245 template <class T>
246 bool TryPointComponents(DenseComponentsPointers3D<T> &components) const noexcept
247 {
248 ComponentsPointers3D rawComponents;
249 auto error = PointCloud::TryPointComponents<T>(rawComponents);
250 if (error)
251 return false;
252 components = DenseComponentsPointers3D<T>(rawComponents, LatticeSize());
253 return true;
254 }
255 };
256
257 CVB_END_INLINE_NS
258
259} // namespace Cvb
Object for convenient and type - safe handling of angles.
Definition angle.hpp:16
double Deg() const noexcept
Get the value in degrees.
Definition angle.hpp:89
Point components of the point cloud.
Definition components_pointers_3d.hpp:18
3D rectangle in the X, Y and Z domain.
Definition cuboid.hpp:19
Point components of a dense point cloud.
Definition dense_components_pointers_3d.hpp:15
DensePointCloudPtr Crop(const Cuboid &clipBox) const
Creates a new point cloud which only consists of the points inside the clip box.
Definition decl_dense_point_cloud.hpp:111
DensePointCloudPtr PlaneCrop(const Plane3D &plane, double threshold, CropDirection cropBelowAbove=CropDirection::Below) const
Creates a new point cloud which only consists of the points below or above given plane.
Definition decl_dense_point_cloud.hpp:216
bool TryPointComponents(DenseComponentsPointers3D< T > &components) const noexcept
Tries to get the point components from the given point cloud.
Definition decl_dense_point_cloud.hpp:246
static DensePointCloudPtr FromComposite(CompositePtr object)
Creates a dense point cloud from a composite.
Definition decl_dense_point_cloud.hpp:64
SparsePointCloudPtr ToSparsePointCloud() const
Creates a sparse point cloud from this dense point cloud with confidence plane.
Definition detail_dense_point_cloud.hpp:11
Cvb::Size2D< int > LatticeSize() const
Gets the number of x,y,z(,w) point rows and columns of the given dense PointCloud.
Definition decl_dense_point_cloud.hpp:83
DensePointCloudPtr Shrink() const
Creates a new dense point cloud where lines and columns at the borders containing only non-confident ...
Definition decl_dense_point_cloud.hpp:99
DensePointCloudPtr PlaneCrop(const Plane3D &plane, const ValueRange< double > &range, CropRange cropRange) const
Creates a new point cloud where points within or outside a range parallel to given plane are cropped.
Definition decl_dense_point_cloud.hpp:179
DenseComponentsPointers3D< T > PointComponents() const
Get the point components from the given point cloud.
Definition decl_dense_point_cloud.hpp:228
DensePointCloudPtr FrustumCrop(const Cuboid &clipBox, Angle theta, Angle phi) const
Creates a new point cloud which only consists of the points inside the clipBox, where the orientation...
Definition decl_dense_point_cloud.hpp:141
A plane in 3D space in Hessian normal form.
Definition plane_3d.hpp:19
std::shared_ptr< T > PlaneCrop(const Plane3D &plane, const ValueRange< double > &range, CropRange cropRange) const
Creates a new point cloud where points within or outside a range parallel to given plane are cropped.
Definition decl_point_cloud.hpp:391
static std::shared_ptr< T > FromComposite(CompositePtr object)
Creates a point cloud from a composite.
Definition detail_point_cloud.hpp:27
void * Handle() const noexcept
Returns C-API style handle to Node Object.
Definition decl_point_cloud.hpp:764
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
Container for range definitions.
Definition value_range.hpp:17
T make_shared(T... args)
T move(T... args)
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
CropRange
Indicates cropping range.
Definition core_3d.hpp:288
std::shared_ptr< SparsePointCloud > SparsePointCloudPtr
Convenience shared pointer for SparsePointCloud.
Definition core_3d.hpp:48
CropDirection
Indicates cropping direction.
Definition core_3d.hpp:301
@ Below
Crop below given plane.
Definition core_3d.hpp:305
std::shared_ptr< Composite > CompositePtr
Convenience shared pointer for Composite.
Definition global.hpp:102
std::shared_ptr< DensePointCloud > DensePointCloudPtr
Convenience shared pointer for DensePointCloud.
Definition core_3d.hpp:44
T rethrow_exception(T... args)