sampling_visualizer.cpp
Go to the documentation of this file.
2 
3 pcl::ModelCoefficients SamplingVisualizer::createCylinder(Eigen::Vector3d pt_on_axis, Eigen::Vector3d axis_direction,
4  double radius, double extent)
5 {
6  pcl::ModelCoefficients cylinder_coeff;
7  cylinder_coeff.values.resize(7);
8  cylinder_coeff.values[0] = pt_on_axis.x();
9  cylinder_coeff.values[1] = pt_on_axis.y();
10  cylinder_coeff.values[2] = pt_on_axis.z();
11  cylinder_coeff.values[3] = axis_direction.x() * extent;
12  cylinder_coeff.values[4] = axis_direction.y() * extent;
13  cylinder_coeff.values[5] = axis_direction.z() * extent;
14  cylinder_coeff.values[6] = radius;
15  return cylinder_coeff;
16 }
17 
18 void SamplingVisualizer::addCylinders(const std::vector<CylindricalShell> &shells, void* viewer_void,
19  std::string handle_index, double r, double g, double b)
20 {
22  pcl::visualization::PCLVisualizer> *>(viewer_void);
23 
24  for (std::size_t i = 0; i < shells.size(); i++)
25  {
26  std::string id = "cylinder" + handle_index + boost::lexical_cast < std::string > (i);
27  viewer->addCylinder(
28  createCylinder(shells[i].getCentroid(), shells[i].getCurvatureAxis(), shells[i].getRadius(),
29  shells[i].getExtent()),
30  id);
31  viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, r, g, b, id);
32  viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION,
33  pcl::visualization::PCL_VISUALIZER_REPRESENTATION_SURFACE, id);
34  viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.4, id);
35  }
36 }
37 
38 void SamplingVisualizer::createViewer(PointCloud::ConstPtr cloud, std::vector<CylindricalShell> shells,
39  Eigen::MatrixXd samples, double target_radius)
40 {
41  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));
42  viewer->setBackgroundColor(0, 0, 0);
43  pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> rgb(cloud);
44  viewer->addPointCloud < pcl::PointXYZRGBA > (cloud, rgb, "sample cloud");
45  viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "sample cloud");
46 
47  addCylinders(shells, (void*)&viewer, "", 0, 1.0, 1.0);
48 
49  for (std::size_t i = 0; i < samples.cols(); i++)
50  {
51  pcl::PointXYZ center;
52  center.x = samples(0, i);
53  center.y = samples(1, i);
54  center.z = samples(2, i);
55  std::string id = "sphere" + boost::lexical_cast < std::string > (i);
56  viewer->addSphere(center, target_radius * 0.6, id);
57  viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 0.0, 0.0, id);
58  }
59 
60  this->viewer = viewer;
61 }
void createViewer(PointCloud::ConstPtr cloud, std::vector< CylindricalShell > shells, Eigen::MatrixXd samples, double target_radius)
boost::shared_ptr< pcl::visualization::PCLVisualizer > viewer
pcl::ModelCoefficients createCylinder(Eigen::Vector3d pt_on_axis, Eigen::Vector3d axis_direction, double radius, double extent)
void addCylinders(const std::vector< CylindricalShell > &shells, void *viewer_void, std::string handle_index="", double r=0.0, double g=1.0, double b=1.0)


handle_detector
Author(s):
autogenerated on Mon Jun 10 2019 13:29:00