EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_transformed_source.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ transformed source 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: Reid Townson
27 # Blake Walters
28 #
29 ###############################################################################
30 */
31 
32 
38 #ifndef EGS_TRANSFORMED_SOURCE_
39 #define EGS_TRANSFORMED_SOURCE_
40 
41 #include "egs_vector.h"
42 #include "egs_base_source.h"
43 #include "egs_rndm.h"
44 #include "egs_shapes.h"
45 
46 
47 #ifdef WIN32
48 
49  #ifdef BUILD_TRANSFORMED_SOURCE_DLL
50  #define EGS_TRANSFORMED_SOURCE_EXPORT __declspec(dllexport)
51  #else
52  #define EGS_TRANSFORMED_SOURCE_EXPORT __declspec(dllimport)
53  #endif
54  #define EGS_TRANSFORMED_SOURCE_LOCAL
55 
56 #else
57 
58  #ifdef HAVE_VISIBILITY
59  #define EGS_TRANSFORMED_SOURCE_EXPORT __attribute__ ((visibility ("default")))
60  #define EGS_TRANSFORMED_SOURCE_LOCAL __attribute__ ((visibility ("hidden")))
61  #else
62  #define EGS_TRANSFORMED_SOURCE_EXPORT
63  #define EGS_TRANSFORMED_SOURCE_LOCAL
64  #endif
65 
66 #endif
67 
122 class EGS_TRANSFORMED_SOURCE_EXPORT EGS_TransformedSource :
123  public EGS_BaseSource {
124 
125 public:
126 
132  const string &Name="", EGS_ObjectFactory *f=0) :
133  EGS_BaseSource(Name,f), source(Source), T(0) {
134  setUp(t);
135  };
138  void setTransformation(EGS_AffineTransform *t) {
139  if (T) {
140  delete T;
141  T = 0;
142  }
143  if (t) {
144  T = new EGS_AffineTransform(*t);
145  }
146  };
147  const EGS_AffineTransform *getTransform() const {
148  return T;
149  };
151  EGS_Object::deleteObject(source);
152  if (T) {
153  delete T;
154  }
155  };
156 
157  EGS_I64 getNextParticle(EGS_RandomGenerator *rndm,
158  int &q, int &latch, EGS_Float &E, EGS_Float &wt,
159  EGS_Vector &x, EGS_Vector &u) {
160  EGS_I64 c = source->getNextParticle(rndm,q,latch,E,wt,x,u);
161  if (T) {
162  T->rotate(u);
163  T->transform(x);
164  }
165  return c;
166  };
167  EGS_Float getEmax() const {
168  return source->getEmax();
169  };
170  EGS_Float getFluence() const {
171  return source->getFluence();
172  };
173  bool storeState(ostream &data) const {
174  return source->storeState(data);
175  };
176  bool setState(istream &data) {
177  return source->setState(data);
178  };
179  bool addState(istream &data_in) {
180  return source->addState(data_in);
181  };
182  void resetCounter() {
183  source->resetCounter();
184  };
185 
186  bool isValid() const {
187  return (source != 0);
188  };
189 
190  void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun, int npar, int nchunk) {
191  source->setSimulationChunk(nstart, nrun, npar, nchunk);
192  };
193 
194  void printSampledEmissions() {
195  source->printSampledEmissions();
196  }
197 
198  vector<EGS_Ensdf *> getRadionuclideEnsdf() {
199  return source->getRadionuclideEnsdf();
200  };
201 
202 protected:
203 
206 
207  void setUp(EGS_AffineTransform *t);
208 
209 };
210 
211 #endif
A class providing affine transformations.
Base source class. All particle sources must be derived from this class.
virtual bool addState(istream &data_in)
Add data from the stream data_in to the source state.
virtual void printSampledEmissions()
Print statistics on what was sampled from the source.
virtual EGS_Float getEmax() const =0
Return the maximum energy of this source.
virtual EGS_Float getFluence() const =0
Return the fluence this source has emitted so far.
virtual void resetCounter()
Reset the source state.
virtual EGS_I64 getNextParticle(EGS_RandomGenerator *rndm, int &q, int &latch, EGS_Float &E, EGS_Float &wt, EGS_Vector &x, EGS_Vector &u)=0
Sample the next source particle from the source probability distribution.
virtual bool setState(istream &data_in)
Set the source state based on data from the stream data_in.
virtual void setSimulationChunk(EGS_I64 nstart, EGS_I64 nrun, int npar, int nchunk)
Set the next simulation chunk to start at nstart and to consist of nrun particles.
virtual vector< EGS_Ensdf * > getRadionuclideEnsdf()
Get the radionuclide ENSDF object from the source.
virtual bool storeState(ostream &data_out) const
Store the source state into the stream data_out.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
An object factory.
static void deleteObject(EGS_Object *o)
Delete an object.
Base random number generator class. All random number generators should be derived from this class.
Definition: egs_rndm.h:67
A transformed source.
EGS_BaseSource * source
The source being transformed.
EGS_TransformedSource(EGS_BaseSource *Source, EGS_AffineTransform *t, const string &Name="", EGS_ObjectFactory *f=0)
Construct a transformed source using Source as the source and t as the transformation.
EGS_AffineTransform * T
The affine transformation.
A class representing 3D vectors.
Definition: egs_vector.h:57
EGS_BaseSource class header file.
EGS_RandomGenerator class header file.
EGS_BaseShape and shape classes header file.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.