【发布时间】:2015-02-09 02:41:01
【问题描述】:
我有一个定义为pcl::PointCloud<pcl::PointXYZI> cloud_xyzi_; 的点云。一段时间后,我从文件中读取数据并将其推回该点云中;一切正常。然而,我的任务需要我过滤点云,而过滤方法需要指针。
我可以简单地用类似pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_xyzi_p; 的东西替换上面的声明,在类的构造函数中初始化它,然后自己拥有一个指针,而不是创建一个指针只是为了将它传递给一个函数?当然,当我使用它时,将. 更改为->。我问这个是因为我在尝试实现它时遇到了意外的行为。
这是我的删节课,当前的代码看起来既多余又不好用。
class P400toPointcloud {
public:
P400toPointcloud():
callback_counter_(0),
sensor_model_created_(false)
{
// Setup pointers for later use
cloud_xyzi_p = cloud_xyzi_.makeShared();
cloud_xyzi_fp = cloud_xyzi_f.makeShared();
}
~P400toPointcloud()
{
}
private:
pcl::PointCloud<pcl::PointXYZI> cloud_xyzi_;
pcl::PointCloud<pcl::PointXYZI> cloud_xyzi_f;
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_xyzi_p;
pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_xyzi_fp;
std::vector<unsigned int> value_idx_;
};
【问题讨论】: