-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.cpp
96 lines (66 loc) · 2.34 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
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QtCore>
#include <iostream>
#include <chrono>
#include "mesh.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCommandLineParser parser;
parser.addHelpOption();
parser.addPositionalArgument("config", "Path of the config (.ini) file.");
parser.process(a);
// Check for invalid argument count
const QStringList args = parser.positionalArguments();
if (args.size() < 1) {
std::cerr << "Not enough arguments. Please provide a path to a config file (.ini) as a command-line argument." << std::endl;
a.exit(1);
return 1;
}
// Parse common inputs
QSettings settings( args[0], QSettings::IniFormat );
QString infile = settings.value("IO/infile").toString();
QString outfile = settings.value("IO/outfile").toString();
QString method = settings.value("Method/method").toString();
// A note about the representations of other parameters in the .ini files for the various methods:
// args1:
// Subdivide: number of iterations
// Simplify: number of faces to remove
// Remesh: number of iterations
// Denoise: number of iterations
// args2:
// Remesh: Tangential smoothing weight
// Denoise: Smoothing parameter 1 (\Sigma_c)
// args3:
// Denoise: Smoothing parameter 2 (\Sigma_s)
// args4:
// Denoise: Kernel size (\rho)
// Load
Mesh m;
m.loadFromFile(infile.toStdString());
// Start timing
auto t0 = std::chrono::high_resolution_clock::now();
// Switch on method
if (method == "subdivide") {
int numIterations = settings.value("Parameters/args1").toInt();
// TODO
} else if (method == "simplify") {
// TODO
} else if (method == "remesh") {
// TODO
} else if (method == "noise") {
// TODO
} else if (method == "denoise") {
// TODO
} else {
std::cerr << "Error: Unknown method \"" << method.toUtf8().constData() << "\"" << std::endl;
}
// Finish timing
auto t1 = std::chrono::high_resolution_clock::now();
auto duration = duration_cast<std::chrono::milliseconds>(t1 - t0).count();
std::cout << "Execution took " << duration << " milliseconds." << std::endl;
// Save
m.saveToFile(outfile.toStdString());
a.exit();
}