-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.cpp
More file actions
82 lines (56 loc) · 1.77 KB
/
plot.cpp
File metadata and controls
82 lines (56 loc) · 1.77 KB
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
#include "plot.h"
//********************************************************************************
void PlotFile(string file){
//to keep the window open
//string call = "C:\\\"Program Files (x86)\"\\gnuplot\\bin\\gnuplot.exe -persist info\\" + file;
string call = "C:\\\"Program Files (x86)\"\\gnuplot\\bin\\gnuplot.exe info\\" + file;
system(call.c_str());
}
string MakeFileForGnuplot(string name){
ofstream out;
string dfile = "dat\\" + name + ".dat";
out.open(dfile.c_str());
int routes = 0;
for(int i = 1; i <= K; i++){
if(BestRouteStart[i] != 0){
routes++;
int from = BestRouteStart[i];
int to = BestPath[from].next;
//out << "#Route#" << routeNum++ << ": " << from;
/*
while(to != 0){
out << " " << to;
from = to;
to = path[to].next;
}
out << endl;
*/
from = BestRouteStart[i];
to = BestPath[from].next;
out << "#X Y"<<endl;
out << x[0] << " " << y[0] << endl;
out << x[from] << " " << y[from] << endl;
while(to != 0){
out << x[to] << " " << y[to] << endl;
from = to;
to = BestPath[to].next;
}
out << x[0] << " " << y[0] << endl;
out << endl<<endl;
}
}
out.close();
string file = "info\\" + name + ".info";
out.open(file.c_str());
out << "set terminal png size 1280,960\nset output 'png\\" << name << ".png'"<<endl;
for(int i = 0; i < routes; i++){
out << "set style line " << i+1 << " lc rgb '#" << rand()%10<<rand()%10<<rand()%10<<rand()%10<<rand()%10<<rand()%10<< "' lt 1 lw 2 pt 7 ps 1.5" << endl;
}
out << "plot 'dat\\" << name << ".dat' index 0 with linespoints ls 1";
for(int i = 1; i < routes; i++){
out << ", '' index "<< i <<" with linespoints ls " << i+1;
}
out << endl;
out.close();
return name + ".info";
}