EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_transformed_source.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ transformed source
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 #include "egs_transformed_source.h"
38 #include "egs_input.h"
39 
41  EGS_ObjectFactory *f) : EGS_BaseSource(input,f), source(0), T(0) {
42  EGS_Input *isource = input->takeInputItem("source",false);
43  if (isource) {
45  delete isource;
46  }
47  if (!source) {
48  string sname;
49  int err = input->getInput("source name",sname);
50  if (err)
51  egsWarning("EGS_TransformedSource: missing/wrong inline source "
52  "definition and missing wrong 'source name' input\n");
53  else {
55  if (!source) egsWarning("EGS_TransformedSource: a source named %s"
56  " does not exist\n");
57  }
58  }
60  setUp(t);
61  delete t;
62 }
63 
64 void EGS_TransformedSource::setUp(EGS_AffineTransform *t) {
65  setTransformation(t);
66  otype = "EGS_TransformedSource";
67  if (!isValid()) {
68  description = "Invalid transformed source";
69  }
70  else {
71  description = "Transformed ";
73  source->ref();
74  }
75 }
76 
77 extern "C" {
78 
79  EGS_TRANSFORMED_SOURCE_EXPORT EGS_BaseSource *createSource(EGS_Input *input,
80  EGS_ObjectFactory *f) {
81  return
82  createSourceTemplate<EGS_TransformedSource>(input,f,"transformed source");
83  }
84 
85 }
static EGS_BaseSource * createSource(EGS_Input *)
Create sources from the information pointed to by input.
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.
A class providing affine transformations.
EGS_Input class header file.
const char * getSourceDescription() const
Get a short description of this source.
int ref()
Increase the reference count to this object.
An object factory.
static EGS_BaseSource * getSource(const string &Name)
Get a pointer to the source named Name.
static EGS_AffineTransform * getTransformation(EGS_Input *inp)
Constructs an affine transformation object from the input pointed to by inp and returns a pointer to ...
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
string otype
The object type.
EGS_Input * takeInputItem(const string &key, bool self=true)
Get the property named key.
Definition: egs_input.cpp:226
int getInput(const string &key, vector< string > &values) const
Assign values to an array of strings from an input identified by key.
Definition: egs_input.cpp:338
Base source class. All particle sources must be derived from this class.
string description
A short source description.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.