ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Viewer.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include <iostream>
11 #include <string>
12 
17 
18 namespace cloudViewer {
19 namespace visualization {
20 namespace app {
21 
22 static const std::string usage = "usage: ./CloudViewer [meshfile|pointcloud]";
23 static const int width = 1280;
24 static const int height = 960;
25 
26 void RunViewer(int argc, const char *argv[]) {
27  std::function<void(const std::string &)> print_fcn =
30 
31  const char *path = nullptr;
32  if (argc == 2) {
33  path = argv[1];
34  } else if (argc > 2) {
35  utility::LogWarning(usage.c_str());
36  }
37 
38  auto &app = gui::Application::GetInstance();
39  app.Initialize(argc, argv);
40 
41  auto vis = std::make_shared<cloudViewer::visualization::GuiVisualizer>(
42  "CloudViewer", width, height);
43  if (path && path[0] != '\0') {
44  vis->LoadGeometry(path);
45  }
47  // When Run() ends, Filament will be stopped, so we can't be holding on
48  // to any GUI objects.
49  vis.reset();
50 
51  app.Run();
52 
54 }
55 
56 } // namespace app
57 } // namespace visualization
58 } // namespace cloudViewer
void ResetPrintFunction()
Reset the print function to the default one (print to console).
Definition: Logging.cpp:77
void SetPrintFunction(std::function< void(const std::string &)> print_fcn)
Definition: Logging.cpp:68
const std::function< void(const std::string &)> GetPrintFunction()
Get the print function used by the Logger.
Definition: Logging.cpp:73
static Logger & GetInstance()
Get Logger global singleton instance.
Definition: Logging.cpp:25
void AddWindow(std::shared_ptr< Window > window)
Must be called on the same thread that calls Run()
#define LogWarning(...)
Definition: Logging.h:72
static const std::string path
Definition: PointCloud.cpp:59
static const int width
Definition: Viewer.cpp:23
static const std::string usage
Definition: Viewer.cpp:22
void RunViewer(int argc, const char *argv[])
Definition: Viewer.cpp:26
static const int height
Definition: Viewer.cpp:24
Generic file read and write utility for python interface.