EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_extended_shape.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ extended shape headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2005
25 #
26 # Contributors:
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_EXTENDED_SHAPE_
38 #define EGS_EXTENDED_SHAPE_
39 
40 #include "egs_shapes.h"
41 #include "egs_rndm.h"
42 
43 #ifdef WIN32
44 
45  #ifdef BUILD_EXTENDED_SHAPE_DLL
46  #define EGS_EXTENDED_SHAPE_EXPORT __declspec(dllexport)
47  #else
48  #define EGS_EXTENDED_SHAPE_EXPORT __declspec(dllimport)
49  #endif
50  #define EGS_EXTENDED_SHAPE_LOCAL
51 
52 #else
53 
54  #ifdef HAVE_VISIBILITY
55  #define EGS_EXTENDED_SHAPE_EXPORT __attribute__ ((visibility ("default")))
56  #define EGS_EXTENDED_SHAPE_LOCAL __attribute__ ((visibility ("hidden")))
57  #else
58  #define EGS_EXTENDED_SHAPE_EXPORT
59  #define EGS_EXTENDED_SHAPE_LOCAL
60  #endif
61 
62 #endif
63 
87 class EGS_EXTENDED_SHAPE_EXPORT EGS_ExtendedShape : public EGS_BaseShape {
88 
89 public:
90 
91  EGS_ExtendedShape(EGS_BaseShape *Shape, EGS_Float H1, EGS_Float H2,
92  const string &Name="",EGS_ObjectFactory *f=0) :
93  EGS_BaseShape(Name,f), shape(Shape), h1(H1), h2(H2), dh(h2-h1) {
94  if (shape) {
95  shape->ref();
96  otype = "Extended ";
97  otype += shape->getObjectType();
98  }
99  else {
100  otype = "Invalid ExtendedShape";
101  }
102  };
103  ~EGS_ExtendedShape() {
105  };
107  EGS_Vector v(shape->getPoint(rndm));
108  v.z += h1 + dh*rndm->getUniform();
109  return v;
110  };
111 
112 protected:
113 
114  EGS_BaseShape *shape;
115  EGS_Float h1, h2, dh;
116 
117 };
118 
119 #endif
An extended shape.
A class representing 3D vectors.
Definition: egs_vector.h:56
static void deleteObject(EGS_Object *o)
Delete an object.
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Definition: egs_shapes.h:112
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
EGS_Float z
z-component
Definition: egs_vector.h:62
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
An object factory.
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
Definition: egs_rndm.h:103
EGS_BaseShape(const string &Name="", EGS_ObjectFactory *f=0)
Construct a shape named Name.
Definition: egs_shapes.h:117