RSMesh 1.0.0
一个曲面重构的系统,输入为点云,输出为obj,stl等主流格式的网格文件,使用的方法为径向基函数插值,采取了并行优化、Intel-MKL等优化措施,支持百万级别的点云
载入中...
搜索中...
未找到
io.h
1//
2// Created by RainSure on 2023/11/10.
3//
4
5#ifndef RSMESH_IO_H
6#define RSMESH_IO_H
7
8#include <iostream>
9#include <fstream>
10#include <stdexcept>
11
12namespace rsmesh {
13 namespace common {
14 template <class T>
15 struct read {
16 void operator()(std::istream& is, T& t) {
17 is.read(reinterpret_cast<char*>(&t), sizeof(t));
18 }
19 };
20
21 template <class T>
22 struct write {
23 void operator()(std::ostream& os, T& t) {
24 os.write(reinterpret_cast<char*>(&t), sizeof(t));
25 }
26 };
27
28 template <class T>
29 void load(const std::string& filename, T& t) {
30 std::ifstream ifs(filename, std::ios::binary);
31 if(!ifs) {
32 throw std::runtime_error("Cannot open file: " + filename);
33 }
34
35 read<T>{}(ifs, t);
36 }
37
38 template <class T>
39 void save(const std::string& filename, T& t) {
40 std::ofstream ofs(filename, std::ios::binary);
41 if(!ofs) {
42 throw std::runtime_error("Cannot open file: " + filename);
43 }
44
45 write<T>{}(ofs, t);
46 }
47 }
48}
49
50#endif //RSMESH_IO_H
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间