RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
generate_sdf.h
1//
2// Created by RainSure on 2024/2/19.
3//
4
5#ifndef RSMESH_GENERATE_SDF_H
6#define RSMESH_GENERATE_SDF_H
7
8#include <string>
9#include <vector>
10#include <random>
11#include <numeric>
12#include <algorithm>
13#include "types.h"
14#include "table.h"
15#include "geometry/point3d.h"
16#include "common/utility.h"
17#include "point_cloud/sdf_data_generator.h"
18#include "common/eigen_utility.h"
19
20namespace rsmesh::examples {
22 std::string input;
23 std::string output;
24 double max_offset;
25 double min_offset = 0.0;
26 double sdf_multiplication = 2.0;
27 };
28 void generate_sdf(
29 const SdfParameters& parameters
30 ) {
31 const std::string& input = parameters.input;
32 const std::string& output = parameters.output;
33 const double max_offset = parameters.max_offset;
34 const double min_offset = parameters.min_offset;
35 const double sdf_multiplication = parameters.sdf_multiplication;
36 // read data: points(x, y, z) and normals(nx, ny, nz)
37 tabled table = read_table(input);
38
39 // Shuffle the points so that the off-surface points will not be clustered
40 std::vector<index_t> indices(table.rows());
41 std::iota(indices.begin(), indices.end(), index_t{0});
42 std::shuffle(indices.begin(), indices.end(), std::mt19937{std::random_device{}()});
43 table = table(indices, Eigen::all).eval();
44
45 geometry::points3d surface_points = table(Eigen::all, {0, 1, 2});
46 geometry::vectors3d surface_normals = table(Eigen::all, {3, 4, 5});
47
48 // generate SDF (signed distance function) data
49 point_cloud::sdf_data_generator sdf_data(surface_points, surface_normals, min_offset, max_offset, sdf_multiplication);
50 geometry::points3d points = sdf_data.sdf_points();
51 valuesd values = sdf_data.sdf_values();
52
53 // Save the SDF data, x y z val
54 write_table(output, common::concatenate_cols(points, values));
55 }
56}
57
58#endif //RSMESH_GENERATE_SDF_H
examples命名空间,包含一些使用RSMesh库的示例
Eigen::Matrix< double, Eigen::Dynamic, 3, Eigen::RowMajor > vectors3d
3维向量的集合
Definition point3d.h:44
vectors3d points3d
3维点的集合
Definition point3d.h:48