-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
executable file
·107 lines (89 loc) · 2.46 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
#include <iostream>
#include <stdio.h>
#include "mstsegmenter.h"
#include "vertexmstsegmenter.h"
using namespace std;
string fileM;
float K = 0.08; //default value
float alpha = 200;
string fileOut;
string fileN;
string fileField;
bool triBased;
//Command line instructions
void print_help(){
printf("Print help: ");
exit(0);
}
void parseArgs(int argc, char* argv[]){
fileM="";
cout<<"Parsing"<<endl;
for(int ii=1; ii<argc; ii+=2){
if(!strcmp(argv[ii], "-m")){
QString input = argv[ii+1];
fileM = input.toStdString();
}
else if(!strcmp(argv[ii], "-K")){
double input = atof(argv[ii+1]);
K = input;
cout<<"K "<<K<<endl;
}
else if(!strcmp(argv[ii], "-a")){
double input = atof(argv[ii+1]);
alpha = input;
cout<<"alpha "<<alpha<<endl;
}
else if(!strcmp(argv[ii], "-out")){
QString nf = argv[ii+1];
fileOut = nf.toStdString();
}
else if(!strcmp(argv[ii], "-ON")){
QString nf = argv[ii+1];
fileN = nf.toStdString();
cout<<"ON "<<fileN.c_str()<<endl;
}
else if(!strcmp(argv[ii], "-VB")){
triBased = false;
QString nf = argv[ii+1];
fileField = nf.toStdString();
}
else if(!strcmp(argv[ii], "-help")){
print_help();
}
else
cout<<"Invalid input, ignore ("<<argv[ii]<<")"<<endl;
}
}
int main(int argc, char* argv[])
{
cout << "Hello TriMST segmenter!" << endl;
triBased = true;
if(argc<3){
cout<<"Not enough input arguments, type ./TriMST -help"<<endl;
exit(-1);
}
parseArgs(argc, argv);
if(!triBased){
VertexMSTSegmenter *VMSTseg = new VertexMSTSegmenter(fileM, K);
VMSTseg->callLoad();
VMSTseg->setAlpha(alpha);
VMSTseg->callReadF(fileField);
cout<<"Called load"<<endl;
VMSTseg->callInit();
cout<<"Called init"<<endl;
VMSTseg->triggerSegmentation();
VMSTseg->callWriteF(fileOut);
return 0;
}
MSTsegmenter *MSTS = new MSTsegmenter(fileM, K);
MSTS->setAlpha(alpha);
MSTS->callLoad();
MSTS->callInit();
MSTS->triggerSegmentation();
MSTS->writeSegmentation(fileOut);
if(strcmp(fileN.c_str(), "")){
cout<<"Writing on "<<fileN.c_str()<<endl;
MSTS->writeNumbers(fileN);
}
return 0;
}