EGS Brachy
An egs++ user code for rapid brachytherapy calculations
Loading...
Searching...
No Matches
/Users/marc/Developer/EGSnrc/HEN_HOUSE/user_codes/egs_brachy/egs_brachy/ginfo.h
Go to the documentation of this file.
1/*
2################################################################################
3#
4# egs_brachy ginfo.h
5# Copyright (C) 2016 Rowan Thomson, Dave Rogers, Randle Taylor, and Marc
6# Chamberland
7#
8# This file is part of egs_brachy
9#
10# egs_brachy is free software: you can redistribute it and/or modify it
11# under the terms of the GNU Affero General Public License as published
12# by the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# egs_brachy is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# Affero General Public License for more details:
19# <http://www.gnu.org/licenses/>.
20#
21################################################################################
22#
23# When egs_brachy is used for publications, please cite our paper:
24# M. J. P. Chamberland, R. E. P. Taylor, D. W. O. Rogers, and R. M. Thomson,
25# egs brachy: a versatile and fast Monte Carlo code for brachytherapy,
26# Phys. Med. Biol. 61, 8214-8231 (2016).
27#
28################################################################################
29#
30# Author: Randle Taylor, 2016
31#
32# Contributors: Marc Chamberland
33# Dave Rogers
34# Rowan Thomson
35#
36################################################################################
37*/
38
44#ifndef EB_GINFO_
45#define EB_GINFO_
46
47#include <map>
48#include <set>
49#include <cstdlib>
50#include <algorithm>
51
52#include "egs_functions.h"
53#include "egs_input.h"
54#include "phantom.h"
55
56
57// Tree node used for organizing/sorting geometries and their children
58class Node {
59public:
60 string name;
61 vector<Node> children;
62
63 Node(string n, vector<Node> children) {
64 name = n;
65 for (size_t i=0; i < children.size(); i++) {
66 addNode(children[i]);
67 }
68
69 };
70
71 void addNode(Node node) {
72 children.push_back(node);
73 }
74
75};
76
77
79typedef pair<EGS_BaseGeometry *, int> GeomRegT;
80
81
84
85 string name;
86 string type;
87 vector<string> children;
88 int nreg;
89 int start;
90 int end;
92};
93
95typedef map<string, GeomRegionInfo> GeomRegionInfoMapT;
96
97
99class GeomInfo {
100
101 vector<int> global_ir_to_phant;
103 //
106
107
108 vector<EGS_BaseGeometry *> global_ir_to_geom;
110
117 //
119
120 vector<string> getChildren(string name, EGS_Input *inp);
121
122 void getGeomRegs(Node, vector<GeomRegionInfo> &, int);
124
125 Node build_tree(string root, vector<Node> &children);
126
127public:
128
129
132 vector<string> phantom_names;
134 vector<string> source_names;
138 int ngeom;
140
141
144 if (geom_tree) {
145 delete geom_tree;
146 }
147 }
148
149 vector<GeomRegionInfo> ordered_geom_data;
151 map<EGS_BaseGeometry *, GeomRegionInfo> geom_to_regioninfo;
153 vector<EB_Phantom *> phantom_geoms;
154
163 int initializeFromInput(EGS_Input *input);
164
171 void setGeometryIndexes(EGS_BaseGeometry *sim_geom);
172
175 int phantomFromRegion(int ir);
176
178 GeomRegT globalToLocal(int ir);
179
181 int globalToLocalReg(int ir);
182
183 /* \brief convert an (EGS_BaseGeometry, local_reg_num) to global region number */
185
186
187 /* \brief return true if global reg is inside a phantom object */
188 bool isPhantom(int ir);
189
190 /* \brief return true if global reg is inside the first source (a.ka.
191 * generator) object */
192 bool isSource(int ir);
193
194 /* \brief print information about geometries and their region number*/
195 void printInfo();
196
197};
198
199#endif
a container for organizing meta data about the geometries
Definition ginfo.h:99
map< EGS_BaseGeometry *, GeomRegionInfo > geom_to_regioninfo
Definition ginfo.h:151
void getGeomRegs(Node, vector< GeomRegionInfo > &, int)
Definition ginfo.cpp:417
string source_envelope_name
Definition ginfo.h:131
vector< int > global_ir_to_local_ir
pointer for the geometry it belongs to
Definition ginfo.h:111
GeomRegionInfoMapT gmap
Definition ginfo.h:118
vector< GeomRegionInfo > ordered_geom_data
Definition ginfo.h:149
void setGeomMap()
vector< EGS_BaseGeometry * > global_ir_to_geom
the source geometry index or -1 if not a source
Definition ginfo.h:108
vector< EB_Phantom * > phantom_geoms
pointers to all of the phantom objects
Definition ginfo.h:153
bool isSource(int ir)
Definition ginfo.cpp:503
int phantomFromRegion(int ir)
return the phantom index for this region number or -1 if region is not in a phantom
Definition ginfo.cpp:508
int localToGlobal(GeomRegT)
Definition ginfo.cpp:492
GeomInfo()
Definition ginfo.h:142
int initializeFromInput(EGS_Input *input)
Initialize the GeomInfo structure (ginfo) This function reads the geometry input block,...
Definition ginfo.cpp:85
Node build_tree(string root, vector< Node > &children)
Definition ginfo.cpp:71
vector< int > global_ir_to_source
the phantoms geometry index or -1 if not a phant
Definition ginfo.h:104
string sim_geom_name
Definition ginfo.h:130
~GeomInfo()
Definition ginfo.h:143
int ngeom
total number of geometries created
Definition ginfo.h:138
bool isPhantom(int ir)
Definition ginfo.cpp:498
void setGeometryIndexes(EGS_BaseGeometry *sim_geom)
Setup all arrays required to decide which geometry/phantom a region is in and whether or not we are s...
Definition ginfo.cpp:441
vector< int > global_ir_to_phant
array of size nreg mapping global region number to
Definition ginfo.h:101
void printInfo()
Definition ginfo.cpp:513
GeomRegT globalToLocal(int ir)
convert global region number to (EGS_BaseGeometry, local_reg_num) pair
Definition ginfo.cpp:479
int nreg_total
total number of regions in the simulation geometry
Definition ginfo.h:139
Node * geom_tree
Definition ginfo.h:136
int globalToLocalReg(int ir)
convert global region number to local_reg_num
Definition ginfo.cpp:487
vector< string > getChildren(string name, EGS_Input *inp)
Definition ginfo.cpp:332
vector< string > source_names
Definition ginfo.h:134
vector< string > phantom_names
Definition ginfo.h:132
Definition ginfo.h:58
void addNode(Node node)
Definition ginfo.h:71
string name
Definition ginfo.h:60
vector< Node > children
Definition ginfo.h:61
Node(string n, vector< Node > children)
Definition ginfo.h:63
map< string, GeomRegionInfo > GeomRegionInfoMapT
a mapping from geometry name to information about that geometry
Definition ginfo.h:95
pair< EGS_BaseGeometry *, int > GeomRegT
pair of geometry and local region number
Definition ginfo.h:79
Header file for phantom objects.
a struct to contain elementary information aboud a geometry
Definition ginfo.h:83
vector< string > children
Definition ginfo.h:87
string type
Definition ginfo.h:86
string name
Definition ginfo.h:85