38 #ifndef PCL_GRAPH_IMPL_NEAREST_NEIGHBORS_GRAPH_BUILDER_CPP
39 #define PCL_GRAPH_IMPL_NEAREST_NEIGHBORS_GRAPH_BUILDER_CPP
41 #include <pcl/point_types.h>
42 #include <pcl/common/io.h>
43 #include <pcl/common/point_tests.h>
44 #include <pcl/search/kdtree.h>
45 #include <pcl/search/organized.h>
49 template <
typename Po
intT,
typename GraphT>
void
60 for (
size_t i = 0; i < indices_->size(); ++i)
62 if (!pcl::isFinite(input_->operator[](indices_->operator[](i))))
64 fake_indices_ =
false;
68 indices_->operator[](k++) = indices_->operator[](i);
76 typename pcl::PointCloud<PointOutT>::Ptr cloud(
new pcl::PointCloud<PointOutT>);
77 pcl::copyPointCloud(*input_, *indices_, *cloud);
78 graph = GraphT(cloud);
84 if (cloud->isOrganized())
86 search_.reset(
new pcl::search::OrganizedNeighbor<PointOutT>);
91 search_.reset(
new pcl::search::KdTree<PointOutT>);
96 std::vector<int> neighbors(num_neighbors_ + 1);
97 std::vector<float> distances(num_neighbors_ + 1);
98 search_->setInputCloud(cloud);
99 for (
size_t i = 0; i < cloud->size(); ++i)
103 search_->nearestKSearch(i, num_neighbors_ + 1, neighbors, distances);
104 for (
size_t j = 1; j < neighbors.size(); ++j)
105 if (!boost::edge(i, neighbors[j], graph).second)
107 boost::add_edge(i, neighbors[j], graph);
114 for (
size_t i = 0; i < indices_->size(); ++i)
116 point_to_vertex_map_[indices_->operator[](i)] =
v++;