EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
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 #
31 ###############################################################################
32 #
33 # egs_glib was developed for the Carleton Laboratory for Radiotherapy Physics.
34 #
35 ###############################################################################
36 */
37 
38 
44 #include <map>
45 #include <iostream>
46 #include <istream>
47 #include <sstream>
48 #include <fstream>
49 #include "egs_input.h"
50 #include "egs_functions.h"
51 #include "egs_glib.h"
52 
53 
54 extern "C" {
55 
57  EGS_GLIB_EXPORT EGS_BaseGeometry *createGeometry(EGS_Input *input) {
58 
59  if (!input) {
60  egsWarning("createGeometry(egs_glib): null input?\n");
61  return 0;
62  }
63 
64 
65  EGS_Input *egs_geom_input = input->takeInputItem("geometry definition");
66  if (!egs_geom_input) {
67  egsWarning("createGeometry(egs_glib): missing `geometry definition` input\n");
68  return 0;
69  }
70 
71  EGS_BaseGeometry *final = EGS_BaseGeometry::createGeometry(egs_geom_input);
72 
73  delete egs_geom_input;
74 
75  if (!final) {
76  egsWarning("createGeometry(egs_glib): unable to create geometry\n");
77  return 0;
78  }
79 
80  final->setName(input);
81 
82  return final;
83 
84  }
85 
86 }
A small shim for loading geometries from files.
EGS_Input class header file.
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.
static EGS_BaseGeometry * createGeometry(EGS_Input *)
Create a geometry (or geometries) from a given 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(const string &key, bool self=true)
Get the property named key.
Definition: egs_input.cpp:226
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.