RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
mat_a.h
1//
2// Created by RainSure on 2024/2/19.
3//
4
5#ifndef RSMESH_MAT_A_H
6#define RSMESH_MAT_A_H
7
8#include "Eigen/Core"
9#include "model.h"
10#include "types.h"
11
12namespace rsmesh::preconditioner {
13 template <class DerivedPoints, class DerivedGradPoints>
14 Eigen::MatrixXd mat_a(const model& model, const Eigen::MatrixBase<DerivedPoints>& points,
15 const Eigen::MatrixBase<DerivedGradPoints>& grad_points) {
16 const auto& rbf = model.rbf();
17 auto dim = model.poly_dimension();
18 auto mu = points.rows();
19 auto sigma = grad_points.rows();
20 auto m = mu + dim * sigma;
21
22 Eigen::MatrixXd a(m, m);
23
24 auto aa = a.topLeftCorner(mu, mu);
25 aa.diagonal().array() = rbf.evaluate(geometry::vector3d::Zero()) + model.nugget();
26 for (index_t i = 0; i < mu - 1; i++) {
27 for (index_t j = i + 1; j < mu; j++) {
28 aa(i, j) = rbf.evaluate(points.row(i) - points.row(j));
29 aa(j, i) = aa(i, j);
30 }
31 }
32
33 if (sigma > 0) {
34 auto af = a.topRightCorner(mu, dim * sigma);
35 for (index_t i = 0; i < mu; i++) {
36 for (index_t j = 0; j < sigma; j++) {
37 af.block(i, dim * j, 1, dim) =
38 -rbf.evaluate_gradient(points.row(i) - grad_points.row(j)).head(dim);
39 }
40 }
41 a.bottomLeftCorner(dim * sigma, mu) = af.transpose();
42
43 auto ah = a.bottomRightCorner(dim * sigma, dim * sigma);
44 Eigen::MatrixXd ah_diagonal =
45 rbf.evaluate_hessian(geometry::vector3d::Zero()).topLeftCorner(dim, dim);
46 for (index_t i = 0; i < sigma; i++) {
47 ah.block(dim * i, dim * i, dim, dim) = ah_diagonal;
48 }
49 for (index_t i = 0; i < sigma - 1; i++) {
50 for (index_t j = i + 1; j < sigma; j++) {
51 ah.block(dim * i, dim * j, dim, dim) =
52 rbf.evaluate_hessian(grad_points.row(i) - grad_points.row(j)).topLeftCorner(dim, dim);
53 ah.block(dim * j, dim * i, dim, dim) = ah.block(dim * i, dim * j, dim, dim).transpose();
54 }
55 }
56 }
57
58 return a;
59 }
60}
61
62#endif //RSMESH_MAT_A_H
该命名空间下主要定义了关于krylov子空间方法的预处理相关的类和函数