gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
MaterialSet.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, 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 __MaterialSet_h
36 #define __MaterialSet_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 #ifndef __TissueMaterial_h
78 #include "TissueMaterial.h"
79 #endif
80 
81 
82 //******************************************************************************
83 // namespace
84 //******************************************************************************
85 namespace gVirtualXRay {
86 
87 
88 //==============================================================================
93 //==============================================================================
95 //------------------------------------------------------------------------------
96 {
97 //******************************************************************************
98 public:
99  static MaterialSet& getInstance();
100 
101 
102  //--------------------------------------------------------------------------
104  //--------------------------------------------------------------------------
105  ~MaterialSet();
106 
107 
108  //--------------------------------------------------------------------------
110  //--------------------------------------------------------------------------
111  void clearMemory();
112 
113 
114  //--------------------------------------------------------------------------
116  /*
117  * @param aFileName: the name of the file to load
118  */
119  //--------------------------------------------------------------------------
120  void loadFromFile(const std::string& aFileName);
121 
122 
123  //--------------------------------------------------------------------------
125  //--------------------------------------------------------------------------
127 
128 
129  //---------------------------------------------------------------------------
131  /*
132  * @param aMaterial the material to add
133  */
134  //---------------------------------------------------------------------------
135  void addMaterial(const TissueMaterial& aMaterial);
136 
137 
138  //--------------------------------------------------------------------------
140  /*
141  * @param aHUValue: the HU value of the material
142  */
143  //--------------------------------------------------------------------------
144  const TissueMaterial& getMaterial(short aHUValue) const;
145 
146 
147  //--------------------------------------------------------------------------
149  /*
150  * @return the lower energy cutoff for attenuation coefficient
151  */
152  //--------------------------------------------------------------------------
153  float getMuMinEnergy() const;
154 
155 
156  //--------------------------------------------------------------------------
158  /*
159  * @return the higher energy cutoff for attenuation coefficient
160  */
161  //--------------------------------------------------------------------------
162  float getMuMaxEnergy() const;
163 
164 
165  //--------------------------------------------------------------------------
167  /*
168  * @return the minimum Hounsfield unit that the material set can handle
169  */
170  //--------------------------------------------------------------------------
171  short getMinHU() const;
172 
173 
174  //--------------------------------------------------------------------------
176  /*
177  * @return the maximum Hounsfield unit that the material set can handle
178  */
179  //--------------------------------------------------------------------------
180  short getMaxHU() const;
181 
182 
183  //--------------------------------------------------------------------------
185  /*
186  * @return the number of materials
187  */
188  //--------------------------------------------------------------------------
189  unsigned int getMaterialNumber() const;
190 
191 
192  //--------------------------------------------------------------------------
194  /*
195  * @param anOutputSream: the output stream
196  * @param anElement: the element to output
197  * @return the output stream
198  */
199  //--------------------------------------------------------------------------
200  friend std::ostream & operator << (std::ostream& anOutputSream,
201  const MaterialSet& anMaterialSet);
202 
203 
204 //*****************************************************************************
205 private:
206  //---------------------------------------------------------------------------
208  //---------------------------------------------------------------------------
209  MaterialSet();
210 
211 
212  //--------------------------------------------------------------------------
214  //--------------------------------------------------------------------------
215  MaterialSet(const MaterialSet&);
216 
217 
218  //--------------------------------------------------------------------------
220  /*
221  * @param aFileName: the name of the file to load
222  */
223  //--------------------------------------------------------------------------
224  MaterialSet(const std::string& aFileName);
225 
226 
227  //--------------------------------------------------------------------------
229  //--------------------------------------------------------------------------
230  MaterialSet& operator=(const MaterialSet&);
231 
232 
233  //--------------------------------------------------------------------------
235  //--------------------------------------------------------------------------
236  std::map<std::pair<short, short>, TissueMaterial> m_material_set;
237 
238 
239  //--------------------------------------------------------------------------
241  //--------------------------------------------------------------------------
242  float m_mu_min_energy;
243 
244 
245  //--------------------------------------------------------------------------
247  //--------------------------------------------------------------------------
248  float m_mu_max_energy;
249 
250 
251  //--------------------------------------------------------------------------
253  //--------------------------------------------------------------------------
254  float m_min_S;
255 
256 
257  //--------------------------------------------------------------------------
259  //--------------------------------------------------------------------------
260  float m_max_S;
261 
262 
263  //--------------------------------------------------------------------------
265  //--------------------------------------------------------------------------
266  short m_min_HU;
267 
268 
269  //--------------------------------------------------------------------------
271  //--------------------------------------------------------------------------
272  short m_max_HU;
273 };
274 
275 
276 } // namespace gVirtualXRay
277 
278 
279 //******************************************************************************
280 #include "MaterialSet.inl"
281 
282 
283 #endif // __MaterialSet_h
unsigned int getMaterialNumber() const
Accessor on the number of materials in the set.
MaterialSet is a class to manage a table of materials.
Definition: MaterialSet.h:94
Class to manage a table of materials.
void loadMaterialSetFromMemory()
Load the table of materials.
~MaterialSet()
Destructor.
Definition: MaterialSet.inl:84
void clearMemory()
Clear all the memory.
Definition: MaterialSet.inl:92
void addMaterial(const TissueMaterial &aMaterial)
Add a material to the list.
const TissueMaterial & getMaterial(short aHUValue) const
Get the material corresponding to a given HU value.
Class to manage a material database. It implements the method as follows: Schneider W...
float getMuMaxEnergy() const
Accessor on the higher energy cutoff for attenuation coefficient.
static MaterialSet & getInstance()
friend std::ostream & operator<<(std::ostream &anOutputSream, const MaterialSet &anMaterialSet)
operator <<
TissueMaterial is a class to manage a material.
void loadFromFile(const std::string &aFileName)
Load a file containing materials.
short getMaxHU() const
Accessor on the maximum Hounsfield unit that the material set can handle.
short getMinHU() const
Accessor on the minimum Hounsfield unit that the material set can handle.
float getMuMinEnergy() const
Accessor on the lower energy cutoff for attenuation coefficient.