2#include "../Headers/DLLInfo.h"
3#include "../Headers/PCLFunctions.h"
4#include <pcl/point_cloud.h>
5#include <pcl/point_types.h>
6#include <pcl/search/search.h>
7#include <NDEVR/RTree.h>
8#include <NDEVR/Matrix.h>
9#include <NDEVR/Buffer.h>
10#include <NDEVR/Translator.h>
16 template<
typename Po
intT>
20 using PointCloud = pcl::PointCloud<PointT>;
21 using PointCloudPtr =
typename PointCloud::Ptr;
22 using PointCloudConstPtr =
typename PointCloud::ConstPtr;
24 typedef std::shared_ptr<std::vector<int>> IndicesPtr;
25 typedef std::shared_ptr<const std::vector<int>> IndicesConstPtr;
27 typedef std::shared_ptr<PCLRTreeWrapper<PointT>> Ptr;
28 typedef std::shared_ptr<const PCLRTreeWrapper<PointT> > ConstPtr;
38 : pcl::search::Search<PointT>()
41 , m_search_count(search_count)
42 , m_current_search_count(total_search_ptr)
43 , m_log(_t(
"Tree Operation"), log)
47 : pcl::search::Search<PointT>()
50 , m_search_count(m_values.size())
51 , m_current_search_count(search_count)
52 , m_log(_t(
"Tree Operation"), log)
61 bool setInputCloud(
const PointCloudConstPtr& cloud,
const IndicesConstPtr& indices = IndicesConstPtr()) final
override
63 return pcl::search::Search<PointT>::setInputCloud(cloud, indices);
76 std::vector<int>& k_indices,
77 std::vector<float>& k_sqr_distances)
const final override
80 k_indices, k_sqr_distances,
95 std::vector<int>& k_indices,
96 std::vector<float>& k_sqr_distances,
97 unsigned int k = 0) const final
override
103 ku =
getMin(m_max_k, m_values.size());
108 uint04 index =
m_tree.closestElementPresorted(vertex, m_values, max_distance_squared, 0.0f);
110 k_sqr_distances.resize(1);
114 k_sqr_distances[0] = Constant<fltp04>::Max;
118 k_indices[0] =
m_tree.indices()[index];
119 k_sqr_distances[0] = max_distance_squared;
127 m_tree.presortedClosestElements(vertex, ku, heap, m_values, max_distance_squared);
128 k_indices.resize(heap.size());
129 k_sqr_distances.resize(heap.size());
130 const uint04 size = heap.size();
131 auto sorted_values = heap.sortedValues();
132 for (
uint04 i = 0; i < sorted_values.size(); i++)
135 k_sqr_distances[i] = sorted_values[i].second;
138 if (m_current_search_count % 5000 == 0)
140 m_current_search_count++;
143 void setMaxSearchDistance(
fltp04 max)
145 m_max_tree_span = max;
156 uint04& m_current_search_count;
157 fltp04 m_max_tree_span = Constant<fltp04>::Max;
158 uint04 m_max_k = Constant<uint04>::Max;
The equivelent of std::vector but with a bit more control.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
PCLRTreeWrapper(const Buffer< Vertex< 3, fltp04 > > &vertices, const RTree< 3, fltp04 > &tree, uint04 &total_search_ptr, uint04 search_count, LogPtr log=LogPtr())
Constructor for KdTree.
int radiusSearch(const PointT &point, double radius, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances, unsigned int k=0) const final override
Search for all the nearest neighbors of the query point in a given radius.
virtual ~PCLRTreeWrapper()
Destructor for KdTree.
int nearestKSearch(const PointT &point, int k, std::vector< int > &k_indices, std::vector< float > &k_sqr_distances) const final override
Search for the k-nearest neighbors for the given query point.
const RTree< 3, fltp04 > & m_tree
A pointer to the internal KdTree object.
Used with InfoPipe to signal that the system will be using progress.
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.