-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.cpp
125 lines (104 loc) · 3.34 KB
/
cli.cpp
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "cli.h"
#include <iostream>
#include <string>
#include <tclap/CmdLine.h>
const std::string message("GeoMeshCo. \
Copyright (C) 2012 Helmholtz Centre for Environmental Research (UFZ). \
This program comes with ABSOLUTELY NO WARRANTY; This is free software, \
and you are welcome to redistribute it under certain conditions; \
For details see the LICENSE file.");
const char delimiter(' ');
const std::string version("0.1");
TCLAP::ValueArg<std::string>*
construct_input_arg(const std::string& d, const bool r = true)
{
return new TCLAP::ValueArg<std::string>(
"i", "input", d, r, std::string(), "FILE");
}
TCLAP::ValueArg<std::string>*
construct_output_arg(const std::string& d, const bool r = true)
{
return new TCLAP::ValueArg<std::string>(
"o", "output", d, r, std::string(), "FILE");
}
//// CGAL mesh constraint arguments. ////////////////////////////////
struct CGAL_mesh_constraint_args {
TCLAP::ValueArg<double> angular_bound;
TCLAP::ValueArg<double> facet_size;
TCLAP::ValueArg<double> distance_bound;
CGAL_mesh_constraint_args(TCLAP::CmdLineInterface& cmd)
: angular_bound(
"a",
"angular_bound",
"angular bound in the Surface mesh criteria. (30)",
false,
30,
"FLOAT")
, facet_size(
"f",
"facet_size",
"Facet criteria facet's size. (0.3)",
false,
0.3,
"FLOAT")
, distance_bound(
"r",
"approximation",
"Facet criteria approximation. (0.1)",
false,
0.1,
"FLOAT")
{
cmd.add(facet_size);
cmd.add(angular_bound);
cmd.add(distance_bound);
}
};
CLI::CLI(int argc, char** argv)
: z_scale(1),
bottom(-1/z_scale),
angular_bound(30),
approximation(0.1),
facet_size(0.3),
input(""),
output("")
{
try {
TCLAP::CmdLine cmd(message, delimiter, version);
TCLAP::ValueArg<double> bottom_arg(
"b",
"bottom",
"z-value of surfaces buttom. (-1/z_scale)",
false,
-1.,
"FLOAT");
cmd.add(bottom_arg);
TCLAP::ValueArg<double> z_scale_arg(
"z",
"z_scale",
"Vertical scale factor. (1.0)",
false,
1.,
"FLOAT");
cmd.add(z_scale_arg);
CGAL_mesh_constraint_args constraint_args(cmd);
TCLAP::ValueArg<std::string>* output_arg = construct_output_arg(
"Write meshes to this file. No output if the filename is not given.",
false);
cmd.add(output_arg);
TCLAP::ValueArg<std::string>* input_arg = construct_input_arg(
"Input 2D grayscale image.");
cmd.add(input_arg);
cmd.parse(argc, argv);
input = input_arg->getValue();
output = output_arg->getValue();
angular_bound = constraint_args.angular_bound.getValue();
approximation = constraint_args.distance_bound.getValue();
facet_size = constraint_args.facet_size.getValue();
z_scale = z_scale_arg.getValue();
bottom = bottom_arg.getValue();
bottom /= z_scale;
} catch (TCLAP::ArgException &e) {
std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
}
}