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
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 }
chunking::Options
A class to parse the program options for the chunking executable.
Definition: src/tools/lvr2_chunking/Options.hpp:54
lvr2::Hdf5IO
Manager Class for all Hdf5IO components located in hdf5 directory.
Definition: HDF5FeatureBase.hpp:38
lvr2::BaseVector< float >
lvr2::hdf5features::MeshIO::loadMesh
MeshBufferPtr loadMesh(std::string name)
kaboom::Options::getInputFile
string getInputFile() const
Definition: src/tools/lvr2_kaboom/Options.cpp:93
main
int main(int argc, char **argv)
Definition: src/tools/lvr2_chunking/Main.cpp:44
options
const kaboom::Options * options
Definition: src/tools/lvr2_kaboom/Main.cpp:45
lvr2::hdf5features::VariantChannelIO
Hdf5IO Feature for handling VariantChannel related IO.
Definition: hdf5/VariantChannelIO.hpp:59
Options.hpp
HDF5FeatureBase.hpp
lvr2::BoundingBox
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
argc
int argc
Definition: tests_high_five_parallel.cpp:27
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::MeshBufferPtr
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
lvr2::ModelFactory::readModel
static ModelPtr readModel(std::string filename)
Definition: ModelFactory.cpp:65
ModelFactory.hpp
ChunkManager.hpp
lvr2::ChunkManager
Definition: ChunkManager.hpp:50
kaboom::Options::getOutputDir
string getOutputDir() const
Definition: src/tools/lvr2_kaboom/Options.cpp:103
lvr2::hdf5features::ArrayIO
Definition: hdf5/ArrayIO.hpp:13
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28
lvr2::hdf5features::ChannelIO
Definition: hdf5/ChannelIO.hpp:20
lvr2::hdf5features::MeshIO
Hdf5IO Feature for handling MeshBuffer related IO.
Definition: MeshIO.hpp:52


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