src/tools/lvr2_chunking/Options.cpp
Go to the documentation of this file.
1 
35 #include "Options.hpp"
36 
37 #include <iostream>
38 
39 namespace chunking
40 {
41 
42 using boost::program_options::command_line_parser;
43 using boost::program_options::value;
44 using std::cout;
45 using std::endl;
46 
47 Options::Options(int argc, char** argv) : m_descr("Supported options")
48 {
49  // Create option descriptions
50  m_descr.add_options()("help",
51  "Produce help message")("inputFile", value<std::vector<string>>()->multitoken(), "Input file names.")(
52  "outputDir", value<string>(), "Output directory name.")(
53  "chunkSize", value<float>()->default_value(10.0f), "Side length of chunks.")(
54  "maxChunkOverlap", value<float>()->default_value(0.1f),
55  "maximum allowed overlap between chunks relative to the chunk size.")(
56  "chunkedMesh", value<string>(), "Chunked mesh hdf5-file name.")(
57  "load", value<bool>()->default_value(false), "Set this value to true, if you want to load an hdf5-file")(
58  "x_min", value<float>()->default_value(0.0f), "bounding box minimum value in x-dimension")(
59  "y_min", value<float>()->default_value(0.0f), "bounding box minimum value in y-dimension")(
60  "z_min", value<float>()->default_value(0.0f), "bounding box minimum value in z-dimension")(
61  "x_max", value<float>()->default_value(10.0f), "bounding box maximum value in x-dimension")(
62  "y_max", value<float>()->default_value(10.0f), "bounding box maximum value in y-dimension")(
63  "z_max", value<float>()->default_value(10.0f), "bounding box maximum value in z-dimension")(
64  "cacheSize", value<int>()->default_value(200), "while loading the maximum number of chunks in RAM")(
65  "meshName", value<std::string>()->default_value(""), "group name of the mesh if the HDF5 contains multiple meshes");
66 
67  // Parse command line and generate variables map
68  store(command_line_parser(argc, argv).options(m_descr).positional(m_posDescr).run(),
69  m_variables);
70  notify(m_variables);
71 }
72 
73 bool Options::printUsage() const
74 {
75  if (m_variables.count("help"))
76  {
77  cout << m_descr << endl;
78  return true;
79  }
80 
81  if (!m_variables.count("inputFile") && !getLoad())
82  {
83  cout << "Error: You must specify an input file." << endl;
84  cout << endl;
85  cout << m_descr << endl;
86  return true;
87  }
88 
89  if(getLoad() && !m_variables.count("chunkedMesh"))
90  {
91  cout << "Error: You must specify an hdf5-file (\"chunkedMesh\") when loading." << endl;
92  cout << endl;
93  cout << m_descr << endl;
94  return true;
95  }
96 
97  return false;
98 }
99 
100 std::vector<string> Options::getInputFile() const
101 {
102 
103  return m_variables["inputFile"].as<std::vector<string>>();
104 }
105 
106 string Options::getOutputDir() const
107 {
108  return m_variables["outputDir"].as<string>();
109 }
110 
112 {
113  return m_variables["chunkSize"].as<float>();
114 }
115 
117 {
118  return m_variables["maxChunkOverlap"].as<float>();
119 }
121 {
122  return m_variables["chunkedMesh"].as<string>();
123 }
124 bool Options::getLoad() const
125 {
126  return m_variables["load"].as<bool>();
127 }
128 
129 float Options::getXMin() const
130 {
131  return m_variables["x_min"].as<float>();
132 }
133 float Options::getYMin() const
134 {
135  return m_variables["y_min"].as<float>();
136 }
137 float Options::getZMin() const
138 {
139  return m_variables["z_min"].as<float>();
140 }
141 float Options::getXMax() const
142 {
143  return m_variables["x_max"].as<float>();
144 }
145 float Options::getYMax() const
146 {
147  return m_variables["y_max"].as<float>();
148 }
149 float Options::getZMax() const
150 {
151  return m_variables["z_max"].as<float>();
152 }
154 {
155  int size = m_variables["cacheSize"].as<int>();
156  if(size > 0)
157  {
158  return size;
159  }
160  return 200;
161 }
162 std::string Options::getMeshGroup() const
163 {
164  return m_variables["meshName"].as<std::string>();
165 }
166 
168 {
169  // TODO Auto-generated destructor stub
170 }
171 
172 } // namespace chunking
chunking::Options::getChunkedMesh
string getChunkedMesh() const
Returns the chunked mesh file.
Definition: src/tools/lvr2_chunking/Options.cpp:120
chunking::Options::getChunkSize
float getChunkSize() const
Returns the side length of a chunk.
Definition: src/tools/lvr2_chunking/Options.cpp:111
chunking::Options::getXMax
float getXMax() const
Returns the x-max of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:141
chunking::Options::getZMin
float getZMin() const
Returns the z-min of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:137
chunking::Options::m_posDescr
positional_options_description m_posDescr
The internally used positional option description.
Definition: src/tools/lvr2_chunking/Options.hpp:140
chunking::Options::getMeshGroup
std::string getMeshGroup() const
Returns the mesh group in the HDF5.
Definition: src/tools/lvr2_chunking/Options.cpp:162
chunking::Options::m_variables
variables_map m_variables
The internally used variable map.
Definition: src/tools/lvr2_chunking/Options.hpp:134
chunking::Options::getXMin
float getXMin() const
Returns the x-min of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:129
chunking::Options::getCacheSize
int getCacheSize() const
Returns the cacheSize (maximum number of chunks in HashMap while loading)
Definition: src/tools/lvr2_chunking/Options.cpp:153
chunking::Options::getOutputDir
string getOutputDir() const
Returns the output directory.
Definition: src/tools/lvr2_chunking/Options.cpp:106
options
const kaboom::Options * options
Definition: src/tools/lvr2_kaboom/Main.cpp:45
chunking::Options::getLoad
bool getLoad() const
Returns the load-flag. set to true for loading an existing hdf5-file and to false for chunking and sa...
Definition: src/tools/lvr2_chunking/Options.cpp:124
chunking::Options::getYMax
float getYMax() const
Returns the y-max of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:145
chunking::Options::getZMax
float getZMax() const
Returns the z-max of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:149
chunking::Options::m_descr
options_description m_descr
The internally used option description.
Definition: src/tools/lvr2_chunking/Options.hpp:137
Options.hpp
argc
int argc
Definition: tests_high_five_parallel.cpp:27
chunking::Options::getYMin
float getYMin() const
Returns the y-min of the bounding box.
Definition: src/tools/lvr2_chunking/Options.cpp:133
chunking::Options::getMaxChunkOverlap
float getMaxChunkOverlap() const
Returns the maximum allowed chunk overlap.
Definition: src/tools/lvr2_chunking/Options.cpp:116
chunking::Options::getInputFile
std::vector< std::string > getInputFile() const
Returns the input file.
Definition: src/tools/lvr2_chunking/Options.cpp:100
chunking::Options::~Options
virtual ~Options()
Definition: src/tools/lvr2_chunking/Options.cpp:167
chunking
Definition: src/tools/lvr2_chunking/Options.cpp:39
chunking::Options::Options
Options(int argc, char **argv)
Ctor. Parses the command parameters given to the main function of the program.
Definition: src/tools/lvr2_chunking/Options.cpp:47
chunking::Options::printUsage
bool printUsage() const
Prints a usage message to stdout.
Definition: src/tools/lvr2_chunking/Options.cpp:73
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28


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