GGEMS  1.1
GPU GEant4-based Monte Carlo Simulations
GGEMSVoxelizedPhantom.cc
Go to the documentation of this file.
1 // ************************************************************************
2 // * This file is part of GGEMS. *
3 // * *
4 // * GGEMS is free software: you can redistribute it and/or modify *
5 // * it under the terms of the GNU General Public License as published by *
6 // * the Free Software Foundation, either version 3 of the License, or *
7 // * (at your option) any later version. *
8 // * *
9 // * GGEMS is distributed in the hope that it will be useful, *
10 // * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 // * GNU General Public License for more details. *
13 // * *
14 // * You should have received a copy of the GNU General Public License *
15 // * along with GGEMS. If not, see <https://www.gnu.org/licenses/>. *
16 // * *
17 // ************************************************************************
18 
35 
39 
40 GGEMSVoxelizedPhantom::GGEMSVoxelizedPhantom(std::string const& voxelized_phantom_name)
41 : GGEMSNavigator(voxelized_phantom_name),
42  voxelized_phantom_filename_(""),
43  range_data_filename_("")
44 {
45  GGcout("GGEMSVoxelizedPhantom", "GGEMSVoxelizedPhantom", 3) << "GGEMSVoxelizedPhantom creating..." << GGendl;
46 
47  GGcout("GGEMSVoxelizedPhantom", "GGEMSVoxelizedPhantom", 3) << "GGEMSVoxelizedPhantom created!!!" << GGendl;
48 }
49 
53 
55 {
56  GGcout("GGEMSVoxelizedPhantom", "~GGEMSVoxelizedPhantom", 3) << "GGEMSVoxelizedPhantom erasing..." << GGendl;
57 
58  GGcout("GGEMSVoxelizedPhantom", "~GGEMSVoxelizedPhantom", 3) << "GGEMSVoxelizedPhantom erased!!!" << GGendl;
59 }
60 
64 
66 {
67  GGcout("GGEMSVoxelizedPhantom", "CheckParameters", 3) << "Checking the mandatory parameters..." << GGendl;
68 
69  // Checking voxelized phantom files (mhd+range data)
70  if (voxelized_phantom_filename_.empty()) {
71  std::ostringstream oss(std::ostringstream::out);
72  oss << "You have to set a mhd file containing the voxelized phantom!!!";
73  GGEMSMisc::ThrowException("GGEMSVoxelizedPhantom", "CheckParameters", oss.str());
74  }
75 
76  // Checking the phantom name
77  if (range_data_filename_.empty()) {
78  std::ostringstream oss(std::ostringstream::out);
79  oss << "You have to set a file with the range to material data!!!";
80  GGEMSMisc::ThrowException("GGEMSVoxelizedPhantom", "CheckParameters", oss.str());
81  }
82 }
83 
87 
89 {
90  GGcout("GGEMSVoxelizedPhantom", "Initialize", 3) << "Initializing a GGEMS voxelized phantom..." << GGendl;
91 
93 
94  // Getting the current number of registered solid
96 
97  // Get the number of already registered buffer
98  GGsize number_of_registered_solids = navigator_manager.GetNumberOfRegisteredSolids();
99 
100  // Allocation of memory for solid, 1 solid in case of voxelized phantom
101  solids_ = new GGEMSSolid*[1];
102  number_of_solids_ = 1;
103 
104  // Initializing voxelized solid for geometric navigation
105  if (is_dosimetry_mode_) {
107  }
108  else {
110  }
111 
112  // Enabling tracking if necessary
114 
115  // Load voxelized phantom from MHD file and storing materials
117 
118  // Perform rotation before position
121 
122  for (GGsize j = 0; j < number_activated_devices_; ++j) {
123  solids_[0]->SetSolidID<GGEMSVoxelizedSolidData>(number_of_registered_solids, j);
124  // Store the transformation matrix in solid object
126  }
127 
128  // Initialize parent class
130 
131  // Checking if dosimetry mode activated
133 }
134 
138 
140 {
141  if (is_dosimetry_mode_) {
142  GGcout("GGEMSVoxelizedPhantom", "SaveResults", 2) << "Saving dosimetry results in MHD format..." << GGendl;
143 
144  // Compute dose and save results
146  }
147 }
148 
152 
153 void GGEMSVoxelizedPhantom::SetPhantomFile(std::string const& voxelized_phantom_filename, std::string const& range_data_filename)
154 {
155  voxelized_phantom_filename_ = voxelized_phantom_filename;
156  range_data_filename_ = range_data_filename;
157 }
158 
162 
163 GGEMSVoxelizedPhantom* create_ggems_voxelized_phantom(char const* voxelized_phantom_name)
164 {
165  return new(std::nothrow) GGEMSVoxelizedPhantom(voxelized_phantom_name);
166 }
167 
171 
172 void set_phantom_file_ggems_voxelized_phantom(GGEMSVoxelizedPhantom* voxelized_phantom, char const* phantom_filename, char const* range_data_filename)
173 {
174  voxelized_phantom->SetPhantomFile(phantom_filename, range_data_filename);
175 }
176 
180 
181 void set_position_ggems_voxelized_phantom(GGEMSVoxelizedPhantom* voxelized_phantom, GGfloat const position_x, GGfloat const position_y, GGfloat const position_z, char const* unit)
182 {
183  voxelized_phantom->SetPosition(position_x, position_y, position_z, unit);
184 }
185 
189 
190 void set_rotation_ggems_voxelized_phantom(GGEMSVoxelizedPhantom* voxelized_phantom, GGfloat const rx, GGfloat const ry, GGfloat const rz, char const* unit)
191 {
192  voxelized_phantom->SetRotation(rx, ry, rz, unit);
193 }
GGEMSNavigatorManager::GetNumberOfRegisteredSolids
GGsize GetNumberOfRegisteredSolids(void) const
get the number of current registered solid
Definition: GGEMSNavigatorManager.hh:158
GGEMSNavigator::Initialize
virtual void Initialize(void)
Definition: GGEMSNavigator.cc:198
GGEMSVoxelizedSolidData_t
Structure storing the stack of data for voxelized solid.
Definition: GGEMSVoxelizedSolidData.hh:41
GGEMSNavigator::solids_
GGEMSSolid ** solids_
Definition: GGEMSNavigator.hh:255
GGEMSNavigator::is_update_pos_
bool is_update_pos_
Definition: GGEMSNavigator.hh:247
GGEMSVoxelizedPhantom::Initialize
void Initialize(void) override
Initialize the voxelized phantom.
Definition: GGEMSVoxelizedPhantom.cc:88
GGEMSSolid
GGEMS class for solid informations.
Definition: GGEMSSolid.hh:48
GGEMSDosimetryCalculator.hh
Class providing tools storing and computing dose in phantom.
GGEMSVoxelizedPhantom.hh
Child GGEMS class handling voxelized phantom.
GGEMSVoxelizedPhantom::~GGEMSVoxelizedPhantom
~GGEMSVoxelizedPhantom(void)
GGEMSVoxelizedPhantom destructor.
Definition: GGEMSVoxelizedPhantom.cc:54
GGEMSDosimetryCalculator::SaveResults
void SaveResults(void) const
save results (dose images)
Definition: GGEMSDosimetryCalculator.cc:472
GGEMSNavigator::is_dosimetry_mode_
bool is_dosimetry_mode_
Definition: GGEMSNavigator.hh:262
GGEMSVoxelizedSolid
GGEMS class for voxelized solid.
Definition: GGEMSVoxelizedSolid.hh:42
GGEMSNavigatorManager::GetInstance
static GGEMSNavigatorManager & GetInstance(void)
Create at first time the Singleton.
Definition: GGEMSNavigatorManager.hh:60
GGsize
#define GGsize
Definition: GGEMSTypes.hh:252
GGEMSVoxelizedPhantom::SetPhantomFile
void SetPhantomFile(std::string const &voxelized_phantom_filename, std::string const &range_data_filename)
set the mhd filename for voxelized phantom and the range data file
Definition: GGEMSVoxelizedPhantom.cc:153
GGEMSVoxelizedPhantom::voxelized_phantom_filename_
std::string voxelized_phantom_filename_
Definition: GGEMSVoxelizedPhantom.hh:109
GGEMSNavigator::dose_calculator_
GGEMSDosimetryCalculator * dose_calculator_
Definition: GGEMSNavigator.hh:261
GGEMSSolid::EnableTracking
void EnableTracking(void)
Enabling tracking infos during simulation.
Definition: GGEMSSolid.cc:125
GGEMSVoxelizedPhantom::GGEMSVoxelizedPhantom
GGEMSVoxelizedPhantom(std::string const &voxelized_phantom_name)
GGEMSVoxelizedPhantom constructor.
Definition: GGEMSVoxelizedPhantom.cc:40
GGEMSNavigatorManager
GGEMS class handling the navigators (detector + phantom) in GGEMS.
Definition: GGEMSNavigatorManager.hh:42
set_rotation_ggems_voxelized_phantom
void set_rotation_ggems_voxelized_phantom(GGEMSVoxelizedPhantom *voxelized_phantom, GGfloat const rx, GGfloat const ry, GGfloat const rz, char const *unit)
Set the rotation of the voxelized phantom around local axis.
Definition: GGEMSVoxelizedPhantom.cc:190
GGEMSNavigator::number_activated_devices_
GGsize number_activated_devices_
Definition: GGEMSNavigator.hh:264
GGEMSSolid::SetSolidID
void SetSolidID(GGsize const &solid_id, GGsize const &thread_index)
set the global solid index
Definition: GGEMSSolid.hh:239
create_ggems_voxelized_phantom
GGEMSVoxelizedPhantom * create_ggems_voxelized_phantom(char const *voxelized_phantom_name)
Get the GGEMSVoxelizedPhantom pointer for python user.
Definition: GGEMSVoxelizedPhantom.cc:163
GGEMSVoxelizedPhantom::range_data_filename_
std::string range_data_filename_
Definition: GGEMSVoxelizedPhantom.hh:110
set_position_ggems_voxelized_phantom
void set_position_ggems_voxelized_phantom(GGEMSVoxelizedPhantom *voxelized_phantom, GGfloat const position_x, GGfloat const position_y, GGfloat const position_z, char const *unit)
set the position of the voxelized phantom in X, Y and Z
Definition: GGEMSVoxelizedPhantom.cc:181
GGEMSVoxelizedPhantom::CheckParameters
void CheckParameters(void) const override
Definition: GGEMSVoxelizedPhantom.cc:65
GGEMSVoxelizedPhantom
Child GGEMS class handling voxelized phantom.
Definition: GGEMSVoxelizedPhantom.hh:40
GGEMSVoxelizedPhantom::SaveResults
void SaveResults(void) override
save all results from solid
Definition: GGEMSVoxelizedPhantom.cc:139
GGEMSDosimetryCalculator::Initialize
void Initialize(void)
Initialize dosimetry calculator class.
Definition: GGEMSDosimetryCalculator.cc:374
GGEMSNavigator::number_of_solids_
GGsize number_of_solids_
Definition: GGEMSNavigator.hh:256
GGEMSNavigator
Parent GGEMS class for navigator.
Definition: GGEMSNavigator.hh:55
GGEMSSolid::SetPosition
void SetPosition(GGfloat3 const &position_xyz)
set a position for solid
Definition: GGEMSSolid.cc:143
GGcout
GGEMSStream GGcout
Definition: GGEMSPrint.cc:34
GGEMSSolid::UpdateTransformationMatrix
virtual void UpdateTransformationMatrix(GGsize const &thread_index)=0
Update transformation matrix for solid object.
set_phantom_file_ggems_voxelized_phantom
void set_phantom_file_ggems_voxelized_phantom(GGEMSVoxelizedPhantom *voxelized_phantom, char const *phantom_filename, char const *range_data_filename)
set the filename of voxelized phantom and the range data file
Definition: GGEMSVoxelizedPhantom.cc:172
GGEMSNavigator::materials_
GGEMSMaterials * materials_
Definition: GGEMSNavigator.hh:257
GGEMSNavigator::is_tracking_
bool is_tracking_
Definition: GGEMSNavigator.hh:250
GGEMSSolid::Initialize
virtual void Initialize(GGEMSMaterials *materials)=0
Initialize solid for geometric navigation.
GGEMSNavigator::SetRotation
void SetRotation(GGfloat const &rx, GGfloat const &ry, GGfloat const &rz, std::string const &unit="deg")
Set the rotation of the global navigator around global axis.
Definition: GGEMSNavigator.cc:136
GGEMSDoseParams.hh
Structure storing dosimetry infos.
GGEMSVoxelizedSolid.hh
GGEMS class for voxelized solid.
GGendl
#define GGendl
overload C++ std::endl
Definition: GGEMSPrint.hh:60
GGEMSNavigator::is_update_rot_
bool is_update_rot_
Definition: GGEMSNavigator.hh:248
GGEMSNavigator::position_xyz_
GGfloat3 position_xyz_
Definition: GGEMSNavigator.hh:244
GGEMSNavigator::rotation_xyz_
GGfloat3 rotation_xyz_
Definition: GGEMSNavigator.hh:245
GGEMSNavigator::SetPosition
void SetPosition(GGfloat const &position_x, GGfloat const &position_y, GGfloat const &position_z, std::string const &unit="mm")
set the position of the global navigator in X, Y and Z
Definition: GGEMSNavigator.cc:124
GGEMSMHDImage.hh
I/O class handling MHD image file.
GGEMSSolid::SetRotation
void SetRotation(GGfloat3 const &rotation_xyz)
set a rotation for solid
Definition: GGEMSSolid.hh:108
GGEMSMisc::ThrowException
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
Definition: GGEMSTools.cc:61
GGfloat
#define GGfloat
Definition: GGEMSTypes.hh:273