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 
bool anyScaleY() const
Returns true if there is any y-scale value.
string getInputFile() const
Returns the output file name.
const kaboom::Options * options
bool anyTransformFile() const
Returns true if transform file is given.
bool anyTranslationX() const
Returns true if there is any x translation value.
variables_map m_variables
The internally used variable map.
positional_options_description m_pdescr
The internally used positional option desription.
float getTranslationY() const
Returns the y axis translation.
bool anyTranslation() const
Returns true if there is any translation value.
bool anyScaleX() const
Returns true if there is any x-scale value.
string getTransformFile() const
Returns the transform file name.
float getTranslationZ() const
Returns the z axis translation.
bool anyRotationX() const
Returns true if there is any x-rotation value.
float getRotationZ() const
Returns the z axis rotation.
string getOutputFile() const
Returns the output file name.
float getScaleY() const
Returns the y axis scale.
bool anyScale() const
Returns true if there is any scale value.
options_description m_descr
The internally used option description.
bool anyTranslationZ() const
Returns true if there is any z translation value.
bool anyScaleZ() const
Returns true if there is any z-scale value.
bool anyRotationY() const
Returns true if there is any y-rotation value.
Options(int argc, char **argv)
Ctor. Parses the command parameters given to the main function of the program.
float getTranslationX() const
Returns the x axis translation.
bool anyTranslationY() const
Returns true if there is any y translation value.
bool anyRotationZ() const
Returns true if there is any z-rotation value.
float getScaleX() const
Returns the x axis scale.
bool anyRotation() const
Returns true if there is any rotation value.
float getRotationX() const
Returns the x axis rotation.
float getRotationY() const
Returns the y axis rotation.
bool printUsage() const
Prints a usage message to stdout.
char ** argv
float getScaleZ() const
Returns the z axis scale.


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 Mon Feb 28 2022 22:46:08