boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("Normals"));
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud111(new pcl::PointCloud<pcl::PointXYZ>);
for (int i = 0; i < 10; i++) {
pcl::PointXYZ point;
point.x = point.y = point.z = i;
cloud->push_back(point);
}
pcl::copyPointCloud(*cloud, *cloud111);
std::cout << viewer->removeAllPointClouds() << std::endl;
std::string str = "cloud";
viewer->addPointCloud<pcl::PointXYZ>(cloud, str);
viewer->addPointCloud<pcl::PointXYZ>(cloud, "cloud1");
viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
std::cout << viewer->removePointCloud("111") << std::endl;
std::cout << viewer->updatePointCloud<pcl::PointXYZ>(cloud111, "cloud111") << std::endl;
std::cout << viewer->updatePointCloud(cloud, str) << std::endl;
std::cout << viewer->removePointCloud(str) << std::endl;
std::cout << viewer->removeAllPointClouds() << std::endl;
while (!viewer->wasStopped()) {
viewer->spinOnce(100);
boost::this_thread::sleep(boost::posix_time::microseconds(100000));
}
没有点云或是点云id不存在时都没事,就是有这个点云id的时候就崩掉了。 |