Skip to content

Commit

Permalink
Minor utility generalizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kzampog committed Nov 13, 2019
1 parent 35b7219 commit 78f7bf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#include <cilantro/core/common_pair_evaluators.hpp>

namespace cilantro {
template <typename T>
std::vector<size_t> getNNGraphNodeDegrees(const std::vector<std::vector<T>> &adj_list,
bool remove_self = true)
template <typename T, typename DegT = size_t>
std::vector<DegT> getNNGraphNodeDegrees(const std::vector<std::vector<T>> &adj_list,
bool remove_self = true)
{
std::vector<size_t> deg(adj_list.size());
std::vector<DegT> deg(adj_list.size());
if (remove_self) {
#pragma omp parallel for
for (size_t i = 0; i < deg.size(); i++) {
Expand Down
18 changes: 10 additions & 8 deletions include/cilantro/utilities/point_cloud.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ namespace cilantro {
: points(points), normals(normals), colors(colors)
{}

template <typename IndexT = size_t>
PointCloud(const PointCloud<ScalarT,EigenDim> &cloud,
const std::vector<size_t> &indices,
const std::vector<IndexT> &indices,
bool negate = false)
{
std::set<size_t> indices_set;
std::set<IndexT> indices_set;
if (negate) {
std::vector<size_t> full_indices(cloud.size());
for (size_t i = 0; i < cloud.size(); i++) full_indices[i] = i;
std::set<size_t> indices_to_discard(indices.begin(), indices.end());
std::vector<IndexT> full_indices(cloud.size());
for (IndexT i = 0; i < cloud.size(); i++) full_indices[i] = i;
std::set<IndexT> indices_to_discard(indices.begin(), indices.end());
std::set_difference(full_indices.begin(), full_indices.end(), indices_to_discard.begin(), indices_to_discard.end(), std::inserter(indices_set, indices_set.begin()));
} else {
indices_set = std::set<size_t>(indices.begin(), indices.end());
indices_set = std::set<IndexT>(indices.begin(), indices.end());
}

if (cloud.hasNormals() && cloud.hasColors()) {
Expand Down Expand Up @@ -147,10 +148,11 @@ namespace cilantro {
return *this;
}

PointCloud& remove(const std::vector<size_t> &indices) {
template <typename IndexT = size_t>
PointCloud& remove(const std::vector<IndexT> &indices) {
if (indices.empty()) return *this;

std::set<size_t> indices_set(indices.begin(), indices.end());
std::set<IndexT> indices_set(indices.begin(), indices.end());
if (indices_set.size() >= size()) {
clear();
return *this;
Expand Down

0 comments on commit 78f7bf1

Please sign in to comment.