EGSnrc C++ class library
Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs++
geometry
egs_glib
egs_glib.cpp
Go to the documentation of this file.
1
/*
2
###############################################################################
3
#
4
# EGSnrc egs++ glib geometry
5
# Copyright (C) 2016 Randle E. P. Taylor, Rowan M. Thomson,
6
# Marc J. P. Chamberland, D. W. O. Rogers
7
#
8
# This file is part of EGSnrc.
9
#
10
# EGSnrc is free software: you can redistribute it and/or modify it under
11
# the terms of the GNU Affero General Public License as published by the
12
# Free Software Foundation, either version 3 of the License, or (at your
13
# option) any later version.
14
#
15
# EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
16
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
18
# more details.
19
#
20
# You should have received a copy of the GNU Affero General Public License
21
# along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
22
#
23
###############################################################################
24
#
25
# Author: Randle Taylor, 2016
26
#
27
# Contributors: Marc Chamberland
28
# Rowan Thomson
29
# Dave Rogers
30
# Hannah Gallop
31
#
32
###############################################################################
33
#
34
# egs_glib was developed for the Carleton Laboratory for Radiotherapy Physics.
35
#
36
###############################################################################
37
*/
38
39
45
#include <map>
46
#include <iostream>
47
#include <istream>
48
#include <sstream>
49
#include <fstream>
50
#include "
egs_input.h
"
51
#include "
egs_functions.h
"
52
#include "
egs_glib.h
"
53
54
static
bool
EGS_GLIB_LOCAL inputSet =
false
;
55
56
extern
"C"
{
57
58
static
void
setInputs() {
59
inputSet =
true
;
60
61
setBaseGeometryInputs(
false
);
62
63
geomBlockInput->getSingleInput(
"library"
)->setValues({
"egs_glib"
});
64
65
// Format: name, isRequired, description, vector string of allowed values
66
geomBlockInput->addSingleInput(
"include file"
,
true
,
"The path to some geometry."
);
67
}
68
69
EGS_GLIB_EXPORT
string
getExample() {
70
string
example;
71
example = {
72
R
"(
73
# Example of egs_glib
74
#:start geometry:
75
name = my_glib
76
library = egs_glib
77
include file = /path to some external file/
78
:stop geometry:
79
)"};
80
return
example;
81
}
82
83
EGS_GLIB_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
84
if
(!inputSet) {
85
setInputs();
86
}
87
return
geomBlockInput;
88
}
89
91
EGS_GLIB_EXPORT
EGS_BaseGeometry
*
createGeometry
(
EGS_Input
*input) {
92
93
if
(!input) {
94
egsWarning
(
"createGeometry(egs_glib): null input?\n"
);
95
return
0;
96
}
97
98
99
EGS_Input
*egs_geom_input = input->
takeInputItem
(
"geometry definition"
);
100
if
(!egs_geom_input) {
101
egsWarning
(
"createGeometry(egs_glib): missing `geometry definition` input\n"
);
102
return
0;
103
}
104
105
EGS_BaseGeometry
*
final
=
EGS_BaseGeometry::createGeometry
(egs_geom_input);
106
107
delete
egs_geom_input;
108
109
if
(!
final
) {
110
egsWarning
(
"createGeometry(egs_glib): unable to create geometry\n"
);
111
return
0;
112
}
113
114
final
->setName(input);
115
116
return
final
;
117
118
}
119
120
}
EGS_BaseGeometry
Base geometry class. Every geometry class must be derived from EGS_BaseGeometry.
Definition:
egs_base_geometry.h:111
EGS_BaseGeometry::createGeometry
static EGS_BaseGeometry * createGeometry(EGS_Input *)
Create a geometry (or geometries) from a given input.
Definition:
egs_base_geometry.cpp:551
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::takeInputItem
EGS_Input * takeInputItem(const string &key, bool self=true)
Get the property named key.
Definition:
egs_input.cpp:229
egs_functions.h
Global egspp functions header file.
createGeometry
EGS_GLIB_EXPORT EGS_BaseGeometry * createGeometry(EGS_Input *input)
Definition:
egs_glib.cpp:84
egs_glib.h
A small shim for loading geometries from files.
egs_input.h
EGS_Input class header file.
egsWarning
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
Definition:
egs_functions.cpp:136
Generated by
1.9.1