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 # Marc Chamberland
30 #
31 ###############################################################################
32 */
33 
34 
41 #include "egs_gtransformed.h"
42 #include "egs_input.h"
43 #include "egs_functions.h"
44 
46  egsWarning("EGS_TransformedGeometry::setMedia: don't use this method. Use the\n"
47  " setMedia() methods of the geometry objects that make up this geometry\n");
48 }
49 
50 void EGS_TransformedGeometry::setRelativeRho(int start, int end, EGS_Float rho) {
51  setRelativeRho(0);
52 }
53 
54 void EGS_TransformedGeometry::setRelativeRho(EGS_Input *) {
55  egsWarning("EGS_TransformedGeometry::setRelativeRho(): don't use this "
56  "method. Use the \n setRelativeRho() methods of the underlying "
57  "geometry\n");
58 }
59 
60 void EGS_TransformedGeometry::setBScaling(int start, int end, EGS_Float rho) {
61  setBScaling(0);
62 }
63 
64 void EGS_TransformedGeometry::setBScaling(EGS_Input *) {
65  egsWarning("EGS_TransformedGeometry::setBScaling(): don't use this "
66  "method. Use the \n setBScaling() methods of the underlying "
67  "geometry\n");
68 }
69 
70 extern "C" {
71 
72  EGS_GTRANSFORMED_EXPORT EGS_BaseGeometry *createGeometry(EGS_Input *input) {
73  EGS_BaseGeometry *g = 0;
74  EGS_Input *ij = input->takeInputItem("geometry",false);
75  if (ij) {
77  delete ij;
78  if (!g) {
79  egsWarning("createGeometry(gtransformed): got a null pointer"
80  " as a geometry?\n");
81  return 0;
82  }
83  }
84  if (!g) {
85  string gname;
86  int err = input->getInput("my geometry",gname);
87  if (err) {
88  egsWarning(
89  "createGeometry(gtransformed): my geometry must be defined\n"
90  " either inline or using 'my geometry = some_name'\n");
91  return 0;
92  }
94  if (!g) {
95  egsWarning("createGeometry(gtransformed): no geometry named %s"
96  " is defined\n",gname.c_str());
97  return 0;
98  }
99  }
100  g->ref();
102  EGS_BaseGeometry *result;
103  if (!t) {
104  egsWarning("createGeometry(gtransformed): null transformation."
105  " I hope you know what you are doing\n");
107  }
108  else {
109  if (t->isI()) egsWarning("createGeometry(gtransformed): "
110  "unity transformation. I hope you know what you are doing\n");
111  result = new EGS_TransformedGeometry(g,*t);
112  delete t;
113  }
114  result->setName(input);
115  result->setBoundaryTolerance(input);
116  result->setLabels(input);
117  return result;
118 
119  }
120 
121 
122  void EGS_TransformedGeometry::getLabelRegions(const string &str, vector<int> &regs) {
123 
124  // label defined in the geometry being transformed
125  g->getLabelRegions(str, regs);
126 
127  // label defined in self (transformation input block)
129 
130  }
131 
132 
133 }
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 ...
bool isI() const
Returns true if the object is a unity transformation, false otherwise.
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
static EGS_BaseGeometry * createSingleGeometry(EGS_Input *inp)
Create a single geometry from the input inp.
virtual void getLabelRegions(const string &str, vector< int > &regs)
Get the list of all regions labeled with str.
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.
int ref()
Increase the reference count to this geometry.
static EGS_BaseGeometry * getGeometry(const string &Name)
Get a pointer to the geometry named Name.
void setBoundaryTolerance(EGS_Input *inp)
Set the value of the boundary tolerance 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
A transformed geometry.
void setMedia(EGS_Input *inp, int, const int *)
Don't define media in the transformed geometry definition.
EGS_BaseGeometry * g
The geometry being transformed.
Global egspp functions header file.
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Definition: egs_glib.cpp:57
A transformed geometry: header.
EGS_Input class header file.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.