-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
91 lines (75 loc) · 3.17 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
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QtCore>
#include <iostream>
#include <chrono>
#include "mesh.h"
#include "util/settings.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);
Settings *appSettings = Settings::getInstance();
appSettings->setIniFilePath(args[0]);
appSettings->inObjFile = settings.value("IO/inObjFile").toString().toStdString();
appSettings->inPlyFile = settings.value("IO/inPlyFile").toString().toStdString();
appSettings->outStrokeFile = settings.value("IO/outStrokeFile").toString().toStdString();
appSettings->outMeshFile = settings.value("IO/outMeshFile").toString().toStdString();
appSettings->isDebug = settings.value("Debug/isDebug").toBool();
appSettings->noOfNearEndVerticesToConsider = settings.value("Params/noOfNearEndVerticesToConsider").toInt();
// Load
Mesh m;
m.loadFromFile();
// Start timing
auto t0 = std::chrono::high_resolution_clock::now();
// Main algo
m.preprocessLines();
std::cout << "Strips preprocessed." << std::endl;
m.getRestrictedMatchingCandidates();
std::cout << "Got restricted matching candidates." << std::endl;
m.getMatches();
std::cout << "Finished matching." << std::endl;
m.meshStripGeneration();
std::cout << "Generated mesh strips." << std::endl;
m.computeBoundaries();
std::cout << "Computed boundaries." << std::endl;
int smoothiterations = 0;
for(int i = 0; i < smoothiterations; i++){
m.smoothBoundaries();
}
std::cout << "Smoothed boundaries." << std::endl;
// ------ Debug undecided triangle generation --------
// m.computeUndecidedTriangles();
// std::cout << "Computed undecided triangles." << std::endl;
m.manifoldConsolidation();
std::cout << "Fixed mesh to be a manifold mesh." << 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(outStrokeFile.toStdString(), outMeshFile.toStdString());
//NOTE!!!! Debug save to file currently does not really save faces in a way that makes sense, mostly because matches
//between edges are directed(Chloe knows about this). One way to make sure we don't double coumt faces is to make a hash
//out of each face's indices
m.debugSaveToFile();
// m.debugUndecidedTrianglesSaveToFile();
// m.debugIncompatibleTrianglesSaveToFile();
std::cout << "Saved to file." << std::endl;
// Clean up
m.cleanUp();
a.exit();
}