-
Notifications
You must be signed in to change notification settings - Fork 11
/
programma.cpp
91 lines (76 loc) · 2.82 KB
/
programma.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
/* Created by Simone Tinella, University of Catania*/
#include<iostream>
#include<vector>
#include <fstream>
#include "Voronoi.h"
int main(){
std::vector<Punto*> quadrato;
quadrato.push_back(new Punto(20,80));
quadrato.push_back(new Punto(20,90));
quadrato.push_back(new Punto(30,90));
quadrato.push_back(new Punto(30,80));
Ostacolo *o=new Ostacolo(&quadrato);
std::vector<Punto*> rettangolo;
rettangolo.push_back(new Punto(80,50));
rettangolo.push_back(new Punto(90,50));
rettangolo.push_back(new Punto(90,45));
rettangolo.push_back(new Punto(80,45));
Ostacolo *o1=new Ostacolo(&rettangolo);
std::vector<Punto*> triangolo;
triangolo.push_back(new Punto(30,50));
triangolo.push_back(new Punto(35,60));
triangolo.push_back(new Punto(40,50));
Ostacolo *o2=new Ostacolo(&triangolo);
std::vector<Punto*> rettangolo2;
rettangolo2.push_back(new Punto(150,50));
rettangolo2.push_back(new Punto(170,50));
rettangolo2.push_back(new Punto(170,35));
rettangolo2.push_back(new Punto(150,35));
Ostacolo *o3=new Ostacolo(&rettangolo2);
std::vector<Punto*> figura;
figura.push_back(new Punto(70,160));
figura.push_back(new Punto(100,160));
figura.push_back(new Punto(90,140));
figura.push_back(new Punto(85,150));
figura.push_back(new Punto(80,140));
Ostacolo *o4=new Ostacolo(&figura);
std::vector<Punto*> punto;
punto.push_back(new Punto(90,95));
Ostacolo *o5=new Ostacolo(&punto);
std::vector<Ostacolo*> ostacoli;
ostacoli.push_back(o);
ostacoli.push_back(o1);
ostacoli.push_back(o2);
ostacoli.push_back(o3);
ostacoli.push_back(o4);
ostacoli.push_back(o5);
Voronoi *mappa=new Voronoi(200,200,ostacoli);
std::vector<Punto*> *voronoi= mappa->getPuntiVoronoi();
ostacoli= *mappa->getOstacoli();
std::vector<Punto*> *incroci= mappa->getIncroci();
Punto *partenza= new Punto(20,140);
Punto *arrivo= new Punto(160,70);
std::vector<Punto> percorso=mappa->getPercorso(*partenza,*arrivo);
std::ofstream fostacoli("ostacoli.txt");
for(int i=0;i<ostacoli.size();i++){
for(int j=0;j<ostacoli.at(i)->getIngombro()->size();j++){
fostacoli<< ostacoli.at(i)->getIngombro()->at(j)->getX() << " " << ostacoli.at(i)->getIngombro()->at(j)->getY() << std::endl;
}
}
fostacoli.close();
std::ofstream fvoronoi("voronoi.txt");
for(int i=0;i<voronoi->size();i++){
fvoronoi<< voronoi->at(i)->getX() << " " << voronoi->at(i)->getY() << std::endl;
}
fvoronoi.close();
std::ofstream fpercorso("percorso.txt");
for(int i=0;i<percorso.size();i++){
fpercorso<< percorso.at(i).getX() << " " << percorso.at(i).getY() << std::endl;
}
fpercorso.close();
std::ofstream fincroci("incroci.txt");
for(int i=0;i<incroci->size();i++){
fincroci<< incroci->at(i)->getX() << " " << incroci->at(i)->getY() << std::endl;
}
fincroci.close();
}