EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_conical_shell.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ conical shell shape headers
5 # Copyright (C) 2016 Randle E. P. Taylor, Rowan M. Thomson,
6 # Marc J. P. Chamberland, D. W. O. Rogers
7 #
8 # This file is part of EGSnrc.
9 #
10 # EGSnrc is free software: you can redistribute it and/or modify it under
11 # the terms of the GNU Affero General Public License as published by the
12 # Free Software Foundation, either version 3 of the License, or (at your
13 # option) any later version.
14 #
15 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
18 # more details.
19 #
20 # You should have received a copy of the GNU Affero General Public License
21 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
22 #
23 ###############################################################################
24 #
25 # Author: Randle Taylor, 2016
26 #
27 # Contributors: Marc Chamberland
28 # Rowan Thomson
29 # Dave Rogers
30 #
31 ###############################################################################
32 #
33 # egs_conical_shell was developed for the Carleton Laboratory for
34 # Radiotherapy Physics.
35 #
36 ###############################################################################
37 */
38 
39 
45 #ifndef EGS_CONICAL_SHELL_
46 #define EGS_CONICAL_SHELL_
47 
48 #include "egs_shapes.h"
49 #include "egs_rndm.h"
50 #include "egs_math.h"
51 #include "egs_alias_table.h"
52 #include <fstream>
53 
54 #ifdef WIN32
55 
56  #ifdef BUILD_CONICAL_SHELL_DLL
57  #define EGS_CONICAL_SHELL_EXPORT __declspec(dllexport)
58  #else
59  #define EGS_CONICAL_SHELL_EXPORT __declspec(dllimport)
60  #endif
61  #define EGS_CONICAL_SHELL_LOCAL
62 
63 #else
64 
65  #ifdef HAVE_VISIBILITY
66  #define EGS_CONICAL_SHELL_EXPORT __attribute__ ((visibility ("default")))
67  #define EGS_CONICAL_SHELL_LOCAL __attribute__ ((visibility ("hidden")))
68  #else
69  #define EGS_CONICAL_SHELL_EXPORT
70  #define EGS_CONICAL_SHELL_LOCAL
71  #endif
72 
73 #endif
74 
175 struct CSSSLayer {
176 
177 public:
178 
179  EGS_Float thick;
180  EGS_Float ri_top, ro_top;
181  EGS_Float ri_bot, ro_bot;
182  EGS_Float zo;
183  EGS_Float o_slope, i_slope;
184  EGS_Float volume, vout, vcyl, vin;
185  bool const_width;
186 
187  EGS_Float ri_min, ri_max, ro_min, ro_max;
188 
189 
190  CSSSLayer(EGS_Float t, EGS_Float rit, EGS_Float rot, EGS_Float rib, EGS_Float rob, EGS_Float z);
191 
192  EGS_Vector getPoint(EGS_RandomGenerator *rndm);
193 
194  void getRZEqualWidth(EGS_RandomGenerator *rndm, EGS_Float &r, EGS_Float &z);
195 
196  void getRZRejection(EGS_RandomGenerator *rndm, EGS_Float &r, EGS_Float &z);
197 
198  EGS_Vector getPointInCircleAtZ(EGS_RandomGenerator *rndm, EGS_Float r, EGS_Float z);
199 
200  EGS_Float getRoAtZ(EGS_Float z);
201 
202  EGS_Float getRiAtZ(EGS_Float z);
203 
204 };
205 
206 
207 
208 class EGS_CONICAL_SHELL_EXPORT EGS_ConicalShellStackShape : public EGS_BaseShape {
209 
210 
211 public:
212 
214  EGS_ConicalShellStackShape(const EGS_Vector &Xo, const string &Name = "", EGS_ObjectFactory *f=0);
215 
217  for (size_t i = 0; i < layers.size(); i++) {
218  delete layers[i];
219  }
220  };
221 
224 
225  bool supportsDirectionMethod() const {
226  return false;
227  };
228 
229  EGS_Float area() const {
230  return surface_area;
231  };
232 
233  void addLayer(EGS_Float thick, EGS_Float ri_top, EGS_Float ro_top, EGS_Float ri_bot,EGS_Float ro_bot);
234  void addLayer(EGS_Float thick, EGS_Float ri_bot,EGS_Float ro_bot);
235 
236 protected:
237 
238  void setLayerSampler();
239 
240  vector<CSSSLayer *> layers; // inner radii of shell stack
241 
242  vector<EGS_Float> volumes; // volume of each section of shell
243  vector<EGS_Float> cum_volumes; // cumulative volume of each section of shell (normed to 1)
244  EGS_SimpleAliasTable *layer_sampler; // cumulative volume of each section of shell (normed to 1)
245 
246  EGS_Vector xo; // The midpoint
247  EGS_Float surface_area; // calculated total surface area of stack
248  EGS_Float total_thick; // calculated total surface area of stack
249 
250 };
251 
252 
253 #endif
EGS_AliasTable class header file.
A class representing 3D vectors.
Definition: egs_vector.h:56
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Definition: egs_shapes.h:112
A conical shell shape.
virtual EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Sample and return a random 3D vector.
Definition: egs_shapes.h:149
Base random number generator class. All random number generators should be derived from this class...
Definition: egs_rndm.h:67
virtual EGS_Float area() const
Definition: egs_shapes.h:232
virtual bool supportsDirectionMethod() const
Definition: egs_shapes.h:204
EGS_RandomGenerator class header file.
A class for sampling random bins from a given probability distribution using the alias table techniqu...
EGS_BaseShape and shape classes header file.
An object factory.
Attempts to fix broken math header files.