MCPcopy Create free account
hub / github.com/cdcseacave/openMVS / main

Function main

apps/ReconstructMesh/ReconstructMesh.cpp:336–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334}
335
336int main(int argc, LPCTSTR* argv)
337{
338 #ifdef _DEBUGINFO
339 // set _crtBreakAlloc index or use _CrtSetBreakAlloc() to stop in <dbgheap.c> at allocation
340 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);// | _CRTDBG_CHECK_ALWAYS_DF);
341 #endif
342
343 Application application;
344 if (!application.Initialize(argc, argv))
345 return EXIT_FAILURE;
346
347 Scene scene(OPT::nMaxThreads);
348 // load project
349 const Scene::SCENE_TYPE sceneType(scene.Load(MAKE_PATH_SAFE(OPT::strInputFileName),
350 OPT::fSplitMaxArea > 0 || OPT::fDecimateMesh < 1 || OPT::nTargetFaceNum > 0 || !OPT::strImportROIFileName.empty()));
351 if (sceneType == Scene::SCENE_NA)
352 return EXIT_FAILURE;
353 if (!OPT::strPointCloudFileName.empty() && (File::isFile(MAKE_PATH_SAFE(OPT::strPointCloudFileName)) ?
354 !scene.pointcloud.Load(MAKE_PATH_SAFE(OPT::strPointCloudFileName)) :
355 !scene.pointcloud.IsValid())) {
356 VERBOSE("error: cannot load point-cloud file");
357 return EXIT_FAILURE;
358 }
359 if (!OPT::strMeshFileName.empty() && !scene.mesh.Load(MAKE_PATH_SAFE(OPT::strMeshFileName))) {
360 VERBOSE("error: cannot load mesh file");
361 return EXIT_FAILURE;
362 }
363 const String baseFileName(MAKE_PATH_SAFE(Util::getFileFullName(OPT::strOutputFileName)));
364 if (OPT::fSplitMaxArea > 0) {
365 // split mesh using max-area constraint
366 Mesh::FacesChunkArr chunks;
367 if (scene.mesh.Split(chunks, OPT::fSplitMaxArea))
368 scene.mesh.Save(chunks, baseFileName);
369 return EXIT_SUCCESS;
370 }
371
372 if (!OPT::strImportROIFileName.empty()) {
373 if (!scene.LoadROI(MAKE_PATH_SAFE(OPT::strImportROIFileName))) {
374 VERBOSE("error: cannot load ROI file");
375 return EXIT_FAILURE;
376 }
377 if (OPT::bCrop2ROI && !scene.mesh.IsEmpty() && !scene.IsValid()) {
378 TD_TIMER_START();
379 const size_t numVertices = scene.mesh.vertices.size();
380 const size_t numFaces = scene.mesh.faces.size();
381 scene.mesh.RemoveFacesOutside(scene.obb);
382 VERBOSE("Mesh trimmed to ROI: %u vertices and %u faces removed (%s)",
383 numVertices-scene.mesh.vertices.size(), numFaces-scene.mesh.faces.size(), TD_TIMER_GET_FMT().c_str());
384 scene.mesh.Save(baseFileName+OPT::strExportType);
385 return EXIT_SUCCESS;
386 }
387 }
388
389 if (!OPT::strImagePointsFileName.empty() && !scene.mesh.IsEmpty()) {
390 Export3DProjections(scene, MAKE_PATH_SAFE(OPT::strImagePointsFileName));
391 return EXIT_SUCCESS;
392 }
393

Callers

nothing calls this directly

Calls 15

isFileFunction · 0.85
getFileFullNameFunction · 0.85
Export3DProjectionsFunction · 0.85
LoadROIMethod · 0.80
RemoveFacesOutsideMethod · 0.80
ExportCamerasMLPMethod · 0.80
ReloadImageMethod · 0.80
UpdateCameraMethod · 0.80
SelectNeighborViewsMethod · 0.80
CleanMethod · 0.80
FOREACHFunction · 0.50
InitializeMethod · 0.45

Tested by

no test coverage detected