Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in TextureMapping #3549

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions surface/include/pcl/surface/impl/texture_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ pcl::TextureMapping<PointInT>::removeOccludedPoints (const PointCloudPtr &input_
double maxDeltaZ = octree_voxel_size;

// create an octree to perform rayTracing
OctreePtr octree (new Octree (octree_voxel_size));
Octree octree (octree_voxel_size);
// create octree structure
octree->setInputCloud (input_cloud);
octree.setInputCloud (input_cloud);
// update bounding box automatically
octree->defineBoundingBox ();
octree.defineBoundingBox ();
// add points in the tree
octree->addPointsFromInputCloud ();
octree.addPointsFromInputCloud ();

visible_indices.clear ();

Expand All @@ -435,7 +435,7 @@ pcl::TextureMapping<PointInT>::removeOccludedPoints (const PointCloudPtr &input_
direction (2) = input_cloud->points[i].z;

// if point is not occluded
octree->getIntersectedVoxelIndices (direction, -direction, indices);
octree.getIntersectedVoxelIndices (direction, -direction, indices);

int nbocc = static_cast<int> (indices.size ());
for (const int &index : indices)
Expand Down Expand Up @@ -647,14 +647,13 @@ pcl::TextureMapping<PointInT>::showOcclusions (const PointCloudPtr &input_cloud,
double maxDeltaZ = octree_voxel_size * 2.0;

// create an octree to perform rayTracing
pcl::octree::OctreePointCloudSearch<PointInT> *octree;
octree = new pcl::octree::OctreePointCloudSearch<PointInT> (octree_voxel_size);
Octree octree (octree_voxel_size);
// create octree structure
octree->setInputCloud (input_cloud);
octree.setInputCloud (input_cloud);
// update bounding box automatically
octree->defineBoundingBox ();
octree.defineBoundingBox ();
// add points in the tree
octree->addPointsFromInputCloud ();
octree.addPointsFromInputCloud ();

// ray direction
Eigen::Vector3f direction;
Expand All @@ -677,7 +676,7 @@ pcl::TextureMapping<PointInT>::showOcclusions (const PointCloudPtr &input_cloud,

// get number of occlusions for that point
indices.clear ();
int nbocc = octree->getIntersectedVoxelIndices (direction, -direction, indices);
int nbocc = octree.getIntersectedVoxelIndices (direction, -direction, indices);

nbocc = static_cast<int> (indices.size ());

Expand Down