5#include "point_cloud/offset_points_generator.h"
6#include "point_cloud/kdtree.h"
10 namespace point_cloud {
13 offset_points_generator(points, normals, valuesd::Constant(points.rows(), offset)){}
15 offset_points_generator::offset_points_generator(
const geometry::points3d &points,
16 const geometry::vectors3d &normals,
const valuesd &offsets) {
17 if(normals.rows() != points.rows()) {
18 throw std::invalid_argument(
"normals.rows() must be equal to points.rows().");
20 if(offsets.size() != points.size()) {
21 throw std::invalid_argument(
"offsets.rows() must be equal to points.rows().");
24 kdtree tree(points,
true);
26 index_t n_points = points.rows();
27 index_t n_new_points = 0;
29 new_points_ = geometry::points3d(n_points, 3);
30 new_normals_ = geometry::vectors3d(n_points, 3);
32 for (index_t i = 0; i < n_points; i++) {
33 auto p = points.row(i);
34 auto n = normals.row(i);
36 if (n == geometry::vector3d::Zero()) {
41 geometry::point3d q = p + d * n;
43 auto [nn_indices, nn_distaces] = tree.knn_search(q, 1);
44 auto i_nearest = nn_indices.at(0);
50 new_points_.row(n_new_points) = q;
51 new_normals_.row(n_new_points) = n;
55 new_points_.conservativeResize(n_new_points, 3);
56 new_normals_.conservativeResize(n_new_points, 3);
59 const geometry::points3d &offset_points_generator::new_points()
const {
63 const geometry::vectors3d &offset_points_generator::new_normals()
const {
Eigen::Matrix< double, Eigen::Dynamic, 3, Eigen::RowMajor > vectors3d
3维向量的集合
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间