Code_TYMPAN  4.2.0
Industrial site acoustic simulation
Sampler.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 SAMPLER_H
17 #define SAMPLER_H
18 
19 #include "Geometry/mathlib.h"
20 
29 class Sampler
30 {
31 public:
33  Sampler(const unsigned int& nbRays = 0,
34  const decimal& Theta = (decimal) M_PIDIV2,
35  const decimal& Phi = (decimal) M_2PI) : _nb_rays(nbRays),
36  _theta(Theta),
37  _phi(Phi)
38  { }
40  Sampler(const Sampler& other)
41  {
42  _theta = other._theta;
43  _phi = other._phi;
44 
45  _nb_rays = other._nb_rays;
46  }
47 
48  Sampler(Sampler* sampler)
49  {
50  _theta = sampler->_theta;
51  _phi = sampler->_phi;
52 
53  _nb_rays = sampler->_nb_rays;
54  }
56  virtual Sampler* Clone()
57  {
58  Sampler* sampler = new Sampler(this);
59  return sampler;
60  }
62  virtual ~Sampler() { }
63 
65  virtual vec3 getSample() { return vec3(0.0, 0.0, 0.0); }
67  virtual bool isAcceptableSample(vec3 v) { return false; }
69  virtual void init() {}
70 
72  virtual unsigned int getNbRays() const { return _nb_rays; }
73  virtual void setNbRays(const unsigned int& nbRays) {_nb_rays = nbRays; init(); }
74 
76  decimal getTheta() const { return _theta; }
77  void setTheta(const decimal& Theta) { _theta = Theta; init(); }
78 
80  decimal getPhi() const { return _phi; }
81  void setPhi(const decimal& Phi) { _phi = Phi ; init(); }
82 
84  virtual unsigned int computeDiffractionNbr(const decimal& theta) { return 0; }
85 
86 protected :
87  unsigned int _nb_rays;
90 };
91 
92 #endif
decimal _phi
Global equatorial angle.
Definition: Sampler.h:89
virtual vec3 getSample()
Return the sample.
Definition: Sampler.h:65
unsigned int _nb_rays
Number of rays to launch.
Definition: Sampler.h:87
decimal _theta
Global polar angle.
Definition: Sampler.h:88
Sampler(const unsigned int &nbRays=0, const decimal &Theta=(decimal) M_PIDIV2, const decimal &Phi=(decimal) M_2PI)
Default constructor.
Definition: Sampler.h:33
Sampler class and its sub-classes describe ray generators used in AcousticRayTracer. In these classes :
Definition: Sampler.h:29
Sampler(const Sampler &other)
Copy constructors.
Definition: Sampler.h:40
Sampler(Sampler *sampler)
Definition: Sampler.h:48
base_vec3< decimal > vec3
Definition: mathlib.h:269
decimal getPhi() const
Get/Set the equatorial polar angle.
Definition: Sampler.h:80
virtual unsigned int computeDiffractionNbr(const decimal &theta)
Return the number of rays to launch after a diffraction event.
Definition: Sampler.h:84
#define M_PIDIV2
Definition: mathlib.h:66
virtual void setNbRays(const unsigned int &nbRays)
Definition: Sampler.h:73
float decimal
Definition: mathlib.h:46
virtual bool isAcceptableSample(vec3 v)
Return true for an acceptable sample.
Definition: Sampler.h:67
virtual unsigned int getNbRays() const
Get/Set the number of rays to launch.
Definition: Sampler.h:72
void setTheta(const decimal &Theta)
Definition: Sampler.h:77
#define M_2PI
2Pi.
Definition: 3d.h:57
virtual ~Sampler()
Destructor.
Definition: Sampler.h:62
decimal getTheta() const
Get/Set the polar angle.
Definition: Sampler.h:76
void setPhi(const decimal &Phi)
Definition: Sampler.h:81
virtual Sampler * Clone()
Clone a sample.
Definition: Sampler.h:56
virtual void init()
Initialize the sample.
Definition: Sampler.h:69