src/tools/lvr2_transform/Options.cpp
Go to the documentation of this file.
1 
28 /*
29  * Options.cpp
30  *
31  * @date 2012-08-23
32  * @author Christian Wansart <cwansart@uos.de>
33  * @author Thomas Wiemann
34  */
35 
36 #include "Options.hpp"
37 //#include <omp.h>
38 
39 #define vc(x) ( m_variables.count(x) )
40 #define srtOR ( !vc("sx") && !vc("sy") && !vc("sz") && \
41  !vc("rx") && !vc("ry") && !vc("rz") && \
42  !vc("tx") && !vc("ty") && !vc("tz") )
43 
44 namespace transform {
45 
46 Options::Options(int argc, char** argv) : m_descr("Supported options")
47 {
48  // Create option descriptions
49 
50  m_descr.add_options()
51  ("help", "Produce help message")
52  ("inputFile,i", value< string >(), "Input file name.")
53  ("outputFile,o", value< string >(), "Output file name. Don't forget to append a file extension.")
54  ("transformFile,t", value< string >(), "*.pose or *.frame file for transformation")
55 
56  ("sx", value< float >(), "Scale in x axis.")
57  ("sy", value< float >(), "Scale in y axis.")
58  ("sz", value< float >(), "Scale in z axis.")
59 // ("scale,s", value< vector< float >>() "Scale in all axis. (Format: x,y,z; e.g. --scale 1.0,4.2,0.4)")
60 
61  ("rx", value< float >(), "Rotation in x axis.")
62  ("ry", value< float >(), "Rotation in y axis.")
63  ("rz", value< float >(), "Rotation in z axis.")
64 // ("rotation", value< vector< float >>() "Rotation in all axis. (Format: x,y,z; e.g. --rotation 4.0,5.0,0.0)")
65 
66  ("tx", value< float >(), "Transform in x axis.")
67  ("ty", value< float >(), "Transform in y axis.")
68  ("tz", value< float >(), "Transform in z axis.")
69 // ("translate", value< vector< float >>(), "Transform in all axis. (Format: x,y,z; e.g.: --translate 6.0,0.0,1.2)")
70  ;
71 
72  // Parse command line and generate variables map
73  store(command_line_parser(argc, argv).options(m_descr).positional(m_pdescr).run(), m_variables);
74  notify(m_variables);
75 
76  if(m_variables.count("help")) {
77  cout<< m_descr << endl;
78  }
79 
80 }
81 
82 string Options::getInputFile() const
83 {
84  return (m_variables["inputFile"].as< string >());
85 }
86 
87 string Options::getOutputFile() const
88 {
89  return (m_variables["outputFile"].as< string >());
90 }
91 
93 {
94  return (m_variables["transformFile"].as< string >());
95 }
96 
98 {
99  return (m_variables.count("transformFile"));
100 }
101 
102 float Options::getScaleX() const
103 {
104  return (m_variables["sx"].as< float >());
105 }
106 
107 float Options::getScaleY() const
108 {
109  return (m_variables["sy"].as< float >());
110 }
111 
112 float Options::getScaleZ() const
113 {
114  return (m_variables["sz"].as< float >());
115 }
116 
118 {
119  return (m_variables["rx"].as< float >());
120 }
121 
123 {
124  return (m_variables["ry"].as< float >());
125 }
126 
128 {
129  return (m_variables["rz"].as< float >());
130 }
131 
133 {
134  return (m_variables["tx"].as< float >());
135 }
136 
138 {
139  return (m_variables["ty"].as< float >());
140 }
141 
143 {
144  return (m_variables["tz"].as< float >());
145 }
146 
147 bool Options::anyScale() const
148 {
149  return (anyScaleX() || anyScaleY() || anyScaleZ());
150 }
151 
152 bool Options::anyScaleX() const
153 {
154  return (m_variables.count("sx"));
155 }
156 
157 bool Options::anyScaleY() const
158 {
159  return (m_variables.count("sy"));
160 }
161 
162 bool Options::anyScaleZ() const
163 {
164  return (m_variables.count("sz"));
165 }
166 
168 {
169  return (anyRotationX() || anyRotationY() || anyRotationZ());
170 }
171 
173 {
174  return (m_variables.count("rx"));
175 }
176 
178 {
179  return (m_variables.count("ry"));
180 }
181 
183 {
184  return (m_variables.count("rz"));
185 }
186 
188 {
189  return (anyTranslationX() || anyTranslationY() || anyTranslationZ());
190 }
191 
193 {
194  return (m_variables.count("tx"));
195 }
196 
198 {
199  return (m_variables.count("ty"));
200 }
201 
203 {
204  return (m_variables.count("tz"));
205 }
206 
208 {
209  if(!m_variables.count("inputFile"))
210  {
211  cout << "Error: You must specify an input file." << endl;
212  cout << endl;
213  cout << m_descr << endl;
214  return true;
215  }
216 
217  if(!m_variables.count("outputFile"))
218  {
219  cout << "Error: You must specify an output file." << endl;
220  cout << endl;
221  cout << m_descr << endl;
222  return true;
223  }
224 
225  // TODO: Need to check for s, t or r
226  // add notice that s, t and r will be ignored if transformFile is given
227  if(!m_variables.count("transformFile") && srtOR)
228  {
229  cout << "Error: You must specify a transform file or sx, sy, sz, rx, ry, rz, tx, ty, tz." << endl;
230  cout << endl;
231  cout << m_descr << endl;
232  return true;
233  }
234 
235  if(m_variables.count("help"))
236  {
237  cout << endl;
238  cout << m_descr << endl;
239  return true;
240  }
241  return false;
242 }
243 
245 }
246 
247 } // namespace transform
248 
transform::Options::anyTranslation
bool anyTranslation() const
Returns true if there is any translation value.
Definition: src/tools/lvr2_transform/Options.cpp:187
transform::Options::m_variables
variables_map m_variables
The internally used variable map.
Definition: src/tools/lvr2_transform/Options.hpp:203
transform::Options::printUsage
bool printUsage() const
Prints a usage message to stdout.
Definition: src/tools/lvr2_transform/Options.cpp:207
transform::Options::anyScaleX
bool anyScaleX() const
Returns true if there is any x-scale value.
Definition: src/tools/lvr2_transform/Options.cpp:152
transform::Options::anyTranslationZ
bool anyTranslationZ() const
Returns true if there is any z translation value.
Definition: src/tools/lvr2_transform/Options.cpp:202
transform
Definition: src/tools/lvr2_transform/Options.cpp:44
transform::Options::getRotationX
float getRotationX() const
Returns the x axis rotation.
Definition: src/tools/lvr2_transform/Options.cpp:117
transform::Options::getScaleY
float getScaleY() const
Returns the y axis scale.
Definition: src/tools/lvr2_transform/Options.cpp:107
transform::Options::getRotationZ
float getRotationZ() const
Returns the z axis rotation.
Definition: src/tools/lvr2_transform/Options.cpp:127
transform::Options::anyRotationZ
bool anyRotationZ() const
Returns true if there is any z-rotation value.
Definition: src/tools/lvr2_transform/Options.cpp:182
transform::Options::getScaleZ
float getScaleZ() const
Returns the z axis scale.
Definition: src/tools/lvr2_transform/Options.cpp:112
transform::Options::getOutputFile
string getOutputFile() const
Returns the output file name.
Definition: src/tools/lvr2_transform/Options.cpp:87
transform::Options::anyTransformFile
bool anyTransformFile() const
Returns true if transform file is given.
Definition: src/tools/lvr2_transform/Options.cpp:97
transform::Options::anyTranslationX
bool anyTranslationX() const
Returns true if there is any x translation value.
Definition: src/tools/lvr2_transform/Options.cpp:192
transform::Options::~Options
virtual ~Options()
Definition: src/tools/lvr2_transform/Options.cpp:244
transform::Options::anyRotationX
bool anyRotationX() const
Returns true if there is any x-rotation value.
Definition: src/tools/lvr2_transform/Options.cpp:172
transform::Options::anyRotationY
bool anyRotationY() const
Returns true if there is any y-rotation value.
Definition: src/tools/lvr2_transform/Options.cpp:177
Options.hpp
transform::Options::anyScale
bool anyScale() const
Returns true if there is any scale value.
Definition: src/tools/lvr2_transform/Options.cpp:147
transform::Options::m_pdescr
positional_options_description m_pdescr
The internally used positional option desription.
Definition: src/tools/lvr2_transform/Options.hpp:209
transform::Options::getTransformFile
string getTransformFile() const
Returns the transform file name.
Definition: src/tools/lvr2_transform/Options.cpp:92
transform::Options::anyScaleZ
bool anyScaleZ() const
Returns true if there is any z-scale value.
Definition: src/tools/lvr2_transform/Options.cpp:162
options
const kaboom::Options * options
Definition: src/tools/lvr2_kaboom/Main.cpp:45
transform::Options::getTranslationX
float getTranslationX() const
Returns the x axis translation.
Definition: src/tools/lvr2_transform/Options.cpp:132
transform::Options::anyRotation
bool anyRotation() const
Returns true if there is any rotation value.
Definition: src/tools/lvr2_transform/Options.cpp:167
transform::Options::getTranslationZ
float getTranslationZ() const
Returns the z axis translation.
Definition: src/tools/lvr2_transform/Options.cpp:142
argc
int argc
Definition: tests_high_five_parallel.cpp:27
transform::Options::Options
Options(int argc, char **argv)
Ctor. Parses the command parameters given to the main function of the program.
Definition: src/tools/lvr2_transform/Options.cpp:46
transform::Options::anyTranslationY
bool anyTranslationY() const
Returns true if there is any y translation value.
Definition: src/tools/lvr2_transform/Options.cpp:197
srtOR
#define srtOR
Definition: src/tools/lvr2_transform/Options.cpp:40
transform::Options::getInputFile
string getInputFile() const
Returns the output file name.
Definition: src/tools/lvr2_transform/Options.cpp:82
transform::Options::anyScaleY
bool anyScaleY() const
Returns true if there is any y-scale value.
Definition: src/tools/lvr2_transform/Options.cpp:157
transform::Options::getRotationY
float getRotationY() const
Returns the y axis rotation.
Definition: src/tools/lvr2_transform/Options.cpp:122
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28
transform::Options::getScaleX
float getScaleX() const
Returns the x axis scale.
Definition: src/tools/lvr2_transform/Options.cpp:102
transform::Options::m_descr
options_description m_descr
The internally used option description.
Definition: src/tools/lvr2_transform/Options.hpp:206
transform::Options::getTranslationY
float getTranslationY() const
Returns the y axis translation.
Definition: src/tools/lvr2_transform/Options.cpp:137


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24