This repository was archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
110 lines (98 loc) · 3.38 KB
/
main.cpp
File metadata and controls
110 lines (98 loc) · 3.38 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <cmath>
#include "generate.hpp"
using namespace std;
int main(int argc, char *argv[])
{
namespace po = boost::program_options;
string cloudfile;
string polygonfile;
string outfile;
unsigned texture_size;
unsigned points_per_texel;
float max_distance;
float dist_power_param;
bool backface;
po::options_description pos("Positional parameters");
pos.add_options()
("cloudfile", po::value<string>(&cloudfile)->required())
("polygonfile", po::value<string>(&polygonfile)->required())
("outfile", po::value<string>(&outfile)->required())
;
po::positional_options_description p;
p.add("cloudfile", 1);
p.add("polygonfile", 1);
p.add("outfile", 1);
po::options_description opts("Options");
opts.add_options()
( "help,h", "show help" )
( "texture-size,s",
po::value<unsigned>(&texture_size)
->default_value(256)->value_name("int"),
"max testure size. The largest polygon by either width or height"
" will have this as their texture width or height. Smaller"
" polygons will have smaller textures." )
( "points-per-texel,k",
po::value<unsigned>(&points_per_texel)
->default_value(1)->value_name("int"),
"number of points per texel" )
( "max-distance,d",
po::value<float>(&max_distance)
->default_value(INFINITY)->value_name("float"),
"limit point search distance" )
( "dist-power-param,p",
po::value<float>(&dist_power_param)
->default_value(3.0)->value_name("float"),
"distance power parameter."
" Greater values give greater influence to points closer to texel"
" center. Should be >= 3.0." )
( "backface,b",
po::bool_switch(&backface),
"for each polygon, add polygon facing the opposite direction")
;
try {
po::variables_map vm;
po::store(po::command_line_parser(argc, argv)
.options(po::options_description().add(opts).add(pos))
.positional(p)
.run(),
vm);
if (argc == 1 || vm.count("help")) {
cout << "Usage: " << argv[0]
<< " [options] cloudfile polygonfile outfile" << endl;
cout << endl;
cout << " cloudfile input point cloud file" << endl;
cout << " polygonfile input polygon file" << endl;
cout << " outfile output file name with or without extension," << endl
<< " paths not allowed" << endl;
cout << endl;
cout << opts << endl;
return vm.count("help") ? 0 : 2;
}
po::notify(vm);
}
catch (po::error &e) {
cerr << e.what() << endl;
return 2;
}
if (! boost::algorithm::ends_with(outfile, ".x3d"))
outfile += ".x3d";
try {
generate(
cloudfile,
polygonfile,
outfile,
texture_size,
points_per_texel,
max_distance * max_distance,
dist_power_param,
backface);
}
catch (runtime_error &e) {
cerr << e.what() << endl;
return 126;
}
return 0;
}