RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
distance_filter.h
1//
2// Created by RainSure on 2023/11/1.
3//
4
5#ifndef RSMESH_DISTANCE_FILTER_H
6#define RSMESH_DISTANCE_FILTER_H
7
8#include <stdexcept>
9#include <tuple>
10#include <utility>
11#include <vector>
12#include <numeric>
13
14#include "Eigen/Core"
15#include "common/eigen_utility.h"
16#include "geometry/point3d.h"
17#include "types.h"
18
19namespace rsmesh {
24 namespace point_cloud {
25
27 public:
28 distance_filter(const geometry::points3d& points, double distance);
29
30 distance_filter(const geometry::points3d& points, double distance, const std::vector<index_t>& indices);
31
32 template<class Derived>
33 auto filtered(const Eigen::MatrixBase<Derived>& m) const {
34 if(m.rows() != n_points_) {
35 throw std::invalid_argument("The number of rows of the input matrix must be equal to the number of points in the point cloud.");
36 }
37 return common::take_rows(m, filtered_indices_);
38 }
39
40 template <class Derived, class ...Args>
41 auto filtered(const Eigen::MatrixBase<Derived>& m, Args&&... args) {
42 return std::make_tuple(filtered(m), filtered(std::forward<Args>(args))...);
43 }
44
45 template <class Derived>
46 auto operator() (const Eigen::MatrixBase<Derived>& m) {
47 if(m.rows() != n_points_) {
48 throw std::invalid_argument("The number of rows of the input matrix must be equal to the number of points in the point cloud.");
49 }
50 return m(filtered_indices_, Eigen::all).eval();
51 }
52
53 template <class Derived, class... Args>
54 auto operator() (const Eigen::MatrixBase<Derived>& m, Args&&... args) {
55 return std::make_tuple(operator()(m), operator()(std::forward<Args>(args))...);
56 }
57
58 [[nodiscard]] const std::vector<index_t>& filtered_indices() const {return filtered_indices_;}
59 private:
60
61 static std::vector<index_t> trivial_indices(index_t n_points) {
62 std::vector<index_t> indices(n_points);
63 std::iota(begin(indices), end(indices), 0);
64 return indices;
65 }
66
67 const index_t n_points_;
68
69 std::vector<index_t> filtered_indices_;
70 };
71
72 } // rsmesh
73} // point_cloud
74
75#endif //RSMESH_DISTANCE_FILTER_H
vectors3d points3d
3维点的集合
Definition point3d.h:48
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间