src/tools/lvr2_chunking/Main.cpp
Go to the documentation of this file.
1 
35 #include "Options.hpp"
38 #include "lvr2/io/ModelFactory.hpp"
39 
40 #include <boost/filesystem.hpp>
41 #include <iostream>
42 #include <string>
43 
44 int main(int argc, char** argv)
45 {
46  // =======================================================================
47  // Parse and print command line parameters
48  // =======================================================================
49  // Parse command line arguments
50  chunking::Options options(argc, argv);
51 
52  // Exit if options had to generate a usage message
53  // (this means required parameters are missing)
54  if (options.printUsage())
55  {
56  return EXIT_SUCCESS;
57  }
58  if (options.getLoad())
59  {
60  if (boost::filesystem::exists(options.getChunkedMesh()))
61  {
62  // loading a hdf5 file and extracting the chunks for a given bounding box
63  lvr2::ChunkManager chunkLoader(options.getChunkedMesh(), options.getCacheSize());
64 
65  // TODO: remove tmp test later
66  // beginn: tmp test of extractArea method for dat/scan.pts with chunkSize 200
67  if (!boost::filesystem::exists("area"))
68  {
69  boost::filesystem::create_directories("area");
70  }
72  lvr2::BaseVector<float>(options.getXMin(), options.getYMin(), options.getZMin()),
73  lvr2::BaseVector<float>(options.getXMax(), options.getYMax(), options.getZMax()));
74  // end: tmp test of extractArea method
75 
76 // lvr2::ModelFactory::saveModel(
77 // lvr2::ModelPtr(new lvr2::Model(chunkLoader.extractArea(area))), "area.ply");
78  }
79  }
80  else
81  {
82  // saving a mesh as multiple chunked meshes in an hdf5 file
83  boost::filesystem::path outputPath = boost::filesystem::absolute(options.getOutputDir());
84  if (!boost::filesystem::is_directory(outputPath))
85  {
86  boost::filesystem::create_directories(outputPath);
87  }
88 
89  float size = options.getChunkSize();
90  float maxChunkOverlap = options.getMaxChunkOverlap();
91 
92 
93  // Check extension
94  std::vector<std::string> files = options.getInputFile();
95  boost::filesystem::path selectedFile(files[0]);
96  std::string extension = selectedFile.extension().string();
97  lvr2::MeshBufferPtr meshBuffer;
98  if (extension == ".h5")
99  {
100  using HDF5MeshToolIO = lvr2::Hdf5IO<lvr2::hdf5features::ArrayIO,
104  HDF5MeshToolIO hdf5;
105  hdf5.open(files[0]);
106  meshBuffer = hdf5.loadMesh(options.getMeshGroup());
107  }
108  else // use model reader
109  {
110  std::vector<lvr2::MeshBufferPtr> meshes;
111  std::vector<std::string> layers;
112  for(size_t i = 0; i < files.size(); ++i)
113  {
115  layers.push_back(std::string("mesh") + std::to_string(i));
116  meshBuffer = model->m_mesh;
117  if (meshBuffer)
118  {
119  meshes.push_back(meshBuffer);
120  }
121 
122  }
123  lvr2::ChunkManager chunker(meshes, size, maxChunkOverlap, outputPath.string(), layers);
124  }
125  }
126  return EXIT_SUCCESS;
127 }
float getChunkSize() const
Returns the side length of a chunk.
std::vector< std::string > getInputFile() const
Returns the input file.
bool printUsage() const
Prints a usage message to stdout.
float getXMax() const
Returns the x-max of the bounding box.
A class to parse the program options for the chunking executable.
const kaboom::Options * options
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
string getChunkedMesh() const
Returns the chunked mesh file.
float getMaxChunkOverlap() const
Returns the maximum allowed chunk overlap.
int getCacheSize() const
Returns the cacheSize (maximum number of chunks in HashMap while loading)
float getZMin() const
Returns the z-min of the bounding box.
static ModelPtr readModel(std::string filename)
float getYMax() const
Returns the y-max of the bounding box.
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
float getXMin() const
Returns the x-min of the bounding box.
Manager Class for all Hdf5IO components located in hdf5 directory.
Hdf5IO Feature for handling MeshBuffer related IO.
Definition: MeshIO.hpp:52
bool getLoad() const
Returns the load-flag. set to true for loading an existing hdf5-file and to false for chunking and sa...
int main(int argc, char **argv)
Hdf5IO Feature for handling VariantChannel related IO.
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
float getYMin() const
Returns the y-min of the bounding box.
MeshBufferPtr loadMesh(std::string name)
string getOutputDir() const
Returns the output directory.
float getZMax() const
Returns the z-max of the bounding box.
std::string getMeshGroup() const
Returns the mesh group in the HDF5.
char ** argv


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