-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (45 loc) · 1.25 KB
/
main.cpp
File metadata and controls
53 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <algorithm>
#include <stdexcept>
#include <pcl/io/obj_io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/PolygonMesh.h>
#include "camera_position.h"
#include "off_helpers.h"
#include "utils.h"
#include "view_extractor.h"
#include "view_provider_example.h"
pcl::PolygonMesh load(const std::string &path) {
auto ext = get_extension(path);
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
pcl::PolygonMesh mesh;
if (ext == "obj") {
pcl::io::loadOBJFile(path, mesh);
} else if (ext == "off") {
loadOFFFile(path, mesh);
} else if (ext == "pcd") {
pcl::io::loadOBJFile(path, mesh);
} else if (ext == "ply") {
pcl::io::loadPLYFile(path, mesh);
} else {
throw std::invalid_argument("Invalid file");
}
return mesh;
}
int main(int argc, char const *argv[]) {
if (argc >= 2) {
auto mesh = load(argv[1]);
std::string prefix;
if (argc == 2) {
std::string _;
split_path(argv[1], prefix, _);
} else {
prefix = argv[2];
}
extract_view(mesh, new ViewProviderExample(), prefix);
return 0;
} else {
cerr << "Invalid argument" << endl;
return 1;
}
}