Skip to content

Commit

Permalink
Add PointIdList typedef for std::vector<PointId>
Browse files Browse the repository at this point in the history
  • Loading branch information
chambbj committed Sep 19, 2019
1 parent de7fb85 commit 797a784
Show file tree
Hide file tree
Showing 29 changed files with 121 additions and 122 deletions.
2 changes: 1 addition & 1 deletion filters/ChipperFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class PDAL_DLL ChipperFilter : public pdal::Filter
PointId m_threshold;
PointViewPtr m_inView;
PointViewSet m_outViews;
std::vector<PointId> m_partitions;
PointIdList m_partitions;
ChipRefList m_xvec;
ChipRefList m_yvec;
ChipRefList m_spare;
Expand Down
2 changes: 1 addition & 1 deletion filters/GreedyProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void GreedyProjection::filter(PointView& view)
nnn_ = (int)(std::min)((point_count_t)nnn_, view.size());

// Variables to hold the results of nearest neighbor searches
std::vector<PointId> nnIdx(nnn_);
PointIdList nnIdx(nnn_);
std::vector<double> sqrDists(nnn_);

// current number of connected components
Expand Down
10 changes: 5 additions & 5 deletions filters/GreedyProjection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ namespace pdal
/** \brief List of point states **/
std::vector<GP3Type> state_;
/** \brief List of sources **/
std::vector<PointId> source_;
PointIdList source_;
/** \brief List of fringe neighbors in one direction **/
std::vector<PointId> ffn_;
PointIdList ffn_;
/** \brief List of fringe neighbors in other direction **/
std::vector<PointId> sfn_;
PointIdList sfn_;
/** \brief Connected component labels for each point **/
std::vector<PointId> part_;
PointIdList part_;
/** \brief Points on the outer edge from which the mesh is grown **/
std::vector<PointId> fringe_queue_;
PointIdList fringe_queue_;

/** \brief Flag to set if the current point is free **/
bool is_current_free_;
Expand Down
2 changes: 1 addition & 1 deletion filters/HAGFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void HAGFilter::filter(PointView& view)
{
PointViewPtr gView = view.makeNew();
PointViewPtr ngView = view.makeNew();
std::vector<PointId> gIdx, ngIdx;
PointIdList gIdx, ngIdx;

// First pass: Separate into ground and non-ground views.
for (PointId i = 0; i < view.size(); ++i)
Expand Down
4 changes: 2 additions & 2 deletions filters/InfoFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class PDAL_DLL InfoFilter : public Filter, public Streamable
std::list<NearPoint> m_results;

std::string m_pointSpec;
std::vector<PointId> m_idList;
std::vector<PointId>::const_iterator m_idCur;
PointIdList m_idList;
PointIdList::const_iterator m_idCur;
DimTypeList m_dims;
size_t m_pointSize;
PointId m_count;
Expand Down
8 changes: 4 additions & 4 deletions filters/IterativeClosestPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ PointViewPtr IterativeClosestPoint::icp(PointViewPtr fixed,
{
// Compute centroid of fixed PointView such that both the fixed an moving
// PointViews can be centered.
std::vector<PointId> ids(fixed->size());
PointIdList ids(fixed->size());
std::iota(ids.begin(), ids.end(), 0);
auto centroid = computeCentroid(*fixed, ids);

Expand Down Expand Up @@ -136,7 +136,7 @@ PointViewPtr IterativeClosestPoint::icp(PointViewPtr fixed,

// Create empty lists to hold point correspondences, and initialize MSE
// to zero.
std::vector<PointId> fixed_idx, moving_idx;
PointIdList fixed_idx, moving_idx;
fixed_idx.reserve(tempMovingTransformed->size());
moving_idx.reserve(tempMovingTransformed->size());
double mse(0.0);
Expand All @@ -149,7 +149,7 @@ PointViewPtr IterativeClosestPoint::icp(PointViewPtr fixed,
// Find the index of the nearest neighbor, and the square distance
// between each point.
PointRef p = tempMovingTransformed->point(i);
std::vector<PointId> indices(1);
PointIdList indices(1);
std::vector<double> sqr_dists(1);
kd_fixed.knnSearch(p, 1, &indices, &sqr_dists);

Expand Down Expand Up @@ -261,7 +261,7 @@ PointViewPtr IterativeClosestPoint::icp(PointViewPtr fixed,
for (PointId i = 0; i < moving->size(); ++i)
{
PointRef p = moving->point(i);
std::vector<PointId> indices(1);
PointIdList indices(1);
std::vector<double> sqr_dists(1);
kd_fixed_orig.knnSearch(p, 1, &indices, &sqr_dists);
mse += std::sqrt(sqr_dists[0]);
Expand Down
6 changes: 3 additions & 3 deletions filters/LOFFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void LOFFilter::filter(PointView& view)
log()->get(LogLevel::Debug) << "Computing k-distances...\n";
for (PointId i = 0; i < view.size(); ++i)
{
std::vector<PointId> indices(m_minpts);
PointIdList indices(m_minpts);
std::vector<double> sqr_dists(m_minpts);
index.knnSearch(i, m_minpts, &indices, &sqr_dists);
view.setField(m_kdist, i, std::sqrt(sqr_dists[m_minpts-1]));
Expand All @@ -98,7 +98,7 @@ void LOFFilter::filter(PointView& view)
log()->get(LogLevel::Debug) << "Computing lrd...\n";
for (PointId i = 0; i < view.size(); ++i)
{
std::vector<PointId> indices(m_minpts);
PointIdList indices(m_minpts);
std::vector<double> sqr_dists(m_minpts);
index.knnSearch(i, m_minpts, &indices, &sqr_dists);
double M1 = 0.0;
Expand All @@ -118,7 +118,7 @@ void LOFFilter::filter(PointView& view)
for (PointId i = 0; i < view.size(); ++i)
{
double lrdp = view.getFieldAs<double>(m_lrd, i);
std::vector<PointId> indices(m_minpts);
PointIdList indices(m_minpts);
std::vector<double> sqr_dists(m_minpts);
index.knnSearch(i, m_minpts, &indices, &sqr_dists);
double M1 = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion filters/NNDistanceFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void NNDistanceFilter::filter(PointView& view)
log()->get(LogLevel::Debug) << "Computing k-distances...\n";
for (PointId idx = 0; idx < view.size(); ++idx)
{
std::vector<PointId> indices(k);
PointIdList indices(k);
std::vector<double> sqr_dists(k);
index.knnSearch(idx, k, &indices, &sqr_dists);
double val;
Expand Down
2 changes: 1 addition & 1 deletion filters/NeighborClassifierFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void NeighborClassifierFilter::prepared(PointTableRef table)
void NeighborClassifierFilter::doOneNoDomain(PointRef &point, PointRef &temp,
KD3Index &kdi)
{
std::vector<PointId> iSrc = kdi.neighbors(point, m_k);
PointIdList iSrc = kdi.neighbors(point, m_k);
double thresh = iSrc.size()/2.0;

// vote NNs
Expand Down
6 changes: 3 additions & 3 deletions filters/OutlierFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Indices OutlierFilter::processRadius(PointViewPtr inView)

point_count_t np = inView->size();

std::vector<PointId> inliers, outliers;
PointIdList inliers, outliers;

for (PointId i = 0; i < np; ++i)
{
Expand All @@ -102,14 +102,14 @@ Indices OutlierFilter::processStatistical(PointViewPtr inView)

point_count_t np = inView->size();

std::vector<PointId> inliers, outliers;
PointIdList inliers, outliers;

std::vector<double> distances(np, 0.0);

// we increase the count by one because the query point itself will
// be included with a distance of 0
point_count_t count = m_meanK + 1;
std::vector<PointId> indices(count);
PointIdList indices(count);
std::vector<double> sqr_dists(count);
for (PointId i = 0; i < np; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions filters/OutlierFilter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Options;

struct Indices
{
std::vector<PointId> inliers;
std::vector<PointId> outliers;
PointIdList inliers;
PointIdList outliers;
};

class PDAL_DLL OutlierFilter : public pdal::Filter
Expand Down
2 changes: 1 addition & 1 deletion filters/OverlayFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void OverlayFilter::filter(PointView& view)

for (const auto& poly : m_polygons)
{
std::vector<PointId> ids = idx.getPoints(poly.geom.bounds());
PointIdList ids = idx.getPoints(poly.geom.bounds());

PointRef point(view, 0);
for (PointId id : ids)
Expand Down
6 changes: 3 additions & 3 deletions filters/PMFFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void PMFFilter::processGround(PointViewPtr view)
double x = bounds.minx + (c + 0.5) * m_args->m_cellSize;
double y = bounds.miny + (r + 0.5) * m_args->m_cellSize;
int k = 1;
std::vector<PointId> neighbors(k);
PointIdList neighbors(k);
std::vector<double> sqr_dists(k);
kdi.knnSearch(x, y, k, &neighbors, &sqr_dists);
out[idx] = temp->getFieldAs<double>(Dimension::Id::Z, neighbors[0]);
Expand All @@ -292,7 +292,7 @@ void PMFFilter::processGround(PointViewPtr view)
ZImin.swap(out);

// initialize ground indices
std::vector<PointId> groundIdx;
PointIdList groundIdx;
for (PointId i = 0; i < view->size(); ++i)
groundIdx.push_back(i);

Expand Down Expand Up @@ -340,7 +340,7 @@ void PMFFilter::processGround(PointViewPtr view)
std::vector<double> me = erodeDiamond(ZImin, rows, cols, iters);
std::vector<double> mo = dilateDiamond(me, rows, cols, iters);

std::vector<PointId> groundNewIdx;
PointIdList groundNewIdx;
for (auto p_idx : groundIdx)
{
double x = view->getFieldAs<double>(Dimension::Id::X, p_idx);
Expand Down
4 changes: 2 additions & 2 deletions filters/PlaneFitFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ void PlaneFitFilter::setPlaneFit(PointView& view, const PointId& i,
const KD3Index& kdi)
{
// Find k-nearest neighbors of i.
std::vector<PointId> ni = kdi.neighbors(i, m_knn + 1);
PointIdList ni = kdi.neighbors(i, m_knn + 1);

// Normal based only on neighbors, so exclude first point.
std::vector<PointId> neighbors(ni.begin() + 1, ni.end());
PointIdList neighbors(ni.begin() + 1, ni.end());

// Covariance and normal are based off demeaned coordinates, so we record
// the centroid to properly offset the coordinates when computing point to
Expand Down
2 changes: 1 addition & 1 deletion filters/RadialDensityFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void RadialDensityFilter::filter(PointView& view)
double factor = 1.0 / ((4.0 / 3.0) * 3.14159 * (m_rad * m_rad * m_rad));
for (PointId i = 0; i < view.size(); ++i)
{
std::vector<PointId> pts = index.radius(i, m_rad);
PointIdList pts = index.radius(i, m_rad);
view.setField(m_rdens, i, pts.size() * factor);
}
}
Expand Down
2 changes: 1 addition & 1 deletion filters/SMRFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ std::vector<double> SMRFilter::knnfill(PointViewPtr view,
double x = m_bounds.minx + (c + 0.5) * m_args->m_cell;
double y = m_bounds.miny + (r + 0.5) * m_args->m_cell;
int k = 8;
std::vector<PointId> neighbors(k);
PointIdList neighbors(k);
std::vector<double> sqr_dists(k);
kdi.knnSearch(x, y, k, &neighbors, &sqr_dists);

Expand Down
2 changes: 1 addition & 1 deletion filters/VoxelCentroidNearestNeighborFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PointViewSet VoxelCentroidNearestNeighborFilter::run(PointViewPtr view)

// Make an initial pass through the input PointView to index PointIds by
// row, column, and depth.
std::map<std::tuple<size_t, size_t, size_t>, std::vector<PointId>>
std::map<std::tuple<size_t, size_t, size_t>, PointIdList>
populated_voxel_ids;
for (PointId id = 0; id < view->size(); ++id)
{
Expand Down
14 changes: 6 additions & 8 deletions filters/private/Segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,17 @@ namespace pdal
namespace Segmentation
{

std::vector<std::vector<PointId>> extractClusters(PointView& view,
uint64_t min_points,
uint64_t max_points,
double tolerance)
std::vector<PointIdList> extractClusters(PointView& view, uint64_t min_points,
uint64_t max_points, double tolerance)
{
// Index the incoming PointView for subsequent radius searches.
KD3Index kdi(view);
kdi.build();

// Create variables to track PointIds that have already been added to
// clusters and to build the list of cluster indices.
std::vector<PointId> processed(view.size(), 0);
std::vector<std::vector<PointId>> clusters;
PointIdList processed(view.size(), 0);
std::vector<PointIdList> clusters;

for (PointId i = 0; i < view.size(); ++i)
{
Expand All @@ -72,7 +70,7 @@ std::vector<std::vector<PointId>> extractClusters(PointView& view,

// Initialize list of indices belonging to current cluster, marking the
// seed point as processed.
std::vector<PointId> seed_queue;
PointIdList seed_queue;
size_t sq_idx = 0;
seed_queue.push_back(i);
processed[i] = 1;
Expand All @@ -84,7 +82,7 @@ std::vector<std::vector<PointId>> extractClusters(PointView& view,
{
// Find neighbors of the next cluster point.
PointId j = seed_queue[sq_idx];
std::vector<PointId> ids = kdi.radius(j, tolerance);
PointIdList ids = kdi.radius(j, tolerance);

// The case where the only neighbor is the query point.
if (ids.size() == 1)
Expand Down
8 changes: 4 additions & 4 deletions filters/private/Segmentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ namespace Segmentation
\param[in] tolerance the tolerance for adding points to a cluster.
\returns a vector of clusters (themselves vectors of PointIds).
*/
PDAL_DLL std::vector<std::vector<PointId>> extractClusters(PointView& view,
uint64_t min_points,
uint64_t max_points,
double tolerance);
PDAL_DLL std::vector<PointIdList> extractClusters(PointView& view,
uint64_t min_points,
uint64_t max_points,
double tolerance);

PDAL_DLL void ignoreDimRange(DimRange dr, PointViewPtr input, PointViewPtr keep,
PointViewPtr ignore);
Expand Down
10 changes: 5 additions & 5 deletions pdal/EigenUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PointViewPtr demeanPointView(const PointView& view)
using namespace Eigen;
using namespace Dimension;

std::vector<PointId> ids(view.size());
PointIdList ids(view.size());
std::iota(ids.begin(), ids.end(), 0);
Vector3d centroid = computeCentroid(view, ids);
PointViewPtr outView = view.makeNew();
Expand Down Expand Up @@ -155,7 +155,7 @@ void transformInPlace(PointView& view, double* matrix)
}

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

Expand Down Expand Up @@ -184,7 +184,7 @@ Eigen::Vector3d computeCentroid(const PointView& view,
}

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

Expand Down Expand Up @@ -212,7 +212,7 @@ Eigen::Matrix3d computeCovariance(const PointView& view,
return A * A.transpose() / (ids.size()-1);
}

uint8_t computeRank(const PointView& view, const std::vector<PointId>& ids,
uint8_t computeRank(const PointView& view, const PointIdList& ids,
double threshold)
{
using namespace Eigen;
Expand Down Expand Up @@ -362,7 +362,7 @@ Eigen::MatrixXd pointViewToEigen(const PointView& view)
return matrix;
}

Eigen::MatrixXd pointViewToEigen(const PointView& view, const std::vector<PointId>& ids)
Eigen::MatrixXd pointViewToEigen(const PointView& view, const PointIdList& ids)
{
Eigen::MatrixXd matrix(ids.size(), 3);
for (size_t i = 0; i < ids.size(); ++i)
Expand Down
8 changes: 4 additions & 4 deletions pdal/EigenUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PDAL_DLL void transformInPlace(PointView&, double* matrix);
\return the 3D centroid of the XYZ dimensions.
*/
PDAL_DLL Eigen::Vector3d computeCentroid(const PointView& view,
const std::vector<PointId>& ids);
const PointIdList& ids);

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

/**
Compute the rank of a collection of points.
Expand Down Expand Up @@ -157,7 +157,7 @@ PDAL_DLL Eigen::Matrix3d computeCovariance(const PointView& view,
\return the estimated rank.
*/
PDAL_DLL uint8_t computeRank(const PointView& view,
const std::vector<PointId>& ids, double threshold);
const PointIdList& ids, double threshold);

/**
Find local minimum elevations by extended local minimum.
Expand Down Expand Up @@ -225,7 +225,7 @@ PDAL_DLL std::vector<double> erodeDiamond(std::vector<double> data,
API. It is not currently used in the PDAL codebase itself.
*/
PDAL_DLL Eigen::MatrixXd pointViewToEigen(const PointView& view);
PDAL_DLL Eigen::MatrixXd pointViewToEigen(const PointView& view, const std::vector<PointId>& ids);
PDAL_DLL Eigen::MatrixXd pointViewToEigen(const PointView& view, const PointIdList& ids);

/**
Write Eigen Matrix as a GDAL raster.
Expand Down

0 comments on commit 797a784

Please sign in to comment.