CVB++ 15.0
Loading...
Searching...
No Matches
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
29 class DensePointCloud : public PointCloud
30 {
31
32 friend class PointCloud;
33
34 public:
35 static DensePointCloudPtr FromHandle(HandleGuard<PointCloud> &&guard)
36 {
37 if (!IsDense(guard.Handle()))
38 throw std::runtime_error("handle is not a dense point cloud");
39 return std::make_shared<DensePointCloud>(std::move(guard), PrivateTag{});
40 }
41
42 template <class T>
43 static DensePointCloudPtr FromHandle(HandleGuard<PointCloud> &&guard)
44 {
45 return FromHandle(std::move(guard));
46 }
47
48 DensePointCloud(HandleGuard<PointCloud> &&guard, PrivateTag) noexcept
49 : PointCloud(std::move(guard))
50 {
51 }
52
54
63
65
72
74
79 {
80 CExports::cvbdim_t width = 0;
81 CExports::cvbdim_t height = 0;
82 Internal::DoResCall([&]() { return CVB_CALL_CAPI(CVC3DPointCloudGetLatticeSize(Handle(), width, height)); });
83 return Size2D<int>(static_cast<int>(width), static_cast<int>(height));
84 }
85
88
95 {
96 return Internal::DoResCallShareOut<DensePointCloud>(
97 [&](void *&handle) { return CVB_CALL_CAPI(CVC3DCreateShrinkedDensePointCloud(Handle(), handle)); });
98 }
99
101
106 DensePointCloudPtr Crop(const Cuboid &clipBox) const
107 {
108 return Internal::DoResCallShareOut<DensePointCloud>([&](void *&handle) {
109 return CVB_CALL_CAPI(
110 CVC3DCreateCroppedPointCloud(Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), handle));
111 });
112 }
113
117
136 DensePointCloudPtr FrustumCrop(const Cuboid &clipBox, Angle theta, Angle phi) const
137 {
138 return Internal::DoResCallShareOut<DensePointCloud>([&](void *&handle) {
139 return CVB_CALL_CAPI(CVC3DCreateFrustumCroppedPointCloud(
140 Handle(), *reinterpret_cast<const CExports::CVC3DCuboid *>(&clipBox), theta.Deg(), phi.Deg(), handle));
141 });
142 }
143
146
174 DensePointCloudPtr PlaneCrop(const Plane3D &plane, const ValueRange<double> &range, CropRange cropRange) const
175 {
176 return PointCloud::PlaneCrop<DensePointCloud>(plane, range, cropRange);
177 }
178
181
211 DensePointCloudPtr PlaneCrop(const Plane3D &plane, double threshold,
212 CropDirection cropBelowAbove = CropDirection::Below) const
213 {
214 return PointCloud::PlaneCrop<DensePointCloud>(plane, threshold, cropBelowAbove);
215 }
216
218
222 template <class T>
224 {
225 ComponentsPointers3D rawComponents;
226 auto error = PointCloud::TryPointComponents<T>(rawComponents);
227 if (error)
229 return DenseComponentsPointers3D<T>(rawComponents, LatticeSize());
230 }
231
233
240 template <class T>
241 bool TryPointComponents(DenseComponentsPointers3D<T> &components) const noexcept
242 {
243 ComponentsPointers3D rawComponents;
244 auto error = PointCloud::TryPointComponents<T>(rawComponents);
245 if (error)
246 return false;
247 components = DenseComponentsPointers3D<T>(rawComponents, LatticeSize());
248 return true;
249 }
250 };
251
252 CVB_END_INLINE_NS
253
254} // 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:106
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:211
bool TryPointComponents(DenseComponentsPointers3D< T > &components) const noexcept
Tries to get the point components from the given point cloud.
Definition decl_dense_point_cloud.hpp:241
static DensePointCloudPtr FromComposite(CompositePtr object)
Creates a dense point cloud from a composite.
Definition decl_dense_point_cloud.hpp:59
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:78
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:94
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:174
DenseComponentsPointers3D< T > PointComponents() const
Get the point components from the given point cloud.
Definition decl_dense_point_cloud.hpp:223
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:136
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:377
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:773
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)