RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
model.h
1//
2// Created by RainSure on 2024/1/31.
3//
4
5#ifndef RSMESH_MODEL_H
6#define RSMESH_MODEL_H
7
8#include<limits>
9#include<memory>
10#include"polynomial/polynomial_basic_base.h"
11#include"rbf/rbf_base.h"
12#include"types.h"
13#include<stdexcept>
14#include<vector>
15
16namespace rsmesh {
21 class model{
22 public:
23 model(const rbf::rbf_base& rbf, int poly_dimension, int poly_degree) : rbf_(rbf.clone()),
24 poly_dimension_(poly_dimension), poly_degree_(poly_degree) {
25 if(poly_dimension < 0 or poly_dimension > 3) {
26 throw std::invalid_argument("poly_dimension must be within the range of 0 to 3.");
27 }
28 if(poly_degree < rbf.cpd_order() - 1 or poly_degree > 2) {
29 throw std::invalid_argument("poly_degree must be within the range of rbf.cpd_order() - 1 to 2.");
30 }
31 }
32
33 ~model() = default;
34
35 model(const model& model) : rbf_(model.rbf_->clone()), poly_dimension_(model.poly_dimension_),
36 poly_degree_(model.poly_degree_), nugget_(model.nugget_) {}
37
38 model(model&& model) = default;
39
40 model& operator=(const model&) = delete;
41 model& operator=(model&&) = delete;
42
43 [[nodiscard]] double nugget() const {return nugget_;}
44
45 [[nodiscard]] int num_parameters() const {return 1 + rbf_->num_parameters();}
46
47 [[nodiscard]] std::vector<double> parameter_lower_bounds() const {
48 std::vector<double> lower_bounds{0.0};
49 lower_bounds.insert(std::end(lower_bounds), std::begin(rbf_->parameter_lower_bounds()), std::end(rbf_->parameter_lower_bounds()));
50 return lower_bounds;
51 }
52
53 [[nodiscard]] std::vector<double> parameter_upper_bounds() const {
54 std::vector<double> upper_bounds{std::numeric_limits<double>::infinity()};
55 upper_bounds.insert(std::end(upper_bounds), std::begin(rbf_->parameter_upper_bounds()), std::end(rbf_->parameter_upper_bounds()));
56 return upper_bounds;
57 }
58
59 [[nodiscard]] std::vector<double> parameters() const {
60 std::vector<double> params{nugget()};
61 params.insert(std::end(params), std::begin(rbf_->parameters()), std::end(rbf_->parameters()));
62 return params;
63 }
64
65 [[nodiscard]] index_t poly_basis_size() const {
66 return polynomial::polynomial_basis_base::basis_size(poly_dimension_, poly_degree_);
67 }
68
69 [[nodiscard]] int poly_degree() const {
70 return poly_degree_;
71 }
72
73 [[nodiscard]] int poly_dimension() const {
74 return poly_dimension_;
75 }
76
77 [[nodiscard]] const rbf::rbf_base& rbf() const {return *rbf_;}
78
79 void set_nugget(double nugget) {
80 if(nugget < 0.0) {
81 throw std::invalid_argument("nugget mest be greater than or equal to 0.0.");
82 }
83
84 nugget_ = nugget;
85 }
86
87 void set_parameters(const std::vector<double>& params) {
88 if(static_cast<int>(params.size()) != num_parameters()) {
89 throw std::invalid_argument("params.size() must be " + std::to_string(num_parameters()) + ".");
90 }
91 set_nugget(params[0]);
92 rbf_->set_parameters(std::vector<double>(std::begin(params) + 1, std::end(params)));
93 }
94
95 [[nodiscard]] model without_poly() const {
96 return model(*rbf_);
97 }
98
99 private:
100 explicit model(const rbf::rbf_base& rbf) : rbf_(rbf.clone()), poly_dimension_(-1), poly_degree_(-1) {}
101
102 std::unique_ptr<rbf::rbf_base> rbf_;
103 int poly_dimension_;
104 int poly_degree_;
105 double nugget_{}; // 针对高斯过程的参数
106 };
107}
108
109#endif //RSMESH_MODEL_H
描述了一个插值模型
Definition model.h:21
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间