EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Coding Examples
File List
File Members
egs++
shapes
egs_ellipse
egs_ellipse.cpp
Go to the documentation of this file.
1
/*
2
###############################################################################
3
#
4
# EGSnrc egs++ ellipse shape
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_ellipse.h
"
38
#include "
egs_input.h
"
39
#include "
egs_functions.h
"
40
41
extern
"C"
{
42
43
EGS_ELLIPSE_EXPORT
EGS_BaseShape
*createShape(
EGS_Input
*input,
44
EGS_ObjectFactory
*f) {
45
if
(!input) {
46
egsWarning
(
"createShape(ellipse): null input?\n"
);
47
return
0;
48
}
49
vector<EGS_Float> axis;
50
int
err = input->
getInput
(
"halfaxis"
,axis);
51
if
(err) {
52
egsWarning
(
"createShape(ellipse): no 'halfaxis' input\n"
);
53
return
0;
54
}
55
if
(axis.size() != 2) {
56
egsWarning
(
"createShape(ellipse): 2 instead of %d inputs expected"
57
" for keyword 'halfaxis'.\n"
,axis.size());
58
return
0;
59
}
60
vector<EGS_Float> pos;
61
err = input->
getInput
(
"midpoint"
,pos);
62
if
(err) {
63
pos.clear();
64
pos.push_back(0);
65
pos.push_back(0);
66
}
67
else
{
68
if
(pos.size() != 2) {
69
egsWarning
(
"createShape(ellipse): 2 instead of %d inputs expected"
70
" for keyword 'midpoint'. Reseting midpoint to (0,0)\n"
,
71
pos.size());
72
pos.clear();
73
pos.push_back(0);
74
pos.push_back(0);
75
}
76
}
77
EGS_EllipseShape
*shape =
new
EGS_EllipseShape
(pos[0],pos[1],
78
axis[0],axis[1],
""
,f);
79
shape->
setName
(input);
80
shape->
setTransformation
(input);
81
return
shape;
82
}
83
84
}
egs_ellipse.h
An elliptical shape.
EGS_BaseShape::setTransformation
void setTransformation(EGS_Input *inp)
Set the transformation attached to this shape.
Definition:
egs_shapes.cpp:68
egs_input.h
EGS_Input class header file.
egs_functions.h
Global egspp functions header file.
EGS_BaseShape
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
Definition:
egs_shapes.h:112
EGS_ObjectFactory
An object factory.
Definition:
egs_object_factory.h:206
EGS_EllipseShape
An elliptical shape.
Definition:
egs_ellipse.h:86
EGS_Object::setName
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
Definition:
egs_object_factory.cpp:93
EGS_Input
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::getInput
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
egsWarning
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
Definition:
egs_functions.cpp:135
Generated by
1.8.5