Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Engine.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14 */
15 
16 #ifndef ENGINE_H
17 #define ENGINE_H
18 
19 #include "Geometry/Scene.h"
20 #include "Acoustic/Source.h"
21 #include "Acoustic/Solver.h"
22 #include "Acoustic/Recepteur.h"
23 
24 #define TEST_ACCELERATION_RECEPTORS
25 
26 typedef struct _validRay
27 {
28  Ray* r;
29  bool valid;
30 } validRay;
31 
35 class Engine
36 {
37 
38 public:
39 #ifdef TEST_ACCELERATION_RECEPTORS
40  Engine() : scene(NULL), sources(NULL), recepteurs(NULL), solver(NULL), rayCounter(0) { }
43  Engine(Scene* _scene, std::vector<Source> *_sources, Solver* _solver, Scene *_recepteurs)
44  {
45  scene = _scene;
46  recepteurs = _recepteurs;
47  sources = _sources;
48  solver = _solver;
49  rayCounter = 0;
50  }
52  Engine(const Engine& other)
53  {
54  scene = other.scene;
55  recepteurs = other.recepteurs;
56  sources = other.sources;
57  solver = other.solver;
58  rayCounter = other.rayCounter;
59  }
61  virtual ~Engine() { }
62 
63  Scene* getScene() { return scene; }
64  void setScene(Scene* _scene) { scene = _scene; }
65 
66  std::vector<Source>* getSources() { return sources; }
67  void setSources(std::vector<Source> *_sources) { sources = _sources; }
68 
69  Solver* getSolver() { return solver; }
70  void setSolver(Solver* _solver) { solver = _solver; }
71 
72  virtual bool process() { return false;}
73 
74  virtual void runStructureBenchmark() {}
75 
76  virtual unsigned long long int getRayCounter(){ return rayCounter;}
77 
78 protected:
80  std::vector<Source> *sources;
83 
84  unsigned long long int rayCounter;
85 #else
86  Engine() : scene(NULL), sources(NULL), recepteurs(NULL), solver(NULL), rayCounter(0) { }
87 
88  Engine(Scene* _scene, std::vector<Source> *_sources, Solver* _solver, std::vector<Recepteur> *_recepteurs)
89  {
90  scene = _scene;
91  sources = _sources;
92  solver = _solver;
93  recepteurs = _recepteurs;
94  rayCounter = 0;
95  }
96 
97  Engine(const Engine& other)
98  {
99  scene = other.scene;
100  sources = other.sources;
101  solver = other.solver;
102  recepteurs = other.recepteurs;
103  rayCounter = other.rayCounter;
104  }
105 
106  virtual ~Engine() { }
107 
108  Scene* getScene() { return scene; }
109  void setScene(Scene* _scene) { scene = _scene; }
110 
111  std::vector<Source>* getSources() { return sources; }
112  void setSources(std::vector<Source> *_sources) { sources = _sources; }
113 
114  Solver* getSolver() { return solver; }
115  void setSolver(Solver* _solver) { solver = _solver; }
116 
117  virtual bool process() { return false;}
118 
119  virtual void runStructureBenchmark() {}
120 
121 protected:
122  Scene* scene;
123  std::vector<Source> *sources;
124  std::vector<Recepteur> *recepteurs;
125  Solver* solver;
126 
127  unsigned long long int rayCounter;
128 #endif
129 };
130 #endif
std::vector< Source > * sources
Pointer to all the receptors.
Definition: Engine.h:80
Ray * r
Pointer to a ray. Should not be NULL.
Definition: Engine.h:28
unsigned long long int rayCounter
Ray counter.
Definition: Engine.h:84
bool valid
Boolean set to True if the ray is validated, which means an event occurs.
Definition: Engine.h:29
virtual bool process()
If implemented, process and return true if success.
Definition: Engine.h:72
Base class for engines (DefaultEngine, ParallelDefaultEngine,...)
Definition: Engine.h:35
void setSolver(Solver *_solver)
Set the Solver.
Definition: Engine.h:70
Solver * solver
Pointer to the solver.
Definition: Engine.h:82
Scene * getScene()
Get the Scene.
Definition: Engine.h:63
Scene * scene
Pointer to the scene.
Definition: Engine.h:79
struct _validRay validRay
void setScene(Scene *_scene)
Set the Scene.
Definition: Engine.h:64
std::vector< Source > * getSources()
Get the Sources.
Definition: Engine.h:66
: Describes a ray by a pair of unsigned int. The first one gives the source number (in the range 0-40...
Definition: Ray.h:38
virtual void runStructureBenchmark()
If implemented, run a benchmark for the engine.
Definition: Engine.h:74
void setSources(std::vector< Source > *_sources)
Set the Sources.
Definition: Engine.h:67
The Solver class gives an interface to the developer to add easily a new acoustic method using ray tr...
Definition: Solver.h:42
This class mainly define a mesh (list of Shape) used by the Simulation object.
Definition: Scene.h:50
Solver * getSolver()
Get the Solver.
Definition: Engine.h:69
Engine(const Engine &other)
Copy constructor.
Definition: Engine.h:52
virtual ~Engine()
Destructor.
Definition: Engine.h:61
Engine(Scene *_scene, std::vector< Source > *_sources, Solver *_solver, Scene *_recepteurs)
Constructor.
Definition: Engine.h:43
Scene * recepteurs
Pointer to all the sources.
Definition: Engine.h:81
virtual unsigned long long int getRayCounter()
Definition: Engine.h:76