RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
fmm_rbf_kernel.h
1//
2// Created by RainSure on 2024/2/4.
3//
4
5#ifndef RSMESH_FMM_RBF_KERNEL_H
6#define RSMESH_FMM_RBF_KERNEL_H
7
8#include"ScalFMM/Kernels/Interpolation/FInterpMatrixKernel.hpp"
9#include<cmath>
10#include<memory>
11#include"geometry/point3d.h"
12#include"rbf/rbf_base.h"
13
14namespace rsmesh::fmm {
15 struct fmm_rbf_kernel : FInterpAbstractMatrixKernel<double> {
16 static constexpr bool kEvaluateGradient = false;
17
18 static const KERNEL_FUNCTION_TYPE Type = NON_HOMOGENEOUS;
19 static const unsigned int NCMP = 1; // Number of components
20 static const unsigned int NPV = 1; // Number of physical values
21 static const unsigned int NPOT = 1; // Dimension of potentials.
22 static const unsigned int NRHS = 1; // Dimension of multipole expansions.
23 static const unsigned int NLHS = 1; // Dimension of local expansions.
24
25 explicit fmm_rbf_kernel(const rbf::rbf_base& rbf) : rbf_(rbf.clone()) {}
26
27 // returns position in reduced storage
28 int getPosition(const unsigned int) const { return 0; }
29
30 double getMutualCoefficient() const {
31 // The kernel is symmetric.
32 return 1.0;
33 }
34
35 // evaluate interaction
36 double evaluate(double xt, double yt, double zt, double xs, double ys, double zs) const {
37 geometry::vector3d diff{xt - xs, yt - ys, zt - zs};
38
39 return rbf_->evaluate_isotropic(diff);
40 }
41
42 // evaluate interaction and derivative (blockwise)
43 void evaluateBlockAndDerivative(double xt, double yt, double zt, double xs, double ys, double zs,
44 double block[1], double blockDerivative[3]) const {
45 geometry::vector3d diff{xt - xs, yt - ys, zt - zs};
46
47 block[0] = rbf_->evaluate_isotropic(diff);
48
49 if (kEvaluateGradient) {
50 auto grad = rbf_->evaluate_gradient_isotropic(diff);
51 blockDerivative[0] = grad(0);
52 blockDerivative[1] = grad(1);
53 blockDerivative[2] = grad(2);
54 } else {
55 blockDerivative[0] = 0.0;
56 blockDerivative[1] = 0.0;
57 blockDerivative[2] = 0.0;
58 }
59 }
60
61 double getScaleFactor(const double, const int) const override {
62 // The kernel is not homogeneous.
63 return 1.0;
64 }
65
66 double getScaleFactor(const double) const override {
67 // The kernel is not homogeneous.
68 return 1.0;
69 }
70
71 double evaluate(const FPoint<double>& pt, const FPoint<double>& ps) const {
72 return evaluate(pt.getX(), pt.getY(), pt.getZ(), ps.getX(), ps.getY(), ps.getZ());
73 }
74
75 private:
76 const std::unique_ptr<rbf::rbf_base> rbf_;
77 };
78}
79
80#endif //RSMESH_FMM_RBF_KERNEL_H
Eigen::RowVector3d vector3d
3维向量
Definition point3d.h:30