Skip to content

Commit

Permalink
Reduce number of allocations, for example for kdtree searches
Browse files Browse the repository at this point in the history
KdTree calls vectorize for every point. Before this commit, vectorize unnecessarily allocated and freed memory for evey call.
  • Loading branch information
mvieth committed Oct 12, 2023
1 parent 5e640dd commit 7c81724
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions common/include/pcl/point_representation.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,24 @@ namespace pcl
delete [] temp;
}

void
vectorize (const PointT &p, float* out) const
{
copyToFloatArray (p, out);
if (!alpha_.empty ())
for (int i = 0; i < nr_dimensions_; ++i)
out[i] *= alpha_[i];
}

void
vectorize (const PointT &p, std::vector<float> &out) const
{
copyToFloatArray (p, out.data());
if (!alpha_.empty ())
for (int i = 0; i < nr_dimensions_; ++i)
out[i] *= alpha_[i];
}

/** \brief Set the rescale values to use when vectorizing points
* \param[in] rescale_array The array/vector of rescale values. Can be of any type that implements the [] operator.
*/
Expand Down

0 comments on commit 7c81724

Please sign in to comment.