7 #include <Eigen/Geometry>
20 template <
bool HasNormals = false,
bool HasCovs = false>
42 template <
typename Po
intCloud>
43 void add(
const Setting& setting,
const Eigen::Vector4d& transformed_pt,
const PointCloud&
points,
size_t i,
const Eigen::Isometry3d& T) {
46 std::any_of(this->points.begin(), this->points.end(), [&](
const auto& pt) { return (pt - transformed_pt).squaredNorm() < setting.min_sq_dist_in_cell; })
51 this->points.emplace_back(transformed_pt);
52 if constexpr (HasNormals) {
55 if constexpr (HasCovs) {
84 size_t knn_search(
const Eigen::Vector4d& pt,
int k,
size_t* k_indices,
double* k_sq_dists)
const {
89 KnnResult<-1> result(k_indices, k_sq_dists, k);
100 template <
typename Result>
101 void knn_search(
const Eigen::Vector4d& pt, Result& result)
const {
106 for (
size_t i = 0; i <
points.size(); i++) {
107 const double sq_dist = (
points[i] - pt).squaredNorm();
108 result.push(i, sq_dist);
116 std::conditional_t<HasNormals, std::vector<Eigen::Vector4d>,
Empty>
normals;
117 std::conditional_t<HasCovs, std::vector<Eigen::Matrix4d>,
Empty>
covs;
131 template <
bool HasNormals,
bool HasCovs>
147 return container.
knn_search(pt, k, k_index, k_sq_dist);
150 template <
typename Result>
auto cov(const T &points, size_t i)
Get i-th covariance. Only the top-left 3x3 matrix is filled, and the bottom row and the right col mus...
Definition: traits.hpp:52
auto normal(const T &points, size_t i)
Get i-th normal. 4D vector is used to take advantage of SIMD intrinsics. The last element must be fil...
Definition: traits.hpp:46
Definition: flat_container.hpp:12
Definition: flat_container.hpp:113
FlatContainer setting.
Definition: flat_container.hpp:24
size_t max_num_points_in_cell
Maximum number of points in a cell.
Definition: flat_container.hpp:26
double min_sq_dist_in_cell
Minimum squared distance between points in a cell.
Definition: flat_container.hpp:25
Point container with a flat vector.
Definition: flat_container.hpp:21
std::vector< Eigen::Vector4d > points
Points.
Definition: flat_container.hpp:115
size_t nearest_neighbor_search(const Eigen::Vector4d &pt, size_t *k_index, double *k_sq_dist) const
Find the nearest neighbor.
Definition: flat_container.hpp:68
std::conditional_t< HasNormals, std::vector< Eigen::Vector4d >, Empty > normals
Normals (Empty if HasNormals is false)
Definition: flat_container.hpp:116
size_t size() const
Number of points.
Definition: flat_container.hpp:33
void add(const Setting &setting, const Eigen::Vector4d &transformed_pt, const PointCloud &points, size_t i, const Eigen::Isometry3d &T)
Add a point to the container. If there is a point that is too close to the input point,...
Definition: flat_container.hpp:43
void finalize()
Finalize the container (Nothing to do for FlatContainer).
Definition: flat_container.hpp:61
FlatContainer()
Constructor.
Definition: flat_container.hpp:30
size_t knn_search(const Eigen::Vector4d &pt, int k, size_t *k_indices, double *k_sq_dists) const
Find k nearest neighbors.
Definition: flat_container.hpp:84
void knn_search(const Eigen::Vector4d &pt, Result &result) const
Find k nearest neighbors.
Definition: flat_container.hpp:101
std::conditional_t< HasCovs, std::vector< Eigen::Matrix4d >, Empty > covs
Covariances (Empty if HasCovs is false)
Definition: flat_container.hpp:117
K-nearest neighbor search result container.
Definition: knn_result.hpp:33
size_t num_found() const
Number of found neighbors.
Definition: knn_result.hpp:73
Point cloud.
Definition: point_cloud.hpp:15
size_t size() const
Number of points.
Definition: point_cloud.hpp:37
static bool has_normals(const FlatContainer< HasNormals, HasCovs > &container)
Definition: flat_container.hpp:135
static bool has_covs(const FlatContainer< HasNormals, HasCovs > &container)
Definition: flat_container.hpp:136
static size_t knn_search(const FlatContainer< HasNormals, HasCovs > &container, const Eigen::Vector4d &pt, size_t k, size_t *k_index, double *k_sq_dist)
Definition: flat_container.hpp:146
static size_t size(const FlatContainer< HasNormals, HasCovs > &container)
Definition: flat_container.hpp:133
static void knn_search(const FlatContainer< HasNormals, HasCovs > &container, const Eigen::Vector4d &pt, Result &result)
Definition: flat_container.hpp:151
static const Eigen::Vector4d & point(const FlatContainer< HasNormals, HasCovs > &container, size_t i)
Definition: flat_container.hpp:138
static const Eigen::Vector4d & normal(const FlatContainer< HasNormals, HasCovs > &container, size_t i)
Definition: flat_container.hpp:139
static size_t nearest_neighbor_search(const FlatContainer< HasNormals, HasCovs > &container, const Eigen::Vector4d &pt, size_t *k_index, double *k_sq_dist)
Definition: flat_container.hpp:142
static bool has_points(const FlatContainer< HasNormals, HasCovs > &container)
Definition: flat_container.hpp:134
static const Eigen::Matrix4d & cov(const FlatContainer< HasNormals, HasCovs > &container, size_t i)
Definition: flat_container.hpp:140
Definition: traits.hpp:13