I have a point cloud defined as pcl::PointCloud<pcl::PointXYZI> cloud_xyzi_;. Sometime later, I read in data from a file and push it back into this point cloud; everything works fine. My task however requires me to filter the point cloud, and the filtering methods require pointers.
Can I simply replace my above declaration with something like this pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_xyzi_p;, initialise it in the constructor of the class and then have a pointer on its own, rather than creating a pointer just to pass it to a function? Of course change the . to -> when I use it otherwise. I ask this because I am getting unexpected behaviour when trying to implement this.
Here is my abridged class, with the current code which seems both redundant and not working great.
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_;
};