EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_box.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ box geometry
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: Frederic Tessier
27 # Marc Chamberland
28 #
29 ###############################################################################
30 */
31 
32 
38 #include "egs_box.h"
39 #include "egs_input.h"
40 
41 void EGS_Box::printInfo() const {
43  egsInformation(" box size = %g %g %g\n",ax,ay,az);
44  egsInformation("=======================================================\n");
45 }
46 
47 string EGS_Box::type("EGS_Box");
48 
49 static char EGS_BOX_LOCAL ebox_message1[] = "createGeometry(box): %s\n";
50 static char EGS_BOX_LOCAL ebox_message2[] = "null input?";
51 static char EGS_BOX_LOCAL ebox_message3[] = "wrong/missing 'box size' input?";
52 static char EGS_BOX_LOCAL ebox_message4[] =
53  "expecting 1 or 3 float inputs for 'box size'";
54 static char EGS_BOX_LOCAL ebox_key1[] = "box size";
55 
56 extern "C" {
57 
58  EGS_BOX_EXPORT EGS_BaseGeometry *createGeometry(EGS_Input *input) {
59  if (!input) {
60  egsWarning(ebox_message1,ebox_message2);
61  return 0;
62  }
63  vector<EGS_Float> s;
64  int err = input->getInput(ebox_key1,s);
65  if (err) {
66  egsWarning(ebox_message1,ebox_message3);
67  return 0;
68  }
70  EGS_Box *result;
71  if (s.size() == 1) {
72  result = new EGS_Box(s[0],t);
73  }
74  else if (s.size() == 3) {
75  result = new EGS_Box(s[0],s[1],s[2],t);
76  }
77  else {
78  egsWarning(ebox_message1,ebox_message4);
79  if (t) {
80  delete t;
81  }
82  return 0;
83  }
84  if (t) {
85  delete t;
86  }
87  result->setName(input);
88  result->setBoundaryTolerance(input);
89  result->setMedia(input);
90  result->setLabels(input);
91  return result;
92  }
93 
94 }
A class providing affine transformations.
static EGS_AffineTransform * getTransformation(EGS_Input *inp)
Constructs an affine transformation object from the input pointed to by inp and returns a pointer to ...
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
void setMedia(EGS_Input *inp)
Set the media in the geometry from the input pointed to by inp.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
int setLabels(EGS_Input *input)
Set the labels from an input block.
virtual void printInfo() const
Print information about this geometry.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance from the input inp.
A box geometry.
Definition: egs_box.h:104
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
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
A box geometry: header.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Definition: egs_glib.cpp:57
EGS_Input class header file.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.