I would like to know if this is possible. I have a function:
pcl::PointCloud<pcl::PointXYZRGB> createPointCloud(std::Vector<Nodes> input)
which returns a point cloud. I would like to know if it is possible to take this point cloud, and make a pointer to a copy of it. pcl makes pointers to clouds like this:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(new pcl::PointCloud<pcl::PointXYZRGB>)
I have tried doing this:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(createPointCloud(nodeList))
This results in a pretty obvious error ie. createPointCloud doesnt return a pointer to a cloud.
I have also tried this:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR = &createPointCloud(nodeList)
and this:
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(&createPointCloud(nodeList))
And this results in the compile error: "taking address of temporary"
Is the only option to have the function return a pointer type or is there a way to do what i am asking?
EDIT:
Both of the below answers are correct, I have awarded Jonathon the correct tick as he got in first this time.
Yes, use the makeShared() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With