-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulation.cpp
More file actions
executable file
·67 lines (61 loc) · 1.28 KB
/
Simulation.cpp
File metadata and controls
executable file
·67 lines (61 loc) · 1.28 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
#include"Simulation.h"
#include "IntegrateurEuler.h"
#include "IntegrateurRungeKutta.h"
Simulation::Simulation(double _tps):temps(_tps){
}
void Simulation::Add_Mobile(Mobile* m){
listeMobile.push_back(m);
}
void Simulation::Delete_Mobile(Mobile* m){
listeMobile.remove(m);
//delete m;
}
void Simulation::Show_Liste(){
std::list<Mobile*>::iterator it;
it = listeMobile.begin();
while( it != listeMobile.end() )
{
(*it)->affichage();
it++;
}
}
void Simulation::simuler(double dt){
temps+=dt;// modifie le temps courant
std::list<Mobile*>::iterator it;
it = listeMobile.begin();
while( it != listeMobile.end() )
{
(*it)->advance<IntegrateurEuler>(dt);
it++;
}
}
double Simulation::get_temps() const{
return temps;
}
std::list<Mobile*>& Simulation::get_listemobile(){
return listeMobile;
}
Simulation::Simulation(const Simulation& _s){
if(this != &_s)
{
temps = _s.temps;
std::list<Mobile*> tmp=_s.listeMobile;
std::list<Mobile*>::iterator it;
it = tmp.begin();
while( it != tmp.end() )
{
Add_Mobile((*it)->copie());// on appel copie qui renvoie un pointeur de Mobile
it++;
}
}
}
Simulation::~Simulation(){
std::list<Mobile*>::iterator it;
it = listeMobile.begin();
while( it != listeMobile.end() )
{
delete (*it);
it++;
}
listeMobile.clear();
}