src/tools/lvr2_largescale_reconstruct/Main.cpp
Go to the documentation of this file.
1 
28 #include "LargeScaleOptions.hpp"
31 #include <algorithm>
32 #include <iostream>
35 #include <random>
36 #include <string>
37 #include <lvr2/io/hdf5/ScanIO.hpp>
38 #include <boost/filesystem.hpp>
41 #include "lvr2/io/ScanIOUtils.hpp"
42 
43 using std::cout;
44 using std::endl;
45 using namespace lvr2;
46 
47 #if defined CUDA_FOUND
48 #define GPU_FOUND
49 
51 
52 typedef CudaSurface GpuSurface;
53 #elif defined OPENCL_FOUND
54 #define GPU_FOUND
55 
57 
58 
59 typedef ClSurface GpuSurface;
60 #endif
61 
63 // using ScanHDF5IO = lvr2::Hdf5Build<lvr2::hdf5features::ScanIO>;
64 
66 
67 // Extend IO with features (dependencies are automatically fetched)
69 
70 int main(int argc, char** argv)
71 {
72  // =======================================================================
73  // Parse and print command line parameters
74  // =======================================================================
75  // Parse command line arguments
77 
79 
80  // Exit if options had to generate a usage message
81  // (this means required parameters are missing)
82  if (options.printUsage())
83  {
84  return EXIT_SUCCESS;
85  }
86 
87  std::cout << options << std::endl;
88 
89  string in = options.getInputFileName()[0];
90 
91  boost::filesystem::path selectedFile(in);
92  string extension = selectedFile.extension().string();
93 
94  OpenMPConfig::setNumThreads(options.getNumThreads());
95 
96  LargeScaleReconstruction<Vec> lsr(options.getVoxelSizes(), options.getBGVoxelsize(), options.getScaling(),
97  options.getNodeSize(), options.getPartMethod(), options.getKi(), options.getKd(), options.getKn(),
98  options.useRansac(), options.getFlippoint(), options.extrude(), options.getDanglingArtifacts(),
99  options.getCleanContourIterations(), options.getFillHoles(), options.optimizePlanes(),
100  options.getNormalThreshold(), options.getPlaneIterations(), options.getMinPlaneSize(), options.getSmallRegionThreshold(),
101  options.retesselate(), options.getLineFusionThreshold(), options.getBigMesh(), options.getDebugChunks(), options.useGPU());
102 
103 
104 
105 
107  std::shared_ptr<ChunkHashGrid> cm;
108  BoundingBox<Vec> boundingBox;
109 
110  HDF5IO hdf;
111 
112  //reconstruction from hdf5
113  if (extension == ".h5")
114  {
115  // loadAllPreviewsFromHDF5(in, *project->project.get());
116  HDF5IO hdf;
117  hdf.open(in);
118  ScanProjectPtr scanProjectPtr = hdf.loadScanProject();
119  project->project = scanProjectPtr;
120 
121  for (int i = 0; i < project->project->positions.size(); i++)
122  {
123  project->changed.push_back(true);
124  }
125  cm = std::shared_ptr<ChunkHashGrid>(new ChunkHashGrid(in, 50, boundingBox, options.getChunkSize()));
126  }
127  else
128  {
129 
130  ScanProject dirScanProject;
131  bool importStatus = loadScanProject(in, dirScanProject);
132  //reconstruction from ScanProject Folder
133  if(importStatus) {
134  project->project = make_shared<ScanProject>(dirScanProject);
135  std::vector<bool> init(dirScanProject.positions.size(), true);
136  project->changed = init;
137  }
138  //reconstruction from a .ply file
139  else if(!boost::filesystem::is_directory(selectedFile))
140  {
141  project->project = ScanProjectPtr(new ScanProject);
142  ModelPtr model = ModelFactory::readModel(in);
143  ScanPtr scan(new Scan);
144 
145  scan->points = model->m_pointCloud;
146  ScanPositionPtr scanPosPtr = ScanPositionPtr(new ScanPosition());
147  scanPosPtr->scans.push_back(scan);
148  project->project->positions.push_back(scanPosPtr);
149  project->changed.push_back(true);
150  }
151  //reconstruction from a folder of .ply files
152  else{
153  project->project = ScanProjectPtr(new ScanProject);
154  boost::filesystem::directory_iterator it{in};
155  while (it != boost::filesystem::directory_iterator{})
156  {
157  cout << it->path().string() << endl;
158  string ext = it->path().extension().string();
159  if(ext == ".ply")
160  {
161  ModelPtr model = ModelFactory::readModel(it->path().string());
162  ScanPtr scan(new Scan);
163 
164  scan->points = model->m_pointCloud;
165  ScanPositionPtr scanPosPtr = ScanPositionPtr(new ScanPosition());
166  scanPosPtr->scans.push_back(scan);
167  project->project->positions.push_back(scanPosPtr);
168  project->changed.push_back(true);
169  }
170  it++;
171  }
172 
173 
174  }
175 
176  cm = std::shared_ptr<ChunkHashGrid>(new ChunkHashGrid("chunked_mesh.h5", 50, boundingBox, options.getChunkSize()));
177  }
178 
179  BoundingBox<Vec> bb;
180  // reconstruction with diffrent methods
181  if(options.getPartMethod() == 1)
182  {
183  int x = lsr.mpiChunkAndReconstruct(project, bb, cm);
184  }
185  else
186  {
187  int x = lsr.mpiAndReconstruct(project);
188  }
189 
190  // reconstruction of .ply for diffrent voxelSizes
191  if(options.getDebugChunks())
192  {
193 
194  for (int i; i < options.getVoxelSizes().size(); i++) {
195  lsr.getPartialReconstruct(bb, cm, options.getVoxelSizes()[i]);
196  }
197  }
198 
199  cout << "Program end." << endl;
200 
201  return 0;
202 }
LargeScaleOptions.hpp
lvr2::OpenMPConfig::setNumThreads
static void setNumThreads(int n)
Sets the number of used threads if OpenMP is used for parallelization.
Definition: lvropenmp.cpp:56
lvr2::ScanProjectEditMarkPtr
std::shared_ptr< ScanProjectEditMark > ScanProjectEditMarkPtr
Definition: ScanTypes.hpp:357
lvr2::LargeScaleReconstruction::mpiChunkAndReconstruct
int mpiChunkAndReconstruct(ScanProjectEditMarkPtr project, BoundingBox< BaseVecT > &newChunksBB, std::shared_ptr< ChunkHashGrid > chunkManager)
lvr2::ScanProjectEditMark
Definition: ScanTypes.hpp:350
BaseVector.hpp
GeometryAlgorithms.hpp
CudaSurface.hpp
lvr2::Hdf5IO
Manager Class for all Hdf5IO components located in hdf5 directory.
Definition: HDF5FeatureBase.hpp:38
lvr2::BaseVector< float >
lvr2::LargeScaleReconstruction::getPartialReconstruct
HalfEdgeMesh< BaseVecT > getPartialReconstruct(BoundingBox< BaseVecT > newChunksBB, std::shared_ptr< ChunkHashGrid > chunkHashGrid, float voxelSize)
LargeScaleOptions::Options
A class to parse the program options for the reconstruction executable.
Definition: LargeScaleOptions.hpp:58
lvr2::ScanProjectPtr
std::shared_ptr< ScanProject > ScanProjectPtr
Definition: ScanTypes.hpp:344
ScanProjectIO.hpp
GpuSurface
CudaSurface GpuSurface
Definition: src/tools/lvr2_cuda_normals/Main.cpp:60
lvr2::ChunkHashGrid
Definition: ChunkHashGrid.hpp:67
lvr2::CudaSurface
Definition: CudaSurface.hpp:78
ClSurface.hpp
ScanIOUtils.hpp
lvr2::Scan
Definition: ScanTypes.hpp:24
options
const kaboom::Options * options
Definition: src/tools/lvr2_kaboom/Main.cpp:45
lvropenmp.hpp
lvr2::ClSurface
Definition: ClSurface.hpp:63
lvr2::ScanPosition
Definition: ScanTypes.hpp:276
lvr2::ScanPositionPtr
std::shared_ptr< ScanPosition > ScanPositionPtr
Definition: ScanTypes.hpp:311
lvr2::HDF5IO::open
bool open(std::string filename, int open_flag)
Definition: HDF5IO.cpp:232
ScanIO.hpp
main
int main(int argc, char **argv)
Definition: src/tools/lvr2_largescale_reconstruct/Main.cpp:70
lvr2::ScanProject
Definition: ScanTypes.hpp:322
HDF5FeatureBase.hpp
lvr2::BoundingBox
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
argc
int argc
Definition: tests_high_five_parallel.cpp:27
LargeScaleReconstruction.hpp
lvr2::loadScanProject
bool loadScanProject(const boost::filesystem::path &root, ScanProject &scanProj)
Definition: ScanIOUtils.cpp:1083
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Hdf5IO::AddFeatures
typename add_features_with_deps< F... >::type AddFeatures
Definition: HDF5FeatureBase.hpp:120
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::HDF5IO
Definition: descriptions/HDF5IO.hpp:13
lvr2::BaseOption::printLogo
void printLogo() const
Definition: BaseOption.cpp:110
lvr2::ModelFactory::readModel
static ModelPtr readModel(std::string filename)
Definition: ModelFactory.cpp:65
lvr2::LargeScaleReconstruction::mpiAndReconstruct
int mpiAndReconstruct(ScanProjectEditMarkPtr project)
lvr2::LargeScaleReconstruction
Definition: LargeScaleReconstruction.hpp:134
argv
char ** argv
Definition: tests_high_five_parallel.cpp:28
lvr2::ScanProject::positions
std::vector< ScanPositionPtr > positions
Vector of scan positions for this project.
Definition: ScanTypes.hpp:344
lvr2::HDF5IO::loadScanProject
ScanProjectPtr loadScanProject()
Definition: descriptions/HDF5IO.cpp:21
lvr2::ScanPtr
std::shared_ptr< Scan > ScanPtr
Shared pointer to scans.
Definition: ScanTypes.hpp:98


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