2

Code to convert:

struct CurrentFrameCloudView
{
  CurrentFrameCloudView() : cloud_device_ (480, 640), cloud_viewer_ ("Frame Cloud Viewer")
  {
    cloud_ptr_ = PointCloud<PointXYZ>::Ptr (new PointCloud<PointXYZ>);

    cloud_viewer_.setBackgroundColor (0, 0, 0.15);
    cloud_viewer_.setPointCloudRenderingProperties (visualization::PCL_VISUALIZER_POINT_SIZE, 1);
    cloud_viewer_.addCoordinateSystem (1.0);
    cloud_viewer_.initCameraParameters ();
    cloud_viewer_.setPosition (0, 500);
    cloud_viewer_.setSize (640, 480);
    cloud_viewer_.setCameraClipDistances (0.01, 10.01);
  }

  void
  show (const KinfuTracker& kinfu)
  {
    kinfu.getLastFrameCloud (cloud_device_);

    int c;
    cloud_device_.download (cloud_ptr_->points, c);
    cloud_ptr_->width = cloud_device_.cols ();
    cloud_ptr_->height = cloud_device_.rows ();
    cloud_ptr_->is_dense = false;

    cloud_viewer_.removeAllPointClouds ();
    cloud_viewer_.addPointCloud<PointXYZ>(cloud_ptr_);
    cloud_viewer_.spinOnce ();
  }

  void
  setViewerPose (const Eigen::Affine3f& viewer_pose) {
    ::setViewerPose (cloud_viewer_, viewer_pose);
  }

  PointCloud<PointXYZ>::Ptr cloud_ptr_;
  DeviceArray2D<PointXYZ> cloud_device_;
  visualization::PCLVisualizer cloud_viewer_;
};

Problem:

Could some one explain me this line of code?

void
setViewerPose (const Eigen::Affine3f& viewer_pose) {
        ::setViewerPose (cloud_viewer_, viewer_pose); // especially here ...
}

Any help is welcome!

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
alap
  • 646
  • 1
  • 11
  • 24
  • 2
    The double colon is a reference to global namespace. See [this question about this operator](http://stackoverflow.com/questions/4269034/what-is-the-meaning-of-prepended-double-colon-to-class-name) – ghik Nov 01 '13 at 22:00
  • Use the scope operator, ::, to explicitly state scope. As @ghik stated, without a scope stated, look global. – ChuckCottrill Nov 01 '13 at 22:23

1 Answers1

4
::setViewerPose (cloud_viewer_, viewer_pose);

This line calls a global function setViewerPose(). The double colon :: makes sure it calls a function in the global namespace rather than one in the current class.

In general, :: is used to access namespace members a la std::cout, or static class members such as MySingleton::instance. If you leave out the namespace/class name on the left then it accesses global items.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • I was having a though similar to this, but I got confused with the c part of the code. You're answer helped getting to the solution! Thank you! I accept asap! – alap Nov 01 '13 at 22:02
  • 1
    The :: is not optional. Since C++ resolves the name scope before it considers overloading and argument resolution, it won't consider the global `setViewerPose` and will complain that arguments to `CurrentFrameCloudView::setViewerPose` don't match. See, e.g., http://stackoverflow.com/a/72075/25507. – Josh Kelley Nov 01 '13 at 22:07
  • The problem here is "funny" because the same name is used for the global function and the "class" function. It's a legacy code so I don't wanna change this. – alap Nov 01 '13 at 22:12