Code_TYMPAN  4.4.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, const decimal& Theta = (decimal)M_PIDIV2,
34  const decimal& Phi = (decimal)M_2PI)
35  : _nb_rays(nbRays), _theta(Theta), _phi(Phi)
36  {
37  }
39  Sampler(const Sampler& other)
40  {
41  _theta = other._theta;
42  _phi = other._phi;
43 
44  _nb_rays = other._nb_rays;
45  }
46 
47  Sampler(Sampler* sampler)
48  {
49  _theta = sampler->_theta;
50  _phi = sampler->_phi;
51 
52  _nb_rays = sampler->_nb_rays;
53  }
55  virtual Sampler* Clone()
56  {
57  Sampler* sampler = new Sampler(this);
58  return sampler;
59  }
61  virtual ~Sampler() {}
62 
64  virtual vec3 getSample()
65  {
66  return vec3(0.0, 0.0, 0.0);
67  }
69  virtual bool isAcceptableSample(vec3 v)
70  {
71  return false;
72  }
74  virtual void init() {}
75 
77  virtual unsigned int getNbRays() const
78  {
79  return _nb_rays;
80  }
81  virtual void setNbRays(const unsigned int& nbRays)
82  {
83  _nb_rays = nbRays;
84  init();
85  }
86 
88  decimal getTheta() const
89  {
90  return _theta;
91  }
92  void setTheta(const decimal& Theta)
93  {
94  _theta = Theta;
95  init();
96  }
97 
99  decimal getPhi() const
100  {
101  return _phi;
102  }
103  void setPhi(const decimal& Phi)
104  {
105  _phi = Phi;
106  init();
107  }
108 
110  virtual unsigned int computeDiffractionNbr(const decimal& theta)
111  {
112  return 0;
113  }
114 
115 protected:
116  unsigned int _nb_rays;
119 };
120 
121 #endif
#define M_2PI
2Pi.
Definition: 3d.h:55
Sampler class and its sub-classes describe ray generators used in AcousticRayTracer....
Definition: Sampler.h:30
Sampler(Sampler *sampler)
Definition: Sampler.h:47
decimal _phi
Global equatorial angle.
Definition: Sampler.h:118
decimal getTheta() const
Get/Set the polar angle.
Definition: Sampler.h:88
virtual void setNbRays(const unsigned int &nbRays)
Definition: Sampler.h:81
void setTheta(const decimal &Theta)
Definition: Sampler.h:92
decimal _theta
Global polar angle.
Definition: Sampler.h:117
void setPhi(const decimal &Phi)
Definition: Sampler.h:103
unsigned int _nb_rays
Number of rays to launch.
Definition: Sampler.h:116
virtual void init()
Initialize the sample.
Definition: Sampler.h:74
Sampler(const Sampler &other)
Copy constructors.
Definition: Sampler.h:39
virtual unsigned int getNbRays() const
Get/Set the number of rays to launch.
Definition: Sampler.h:77
decimal getPhi() const
Get/Set the equatorial polar angle.
Definition: Sampler.h:99
virtual unsigned int computeDiffractionNbr(const decimal &theta)
Return the number of rays to launch after a diffraction event.
Definition: Sampler.h:110
virtual Sampler * Clone()
Clone a sample.
Definition: Sampler.h:55
Sampler(const unsigned int &nbRays=0, const decimal &Theta=(decimal) M_PIDIV2, const decimal &Phi=(decimal) M_2PI)
Default constructor.
Definition: Sampler.h:33
virtual bool isAcceptableSample(vec3 v)
Return true for an acceptable sample.
Definition: Sampler.h:69
virtual vec3 getSample()
Return the sample.
Definition: Sampler.h:64
virtual ~Sampler()
Destructor.
Definition: Sampler.h:61
#define M_PIDIV2
Definition: mathlib.h:68
float decimal
Definition: mathlib.h:45
base_vec3< decimal > vec3
Definition: mathlib.h:381