-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
109 lines (98 loc) · 4.47 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "mainwindow.h"
#include "parameters.h"
#include <QStyleFactory>
#include <iostream>
#include <QApplication>
void setPalette(QApplication& a) {
a.setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25, 25, 25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
darkPalette.setColor(QPalette::ButtonText, Qt::white);
darkPalette.setColor(QPalette::BrightText, Qt::red);
darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
darkPalette.setColor(QPalette::HighlightedText, Qt::black);
a.setPalette(darkPalette);
a.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
}
void parseArgument(const std::string& arg, const std::string& param) {
if (arg == "--extents") {
auto extents = Mpcv::parseExtents(param);
std::cout << "Setting point extents to " << extents.lower()[0] << "," << extents.lower()[1] << ":"
<< extents.upper()[0] << "," << extents.upper()[1] << std::endl;
Mpcv::Parameters::global().extents = extents;
} else if (arg == "--stride") {
int stride = std::stoi(param);
std::cout << "Setting point stride to " << stride << std::endl;
Mpcv::Parameters::global().pointStride = stride;
} else if (arg == "--subset") {
if (param == "street") {
Mpcv::Parameters::global().subset = Mpcv::CloudSubset::STREET_ONLY;
} else if (param == "aerial") {
Mpcv::Parameters::global().subset = Mpcv::CloudSubset::AERIAL_ONLY;
} else {
std::cout << "Unknown subset type, expected 'street' or 'aerial'" << std::endl;
exit(-1);
}
} else if (arg == "--textureScale") {
float scale = std::stof(param);
std::cout << "Setting texture scale to " << scale << std::endl;
Mpcv::Parameters::global().textureScale = scale;
} else if (arg == "--dsmResolution") {
int res = std::stoi(param);
std::cout << "Setting DSM resolution " << res << std::endl;
Mpcv::Parameters::global().dsmResolution = res;
} else {
std::cout << "Unknown parameter '" << arg << "'" << std::endl;
exit(-1);
}
}
int main(int argc, char* argv[]) {
if (argc == 2 && (argv[1] == std::string("-h") || argv[1] == std::string("--help"))) {
std::cout << "Mesh and Point Cloud Viewer" << std::endl;
std::cout << "Usage: mpcv [OPTIONS] [FILE]..." << std::endl << std::endl;
std::cout << "Available parameters:" << std::endl;
std::cout << "--extents llx,lly:urx,ury Specifies filtering extents for any loaded point cloud"
<< std::endl;
std::cout << "--stride n Loads only every n-th point for each point cloud"
<< std::endl;
std::cout << "--subset [street,aerial] Loads only a specific category of points" << std::endl;
std::cout << "--textureScale f Resizes the loaded textures by given factor" << std::endl;
std::cout << "--dsmResolution n Resolution of the loaded GeoTIFF DSMs" << std::endl;
return 0;
}
QApplication a(argc, argv);
setlocale(LC_NUMERIC, "C"); // needed for sscanf
setPalette(a);
QStringList args = a.arguments();
std::vector<QString> files;
for (int i = 1; i < args.size(); ++i) {
QString arg = args.at(i);
if (arg.size() > 2 && arg.left(2) == "--") {
if (i == args.size() - 1) {
std::cout << "Missing parameter of '" << arg.toStdString() << "'" << std::endl;
exit(-1);
}
parseArgument(arg.toStdString(), args.at(i + 1).toStdString());
i++;
} else {
files.push_back(arg);
}
}
MainWindow w;
#ifdef NDEBUG
w.setWindowTitle(QString("MPCV build ") + __DATE__ + " " + __TIME__);
#else
w.setWindowTitle(QString("MPCV DEBUG BUILD ") + __DATE__ + " " + __TIME__);
#endif
w.showMaximized();
w.openAll(files);
return a.exec();
}