Cvb/CppPointCloudCreateAndHandle
1 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 
6 #include <iostream>
7 
8 #include "cvb/point_cloud_factory.hpp"
9 #include "cvb/point_cloud.hpp"
10 
11 void SetValuesToDensePointCloud(Cvb::DensePointCloud &cloud, const float initialValue);
12 
13 int main()
14 {
15  try
16  {
17  // create dense point cloud
18  int width = 25, height = 20;
19  auto cloudDense = Cvb::PointCloudFactory::CreateDense(Cvb::Size2D<int>(width, height),
21 
22  // set intial values to points of cloud
23  SetValuesToDensePointCloud(*cloudDense, 123.4f);
24 
25  }
26  catch (const std::exception & error)
27  {
28  std::cout << error.what() << std::endl;
29  }
30 
31  return 0;
32 }
33 
34 void SetValuesToDensePointCloud(Cvb::DensePointCloud &cloud, const float initialValue)
35 {
36  Cvb::Point3D<float>* pPoints = nullptr;
37  cloud.Points(pPoints);
38 
39  auto size = cloud.LatticeSize();
40  float x = 0, y = 0;
41  auto end = pPoints + cloud.NumPoints();
42  for (auto it = pPoints; it != end; it++)
43  {
44  *it = Cvb::Point3D<float>{ x++,y,initialValue };
45  if (x >= size.Width())
46  {
47  x = 0;
48  y++;
49  }
50  }
51 }
std::size_t Points(Point3D< T > *&points) const
Gets the 3D points from the given point cloud.
Definition: decl_point_cloud.hpp:203
T end(T... args)
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:80
Multi-purpose 3D vector class.
Definition: point_3d.hpp:21
STL class.
std::size_t NumPoints() const
Gets the number of x,y,z(,w) points in the given point cloud.
Definition: decl_point_cloud.hpp:176
static DensePointCloudPtr CreateDense(Size2D< int > size, PointCloudFlags flags)
Creates a new dense Cartesian 3D point cloud.
Definition: point_cloud_factory.hpp:226
T Width() const noexcept
Gets the horizontal component of the size.
Definition: size_2d.hpp:59
A dense Cartesian 3D point cloud object.
Definition: decl_dense_point_cloud.hpp:29