gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Mixture.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2018, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __Mixture_h
36 #define __Mixture_h
37 
38 
66 //******************************************************************************
67 // Include
68 //******************************************************************************
69 #ifndef __gVirtualXRayConfig_h
71 #endif
72 
73 #include <iostream>
74 #include <map>
75 #include <string>
76 
77 
78 //******************************************************************************
79 // define
80 //******************************************************************************
81 
82 
83 //******************************************************************************
84 // namespace
85 //******************************************************************************
86 namespace gVirtualXRay {
87 
88 
89 //******************************************************************************
90 // Class declaration
91 //******************************************************************************
92 class ElementSet;
93 
94 
95 //==============================================================================
100 //==============================================================================
101 class Mixture
102 //------------------------------------------------------------------------------
103 {
104 //******************************************************************************
105 public:
106  //--------------------------------------------------------------------------
108  /*
109  * @param aWeightSet: ???
110  */
111  //--------------------------------------------------------------------------
112  Mixture();
113 
114 
115  Mixture(const std::map<int, double>& aWeightSet);
116 
117 
118  Mixture(const std::map<std::string, double>& aWeightSet);
119 
120 
121  //--------------------------------------------------------------------------
123  /*
124  * @param aMixture: the mixture to copy
125  */
126  //--------------------------------------------------------------------------
127  Mixture(const Mixture& aMixture);
128 
129 
130  void clear();
131 
132  void setMixture(const std::map<int, double>& aWeightSet);
133  void setMixture(const std::map<std::string, double>& aWeightSet);
134  void addElement(const std::string& aName, double aPercentage);
135 
136 
137  //--------------------------------------------------------------------------
139  //--------------------------------------------------------------------------
140  void normaliseWeightSet();
141 
142 
143  //--------------------------------------------------------------------------
145  /*
146  * @return the molar mass of the material
147  */
148  //--------------------------------------------------------------------------
149  double computeMolarMass();
150 
151 
152  //--------------------------------------------------------------------------
154  /*
155  * @return the molar mass of the element
156  */
157  //--------------------------------------------------------------------------
158  double getMolarMass() const;
159 
160 
161  void setDensity(double aDensity);
162 
163 
164  //--------------------------------------------------------------------------
166  /*
167  * @return the material density
168  */
169  //--------------------------------------------------------------------------
170  double getDensity() const;
171 
172 
173  //--------------------------------------------------------------------------
176  /*
177  * @param aHounsfieldValue: the material (HU) value
178  * @param anEnergy: the energy
179  * @return the corresponding linear attenuation coefficient
180  */
181  //--------------------------------------------------------------------------
182  double getMassAttenuationTotal(double anEnergy) const;
183 
184 
185  //--------------------------------------------------------------------------
188  /*
189  * @param anEnergy: the energy
190  * @return the corresponding linear attenuation coefficient
191  */
192  //--------------------------------------------------------------------------
193  double getLinearAttenuationTotal(double anEnergy) const;
194 
195 
196  //--------------------------------------------------------------------------
199  /*
200  * @param anEnergy: the energy
201  * @return the corresponding linear attenuation coefficient
202  */
203  //--------------------------------------------------------------------------
204  double getMu(double anEnergy) const;
205 
206 
207  //--------------------------------------------------------------------------
210  /*
211  * @param x: the sample
212  * @return the Compton scattering cross section value
213  */
214  //--------------------------------------------------------------------------
215  double getS(double x) const;
216 
217 
218  const std::string& getLabel() const;
219 
220 
221  //--------------------------------------------------------------------------
223  /*
224  * @param aMaterial: the material to copy
225  * @return the newly created material
226  */
227  //--------------------------------------------------------------------------
228  Mixture& operator=(const Mixture& aMixture);
229 
230 
231  bool operator==(const Mixture& aMixture) const;
232 
233 
234  bool operator!=(const Mixture& aMixture) const;
235 
236 
237  const std::map<int, double>& getWeightSet() const;
238 
239 
240 //******************************************************************************
241 private:
242  void setLabel();
243 
244 
245  // The weight of each element in the material
246  std::map<int, double> m_p_weight_set; // First: Atomic number; Second: Weight in percentage
247 
248 
249  // The molar mass of the material
250  double m_molar_mass;
251 
252  // The density (a negative value means that it is computed automatically from the HU number
253  // A positive value means that is is set by the user
254  double m_density;
255 
256 
257  std::string m_label;
258 };
259 
260 
261 } // namespace gVirtualXRay
262 
263 
264 //******************************************************************************
265 #include "Mixture.inl"
266 
267 
268 #endif // __Mixture_h
void addElement(const std::string &aName, double aPercentage)
Class to manage a mixture (e.g. Ti90Al6V4).
double getS(double x) const
bool operator==(const Mixture &aMixture) const
double getMolarMass() const
Accessor on the molar mass of the material.
Definition: Mixture.inl:209
bool operator!=(const Mixture &aMixture) const
Definition: Mixture.inl:271
Mixture()
Default Constructor.
Definition: Mixture.inl:83
double getLinearAttenuationTotal(double anEnergy) const
Definition: Mixture.inl:233
double getMassAttenuationTotal(double anEnergy) const
void setMixture(const std::map< int, double > &aWeightSet)
Definition: Mixture.inl:145
const std::string & getLabel() const
Definition: Mixture.inl:250
double getMu(double anEnergy) const
Definition: Mixture.inl:242
Mixture & operator=(const Mixture &aMixture)
Copy operator.
Definition: Mixture.inl:258
Mixture is a class to manage a mixture (e.g. Ti90Al6V4).
Definition: Mixture.h:101
void normaliseWeightSet()
Normalise the weight set.
double computeMolarMass()
Update the value of the molar mass of the material.
const std::map< int, double > & getWeightSet() const
Definition: Mixture.inl:279
double getDensity() const
Get the density of the material.
Definition: Mixture.inl:225
void setDensity(double aDensity)
Definition: Mixture.inl:217