EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_gtransformed.cpp
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ gtransformed 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 # Ernesto Mainegra-Hing
28 # Hubert Ho
29 #
30 ###############################################################################
31 */
32 
33 
40 #include "egs_gtransformed.h"
41 #include "egs_input.h"
42 #include "egs_functions.h"
43 
45  egsWarning("EGS_TransformedGeometry::setMedia: don't use this method. Use the\n"
46  " setMedia() methods of the geometry objects that make up this geometry\n");
47 }
48 
49 void EGS_TransformedGeometry::setRelativeRho(int start, int end, EGS_Float rho) {
50  setRelativeRho(0);
51 }
52 
53 void EGS_TransformedGeometry::setRelativeRho(EGS_Input *) {
54  egsWarning("EGS_TransformedGeometry::setRelativeRho(): don't use this "
55  "method. Use the \n setRelativeRho() methods of the underlying "
56  "geometry\n");
57 }
58 
59 void EGS_TransformedGeometry::setBScaling(int start, int end, EGS_Float rho) {
60  setBScaling(0);
61 }
62 
63 void EGS_TransformedGeometry::setBScaling(EGS_Input *) {
64  egsWarning("EGS_TransformedGeometry::setBScaling(): don't use this "
65  "method. Use the \n setBScaling() methods of the underlying "
66  "geometry\n");
67 }
68 
69 extern "C" {
70 
71  EGS_GTRANSFORMED_EXPORT EGS_BaseGeometry *createGeometry(EGS_Input *input) {
72  EGS_BaseGeometry *g = 0;
73  EGS_Input *ij = input->takeInputItem("geometry",false);
74  if (ij) {
76  delete ij;
77  if (!g) {
78  egsWarning("createGeometry(gtransformed): got a null pointer"
79  " as a geometry?\n");
80  return 0;
81  }
82  }
83  if (!g) {
84  string gname;
85  int err = input->getInput("my geometry",gname);
86  if (err) {
87  egsWarning(
88  "createGeometry(gtransformed): my geometry must be defined\n"
89  " either inline or using 'my geometry = some_name'\n");
90  return 0;
91  }
93  if (!g) {
94  egsWarning("createGeometry(gtransformed): no geometry named %s"
95  " is defined\n",gname.c_str());
96  return 0;
97  }
98  }
99  g->ref();
101  EGS_BaseGeometry *result;
102  if (!t) {
103  egsWarning("createGeometry(gtransformed): null transformation."
104  " I hope you know what you are doing\n");
106  }
107  else {
108  if (t->isI()) egsWarning("createGeometry(gtransformed): "
109  "unity transformation. I hope you know what you are doing\n");
110  result = new EGS_TransformedGeometry(g,*t);
111  delete t;
112  }
113  result->setName(input);
114  result->setBoundaryTolerance(input);
115  result->setLabels(input);
116  return result;
117 
118  }
119 
120 
121  void EGS_TransformedGeometry::getLabelRegions(const string &str, vector<int> &regs) {
122 
123  // label defined in the geometry being transformed
124  g->getLabelRegions(str, regs);
125 
126  // label defined in self (transformation input block)
128 
129  }
130 
131 
132 }
void setMedia(EGS_Input *inp, int, const int *)
Don&#39;t define media in the transformed geometry definition.
A class providing affine transformations.
EGS_Input class header file.
int setLabels(EGS_Input *input)
Set the labels from an input block.
Global egspp functions header file.
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.
A transformed geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
virtual void getLabelRegions(const string &str, vector< int > &regs)
Get the list of all regions labeled with str.
bool isI() const
Returns true if the object is a unity transformation, false otherwise.
void setName(EGS_Input *inp)
Set the name of the geometry from the input inp.
A transformed geometry: header.
static EGS_AffineTransform * getTransformation(EGS_Input *inp)
Constructs an affine transformation object from the input pointed to by inp and returns a pointer to ...
int ref()
Increase the reference count to this geometry.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
A class for storing information in a tree-like structure of key-value pairs. This class is used throu...
Definition: egs_input.h:182
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
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.