Code_TYMPAN  4.4.0
Industrial site acoustic simulation
Diffraction.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 DIFFRACTION_H
17 #define DIFFRACTION_H
18 
19 #include <cmath>
20 
21 #include "Event.h"
22 #include "Geometry/Repere.h"
23 #include "Base.h"
24 
25 class Cylindre;
26 
30 class Diffraction : public Event
31 {
32 public:
34  Diffraction(const vec3& position = vec3(0.0, 0.0, 0.0),
35  const vec3& incomingDirection = vec3(0.0, 0.0, 0.0), Cylindre* c = NULL);
37  Diffraction(const Diffraction& other);
39  virtual ~Diffraction() {}
40 
41  virtual void setNbResponseLeft(int _nbResponseLeft)
42  {
43  nbResponseLeft = static_cast<unsigned int>(
44  std::floor(static_cast<decimal>(_nbResponseLeft - 1) / M_2PI * angleOuverture + 0.5));
45  nbResponseLeft = nbResponseLeft >= 4 ? nbResponseLeft : 4; // Limite le nombre a 4 reponses minimum
47  computeDTheta();
48  }
49 
53  virtual bool getResponse(vec3& r, bool force = false);
54 
56  bool (*responseValidator)(const vec3&, const vec3&, const vec3&, vec3&);
57 
60  void (*getTheta)(const decimal&, const decimal&, const decimal&, decimal&);
61 
66  {
67  angleOuverture = angle;
68  computeDTheta();
69  }
70 
75  {
76  return angleOuverture;
77  }
78 
83  {
84  return delta_theta;
85  }
86 
90  virtual double getAngle()
91  {
92  return angleArrive;
93  }
94  virtual bool generateTest(std::vector<vec3>& succededTest, std::vector<vec3>& failTest,
95  unsigned int nbResponses);
97  virtual const Repere& getRepere() const
98  {
99  return localRepere;
100  }
101 
102 #ifdef _ALLOW_TARGETING_
103  virtual bool isAcceptableResponse(vec3& test);
104  virtual bool generateResponse(std::vector<vec3>& responses, unsigned int nbResponses);
105  virtual bool appendTarget(vec3 target, bool force = false);
106 #endif //_ALLOW_TARGETING_
107 
108 protected:
112  void buildRepere();
113 
117  void computeAngle();
118 
124  {
125  // Angles should span the aperture angle of the diffraction edge
127  }
128 
130 
133 
135 
138 };
139 
140 #endif
#define M_2PI
2Pi.
Definition: 3d.h:55
NxReal c
Definition: NxVec3.cpp:317
Cylinder class.
Definition: Cylindre.h:27
Diffraction class Event.
Definition: Diffraction.h:31
vec3 N2
Face 2 normal.
Definition: Diffraction.h:137
void computeDTheta()
Compute the angle step between two responses in function of the aperture angle and the number of resp...
Definition: Diffraction.h:123
decimal getAngleOuverture()
Get the aperture angle of the cone of Keller.
Definition: Diffraction.h:74
virtual void setNbResponseLeft(int _nbResponseLeft)
Set the number of remaining rays to launch.
Definition: Diffraction.h:41
Repere localRepere
Local frame.
Definition: Diffraction.h:129
decimal getDeltaTheta() const
Get the angle between 2 consecutive responses.
Definition: Diffraction.h:82
virtual bool getResponse(vec3 &r, bool force=false)
Computes the next response of the event in function of the number of responses left.
vec3 N1
Face 1 normal.
Definition: Diffraction.h:136
virtual ~Diffraction()
Destructor.
Definition: Diffraction.h:39
decimal delta_theta
Angle step between two rays to send.
Definition: Diffraction.h:134
decimal angleArrive
Incident ray angle.
Definition: Diffraction.h:132
virtual bool generateTest(std::vector< vec3 > &succededTest, std::vector< vec3 > &failTest, unsigned int nbResponses)
bool(* responseValidator)(const vec3 &, const vec3 &, const vec3 &, vec3 &)
Filter generated response (or not)
Definition: Diffraction.h:56
void computeAngle()
Compute the angle between the incident ray and the diffraction edge.
void buildRepere()
Build local frame.
virtual double getAngle()
Get the angle between the incident ray and the diffraction edge.
Definition: Diffraction.h:90
void(* getTheta)(const decimal &, const decimal &, const decimal &, decimal &)
Definition: Diffraction.h:60
virtual const Repere & getRepere() const
Get the local frame.
Definition: Diffraction.h:97
void setAngleOuverture(decimal angle)
Set the aperture angle of the cone of Keller.
Definition: Diffraction.h:65
Diffraction(const vec3 &position=vec3(0.0, 0.0, 0.0), const vec3 &incomingDirection=vec3(0.0, 0.0, 0.0), Cylindre *c=NULL)
Constructor.
Definition: Diffraction.cpp:87
decimal angleOuverture
Angle formed by the two faces of the diffraction edge.
Definition: Diffraction.h:131
Class describing an event (reflection, diffraction, ...)
Definition: Event.h:37
int nbResponseLeft
Number of remaining rays to launch.
Definition: Event.h:238
int initialNbResponse
Number of rays to launch after event.
Definition: Event.h:239
virtual bool generateResponse(std::vector< vec3 > &responses, unsigned int nbResponses)
Definition: Event.h:189
virtual bool appendTarget(vec3 target, bool force=false)
Definition: Event.h:194
virtual bool isAcceptableResponse(vec3 &test)
Return true if the ray direction vector in response of the event is acceptable.
Definition: Event.h:178
Frame class.
Definition: Repere.h:26
float decimal
Definition: mathlib.h:45
base_vec3< decimal > vec3
Definition: mathlib.h:381