Skip to content

Commit

Permalink
Pass vectors as const ref in case they might be large.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Apr 23, 2018
1 parent 6f5115b commit 545a440
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 6 additions & 3 deletions pdal/EigenUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ namespace pdal
namespace eigen
{

Eigen::Vector3d computeCentroid(PointView& view, std::vector<PointId> ids)
Eigen::Vector3d computeCentroid(PointView& view,
const std::vector<PointId>& ids)
{
using namespace Eigen;

Expand Down Expand Up @@ -80,7 +81,8 @@ Eigen::Vector3d computeCentroid(PointView& view, std::vector<PointId> ids)
return centroid;
}

Eigen::Matrix3f computeCovariance(PointView& view, std::vector<PointId> ids)
Eigen::Matrix3f computeCovariance(PointView& view,
const std::vector<PointId>& ids)
{
using namespace Eigen;

Expand All @@ -102,7 +104,8 @@ Eigen::Matrix3f computeCovariance(PointView& view, std::vector<PointId> ids)
return A * A.transpose() / (ids.size()-1);
}

uint8_t computeRank(PointView& view, std::vector<PointId> ids, double threshold)
uint8_t computeRank(PointView& view, const std::vector<PointId>& ids,
double threshold)
{
using namespace Eigen;

Expand Down
6 changes: 3 additions & 3 deletions pdal/EigenUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace eigen
\return the 3D centroid of the XYZ dimensions.
*/
PDAL_DLL Eigen::Vector3d computeCentroid(PointView& view,
std::vector<PointId> ids);
const std::vector<PointId>& ids);

/**
Compute the covariance matrix of a collection of points.
Expand All @@ -101,7 +101,7 @@ PDAL_DLL Eigen::Vector3d computeCentroid(PointView& view,
\return the covariance matrix of the XYZ dimensions.
*/
PDAL_DLL Eigen::Matrix3f computeCovariance(PointView& view,
std::vector<PointId> ids);
const std::vector<PointId>& ids);

/**
Compute second derivative in X direction using central difference method.
Expand Down Expand Up @@ -232,7 +232,7 @@ PDAL_DLL Eigen::MatrixXd cleanDSM(Eigen::MatrixXd data);
\param ids a vector of PointIds specifying a subset of points.
\return the estimated rank.
*/
PDAL_DLL uint8_t computeRank(PointView& view, std::vector<PointId> ids,
PDAL_DLL uint8_t computeRank(PointView& view, const std::vector<PointId>& ids,
double threshold);

/**
Expand Down
1 change: 0 additions & 1 deletion pdal/PointView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <memory>
#include <queue>
#include <set>
#include <vector>
#include <deque>

#pragma warning(disable: 4244) // conversion from 'type1' to 'type2', possible loss of data
Expand Down

0 comments on commit 545a440

Please sign in to comment.