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