|
GGEMS
1.1
GPU GEant4-based Monte Carlo Simulations
|
Go to the documentation of this file. 1 #ifndef GUARD_GGEMS_GEOMETRIES_GGEMSVOXELIZEDSOLID_HH
2 #define GUARD_GGEMS_GEOMETRIES_GGEMSVOXELIZEDSOLID_HH
50 GGEMSVoxelizedSolid(std::string
const& volume_header_filename, std::string
const& range_filename, std::string
const& data_reg_type =
"");
143 template <
typename T>
144 void ConvertImageToLabel(std::string
const& raw_data_filename, std::string
const& range_data_filename,
GGEMSMaterials* materials);
161 template <
typename T>
164 GGcout(
"GGEMSVoxelizedSolid",
"ConvertImageToLabel", 3) <<
"Converting image material data to label data..." <<
GGendl;
180 std::ifstream in_raw_stream(raw_data_filename, std::ios::in | std::ios::binary);
184 std::vector<T> tmp_raw_data;
185 tmp_raw_data.resize(number_of_voxels);
186 in_raw_stream.read(
reinterpret_cast<char*
>(&tmp_raw_data[0]),
static_cast<std::streamsize
>(number_of_voxels *
sizeof(
T)));
189 in_raw_stream.close();
192 label_data_[d] = opencl_manager.
Allocate(
nullptr, number_of_voxels *
sizeof(
GGuchar), d, CL_MEM_READ_WRITE,
"GGEMSVoxelizedSolid");
198 std::fill(label_data_device, label_data_device + number_of_voxels, std::numeric_limits<GGuchar>::max());
201 std::ifstream in_range_stream(range_data_filename, std::ios::in);
205 GGfloat first_label_value = 0.0f;
206 GGfloat last_label_value = 0.0f;
208 std::string material_name(
"");
211 std::string line(
"");
212 while (std::getline(in_range_stream, line)) {
218 iss >> first_label_value >> last_label_value >> material_name;
224 for (
GGsize i = 0; i < number_of_voxels; ++i) {
227 if (((value == first_label_value) && (value == last_label_value)) || ((value >= first_label_value) && (value < last_label_value))) {
228 label_data_device[i] = label_index;
237 bool all_converted =
true;
238 for (
GGsize i = 0; i < number_of_voxels; ++i) {
239 if (label_data_device[i] == std::numeric_limits<GGuchar>::max()) all_converted =
false;
243 in_range_stream.close();
244 tmp_raw_data.clear();
251 GGcout(
"GGEMSVoxelizedSolid",
"ConvertImageToLabel", 2) <<
"All your voxels are converted to label..." <<
GGendl;
259 #endif // End of GUARD_GGEMS_GEOMETRIES_GGEMSVOXELIZEDSOLID_HH
cl::Buffer ** label_data_
Structure storing the stack of data for voxelized solid.
GGEMSVoxelizedSolid & operator=(GGEMSVoxelizedSolid const &voxelized_solid)=delete
Avoid assignement by reference.
struct GGEMSVoxelizedSolidData_t GGEMSVoxelizedSolidData
cl::Buffer ** solid_data_
GGEMS class handling material(s) for a specific navigator.
void ConvertImageToLabel(std::string const &raw_data_filename, std::string const &range_data_filename, GGEMSMaterials *materials)
convert image data to label data
GGEMS class for solid informations.
void ReleaseDeviceBuffer(cl::Buffer *const device_ptr, T *host_ptr, GGsize const &thread_index)
Get the device pointer on host to write on it. Mandatory after a GetDeviceBufferWrite ou GetDeviceBuf...
Structure storing the stack of data for voxelized and analytical solid.
GGEMS class for voxelized solid.
std::istringstream ReadRangeMaterial(std::string &line)
get string stream of value for material range
virtual void PrintInfos(void) const =0
printing infos about solid
void EnableScatter(void) override
Activate scatter registration.
cl::Buffer * Allocate(void *host_ptr, GGsize const &size, GGsize const &thread_index, cl_mem_flags flags, std::string const &class_name="Undefined")
Allocation of OpenCL memory.
GGEMS class for solid. This class store geometry about phantom or detector.
std::string volume_header_filename_
virtual void UpdateTransformationMatrix(GGsize const &thread_index)=0
Update transformation matrix for solid object.
bool IsBlankLine(std::string const &line)
check if the line is blank or not
GGsize number_activated_devices_
virtual void Initialize(GGEMSMaterials *materials)=0
Initialize solid for geometric navigation.
Structure storing OBB (Oriented Bounding Box) geometry.
T * GetDeviceBuffer(cl::Buffer *device_ptr, GGsize const &size, GGsize const &thread_index)
Get the device pointer on host to write on it. ReleaseDeviceBuffer must be used after this method!...
#define GGendl
overload C++ std::endl
Singleton class storing all informations about OpenCL and managing GPU/CPU devices,...
GGEMSVoxelizedSolid(GGEMSVoxelizedSolid const &&voxelized_solid)=delete
Avoid copy by rvalue reference.
void CheckInputStream(std::ifstream const &input_stream, std::string const &filename)
check the input stream during the opening
GGEMSVoxelizedSolid(GGEMSVoxelizedSolid const &voxelized_solid)=delete
Avoid copy by reference.
void AddMaterial(std::string const &material_name)
Add a material associated to a phantom.
std::string range_filename_
GGEMSVoxelizedSolid & operator=(GGEMSVoxelizedSolid const &&voxelized_solid)=delete
Avoid copy by rvalue reference.
void ThrowException(std::string const &class_name, std::string const &method_name, std::string const &message)
Throw a C++ exception.
virtual void InitializeKernel(void)=0
Initialize kernel for particle solid distance.
static GGEMSOpenCLManager & GetInstance(void)
Create at first time the Singleton.