Code_TYMPAN  4.4.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;
31 
35 class Engine
36 {
37 
38 public:
39 #ifdef TEST_ACCELERATION_RECEPTORS
41  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 
64  {
65  return scene;
66  }
67  void setScene(Scene* _scene)
68  {
69  scene = _scene;
70  }
71 
72  std::vector<Source>* getSources()
73  {
74  return sources;
75  }
76  void setSources(std::vector<Source>* _sources)
77  {
78  sources = _sources;
79  }
80 
82  {
83  return solver;
84  }
85  void setSolver(Solver* _solver)
86  {
87  solver = _solver;
88  }
89 
90  virtual bool process()
91  {
92  return false;
93  }
94 
95  virtual void runStructureBenchmark() {}
96 
97  virtual unsigned long long int getRayCounter()
98  {
99  return rayCounter;
100  }
101 
102 protected:
104  std::vector<Source>* sources;
107 
108  unsigned long long int rayCounter;
109 #else
110  Engine() : scene(NULL), sources(NULL), recepteurs(NULL), solver(NULL), rayCounter(0) {}
111 
112  Engine(Scene* _scene, std::vector<Source>* _sources, Solver* _solver, std::vector<Recepteur>* _recepteurs)
113  {
114  scene = _scene;
115  sources = _sources;
116  solver = _solver;
117  recepteurs = _recepteurs;
118  rayCounter = 0;
119  }
120 
121  Engine(const Engine& other)
122  {
123  scene = other.scene;
124  sources = other.sources;
125  solver = other.solver;
126  recepteurs = other.recepteurs;
127  rayCounter = other.rayCounter;
128  }
129 
130  virtual ~Engine() {}
131 
132  Scene* getScene()
133  {
134  return scene;
135  }
136  void setScene(Scene* _scene)
137  {
138  scene = _scene;
139  }
140 
141  std::vector<Source>* getSources()
142  {
143  return sources;
144  }
145  void setSources(std::vector<Source>* _sources)
146  {
147  sources = _sources;
148  }
149 
150  Solver* getSolver()
151  {
152  return solver;
153  }
154  void setSolver(Solver* _solver)
155  {
156  solver = _solver;
157  }
158 
159  virtual bool process()
160  {
161  return false;
162  }
163 
164  virtual void runStructureBenchmark() {}
165 
166 protected:
167  Scene* scene;
168  std::vector<Source>* sources;
169  std::vector<Recepteur>* recepteurs;
170  Solver* solver;
171 
172  unsigned long long int rayCounter;
173 #endif
174 };
175 #endif
struct _validRay validRay
Base class for engines (DefaultEngine, ParallelDefaultEngine,...)
Definition: Engine.h:36
void setSolver(Solver *_solver)
Set the Solver.
Definition: Engine.h:85
void setSources(std::vector< Source > *_sources)
Set the Sources.
Definition: Engine.h:76
void setScene(Scene *_scene)
Set the Scene.
Definition: Engine.h:67
Scene * recepteurs
Pointer to all the sources.
Definition: Engine.h:105
Scene * scene
Pointer to the scene.
Definition: Engine.h:103
Scene * getScene()
Get the Scene.
Definition: Engine.h:63
virtual ~Engine()
Destructor.
Definition: Engine.h:61
Engine(Scene *_scene, std::vector< Source > *_sources, Solver *_solver, Scene *_recepteurs)
Constructor.
Definition: Engine.h:43
Solver * solver
Pointer to the solver.
Definition: Engine.h:106
unsigned long long int rayCounter
Ray counter.
Definition: Engine.h:108
Engine()
Default constructor.
Definition: Engine.h:41
virtual bool process()
If implemented, process and return true if success.
Definition: Engine.h:90
virtual void runStructureBenchmark()
If implemented, run a benchmark for the engine.
Definition: Engine.h:95
Solver * getSolver()
Get the Solver.
Definition: Engine.h:81
std::vector< Source > * sources
Pointer to all the receptors.
Definition: Engine.h:104
virtual unsigned long long int getRayCounter()
Definition: Engine.h:97
std::vector< Source > * getSources()
Get the Sources.
Definition: Engine.h:72
Engine(const Engine &other)
Copy constructor.
Definition: Engine.h:52
: 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
This class mainly define a mesh (list of Shape) used by the Simulation object.
Definition: Scene.h:51
The Solver class gives an interface to the developer to add easily a new acoustic method using ray tr...
Definition: Solver.h:45
bool valid
Boolean set to True if the ray is validated, which means an event occurs.
Definition: Engine.h:29
Ray * r
Pointer to a ray. Should not be NULL.
Definition: Engine.h:28