73 #ifndef __OpenGLUtilities_h 81 #ifndef __ElementSet_h 85 #ifndef __MaterialSet_h 99 #define XRAY_DETECTOR_UNCLEANED_LBUFFER_FBO_ID 0 100 #define XRAY_DETECTOR_CLEANED_LBUFFER_FBO_ID 1 101 #define XRAY_DETECTOR_CUMULATED_LBUFFERS_FBO_ID 2 102 #define XRAY_DETECTOR_ENERGY_FLUENCE_FBO_ID 3 103 #define XRAY_DETECTOR_SUM_MUx_Dx_FBO_ID 4 106 #define XRAY_DETECTOR_UNCLEANED_LBUFFER_TEXTURE_NAME_ID 0 107 #define XRAY_DETECTOR_CLEANED_LBUFFER_TEXTURE_NAME_ID 1 108 #define XRAY_DETECTOR_CUMULATED_LBUFFERS_TEXTURE_NAME_ID 2 109 #define XRAY_DETECTOR_ENERGY_FLUENCE_TEXTURE_NAME_ID 3 110 #define XRAY_DETECTOR_SUM_MUx_Dx_TEXTURE_NAME_ID 4 111 #define XRAY_DETECTOR_ZBUFFER_TEXTURE_NAME_ID 5 135 for (
unsigned int current_slice(0);
149 total_energy += input_energy;
195 std::stringstream label;
219 std::stringstream label;
246 if (*ite == apNode)
return true;
268 std::vector<std::vector<SceneGraphNode*>::iterator> waiting_list;
277 waiting_list.push_back(ite);
281 for (std::vector<std::vector<SceneGraphNode*>::iterator>::reverse_iterator ite = waiting_list.rbegin();
282 ite != waiting_list.rend();
294 std::vector<std::vector<SceneGraphNode*>::iterator> waiting_list;
303 waiting_list.push_back(ite);
307 for (std::vector<std::vector<SceneGraphNode*>::iterator>::reverse_iterator ite = waiting_list.rbegin();
308 ite != waiting_list.rend();
320 const std::string& aFileName,
324 printFBO(aFBOID, aFileName.data(), useCompression);
330 const std::string& aFileName,
384 for (std::vector<AttenuationCoefficient>::const_iterator ite(
m_mu_water_set.begin());
388 anOutputStream << *ite << std::endl;
409 catch (std::exception& e)
532 if (anIndex >= m_p_inner_surface_set.size())
537 m_p_inner_surface_set[anIndex]->display();
832 float voxel_size = spacing;
837 return round((
Pi / 2.0) * ncols);
845 return round(2.0 *
Pi / atan((2.0 * voxel_size) / (ncols / spacing)));
1065 bool useCompression)
1111 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"CUDA is not supported.");
1115 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"OpenCL is not supported.");
1119 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"Unsupported computing mode.");
1141 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"CUDA is not supported.");
1145 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"OpenCL is not supported.");
1149 throw Exception(__FILE__, __FUNCTION__, __LINE__,
"Unsupported computing mode.");
unsigned int getNumberOfProjectionsCT() const
RATIONAL_NUMBER applyEnergyResponse(const RATIONAL_NUMBER &anEnergy) const
Apply the energy response if any.
bool useParallelBeam() const
Accessor on the flag about projection.
#define XRAY_DETECTOR_UNCLEANED_LBUFFER_FBO_ID
void printEnergyFluence(const char *aFileName, bool useCompression=false)
Save the current energy fluence into a file (same as printXRayImage()).
void enableArtifactFilteringOnGPU()
Enable artefact filtering on GPU.
Sinogram< PixelType > m_sinogram_image
Sinogram.
void usePoissonNoise(bool aFlag)
Enable or disable Poisson noise for the energy fluence.
void disableArtefactFilteringOnCPU()
Disable artefact filtering on CPU.
unsigned int getNumberOfOuterSurfaces() const
void removeInnerSurfaces()
Remove the external surface from the renderer if any.
std::vector< VEC3 > m_source_positions_set
void addInnerSurface(const SceneGraphNode *apSurface)
Add a 3D object to be rendered. It will be used as an internal surface.
const std::vector< RATIONAL_NUMBER > & getAngleSetCT() const
void resetSumMuxDx()
Reset the Mu_x * D_x FBO to 0.
bool getNegativeFilteringFlag() const
Accessor on the flag control the display of the final in negative.
XRayBeam is a class to handle the X-Ray beam. The beam spectrum is discretised into energy channels...
RATIONAL_NUMBER getPhotonEnergy() const
Accessor on the energy of photons.
const std::vector< VEC3 > & getDetectorPositionSet() const
const Sinogram< XRayRenderer::PixelType > & getSinogram() const
const Image< XRayRenderer::PixelType > & getCumulatedLBuffer() const
Image< T > convolution1D(const std::vector< float > &aKernel) const
static RATIONAL_NUMBER getMuFromHUAndMuWater(const RATIONAL_NUMBER &HU, const RATIONAL_NUMBER &mu_water)
Convert a Hounsfield value into a linear attenuation coefficient ( ).
const std::vector< VEC3 > & getDetectorUpVectorSet() const
#define XRAY_DETECTOR_CLEANED_LBUFFER_FBO_ID
void reset2DBuffer(unsigned int aFrameBuffer)
Reset the value of a FBO to 0.
bool isInnerSurface(const SceneGraphNode *apNode)
Check if a given PolygonMesh is an inner surface.
XRayRenderer is a class to compute and renderer X-ray images on GPU.
Computation using OpenGL.
void printSumMuxDx(const char *aFileName, bool useCompression=false)
Save the current Mux Dx into a file.
RATIONAL_NUMBER getLastAngleCT() const
Accessor on the last angle of the CT scan acquisition simulation.
const PixelType * getSinogramRawData() const
std::vector< VEC3 > m_detector_up_vector_set
unsigned int m_zbuffer_texture_id
void printMuWaterTable(std::ostream &anOutputStream)
Output the talbe of attenuation coefficients of water into a data stream.
bool m_use_l_buffer_artefact_filtering_on_gpu
Flag set to true to use L-buffer artefact filtering.
RATIONAL_NUMBER m_CT_last_angle
RATIONAL_NUMBER getElementMassAttenuation(const char *anElementSymbol, const RATIONAL_NUMBER &anEnergy)
Get the mass attenuation coefficient ( ) of a chemical element.
RATIONAL_NUMBER PixelType
Pixel type.
bool useArtefactFilteringOnGPU() const
void printCumulatedLBuffer(const char *aFileName, bool useCompression=false)
Save the current cumulated L-buffer into a file.
bool m_energy_fluence_empty
Flag use for lazy evaluation and blending of the energy fluence.
void addPoissonNoise(Image< PixelType > &anImage)
Use the number of photons to add the Poisson noise.
#define XRAY_DETECTOR_UNCLEANED_LBUFFER_TEXTURE_NAME_ID
bool useArtifactFilteringOnGPU() const
RATIONAL_NUMBER m_max_value_in_simulated_xray_image
Max value in simulated X-ray image.
Class to manage a table of elements in material.
#define XRAY_DETECTOR_ENERGY_FLUENCE_TEXTURE_NAME_ID
void print2DTexture(unsigned int aTextureID, const char *aFileName, bool useCompression=false)
Save a texture into a file.
void printFBO(unsigned int aFBOID, const char *aFileName, bool useCompression=false)
Save a FBO into a file.
Exception is a class to handle exceptions.
void printProjectionSet(const char *aFileName, bool useCompression=false)
#define XRAY_DETECTOR_2D_TEXTURE_NUMBER
The total number of 2D textures.
Sinogram is a class to reconstruct images from a sinogram.
bool getIncludeLastAngleFlagCT() const
#define XRAY_DETECTOR_CLEANED_LBUFFER_TEXTURE_NAME_ID
static RATIONAL_NUMBER getElementMu(const char *anElementSymbol, const RATIONAL_NUMBER &anEnergy)
Get the linear attenuation coefficient ( ) of a chemical element.
#define XRAY_DETECTOR_SUM_MUx_Dx_FBO_ID
void displayOuterSurface() const
unsigned int getNumberOfInnerSurfaces() const
const std::vector< RATIONAL_NUMBER > & getLSF() const
Accessor on the line spread function.
void printXRayImage(const char *aFileName, bool useCompression=false)
bool useArtefactFilteringOnCPU() const
void enableArtefactFilteringOnGPU()
Enable artefact filtering on GPU.
void useNegativeFilteringFlag(bool aFlag=true)
Display the final image in negative or not.
Class to manage a table of materials.
Image< PixelType > m_projection_set
Projection set.
unsigned int m_CT_white_images_in_flat_field
RATIONAL_NUMBER getMinPixelValue() const
RATIONAL_NUMBER getMaxPixelValue() const
RATIONAL_NUMBER getTotalEnergyWithDetectorResponse() const
Accessor on a total energy of the beam when the detector response is applied.
Image< PixelType > m_cumulated_lbuffer_image
Cumulated L-buffer for all the inner surfaces.
T * getRawData()
Accessor on the raw data.
void save(const char *aFileName, bool anInvertLUTFlag=false, const char *aComment="", bool useDeflateCompressionIfPossible=false) const
Save the image in a file.
ComputingMode m_computing_mode
The computing mode (OPENGL, CUDA, or OPENCL)
void disableArtefactFilteringOnGPU()
Disable artefact filtering on GPU.
void enableArtifactFilteringOnCPU()
Enable artefact filtering on CPU.
static ElementSet & getInstance()
const Vec2ui & getNumberOfPixels() const
Accessor on the number of pixels.
std::vector< RATIONAL_NUMBER > m_CT_angle_set
PolygonMesh is a class to handle polygon (triangles) meshes.
Image< PixelType > m_energy_fluence_image
Energy fluence.
Image< XRayRenderer::PixelType > & getEnergyFluence()
Image is a class to manage a greyscale image.
unsigned int m_negative_display_flag
Flag to display the result in negative or not.
void removeOuterSurface()
Remove the internal surfaces from the renderer if any.
unsigned int getMaxRadiusLbufferArtefactFilter() const
Accessor on the max radius of the L-buffer artefact correction filter.
const PixelType * getLBufferRawData()
void displayEnergyFluence()
Display the energy fluence using OpenGL (same as displayXRayImage()).
float RATIONAL_NUMBER
Type of data used to store real numbers.
void deletePBO(unsigned int &aPBO)
Delete a PBO.
unsigned int getHeight() const
Number of pixels along the vertical axis.
bool useArtifactFilteringOnCPU() const
std::string m_CT_screenshot_output_path
const std::vector< VEC3 > & getDetectorRightVectorSet() const
const PixelType * getProjectionSetRawData()
static MaterialSet & getInstance()
void disableArtifactFilteringOnCPU()
Disable artefact filtering on CPU.
RATIONAL_NUMBER m_min_value_in_simulated_xray_image
Min value in simulated X-ray image.
Vec3< RATIONAL_NUMBER > VEC3
Type of data used to store 3D vectors.
void pushTexture2D()
Add the current 2D texture binding to the texture stack.
RATIONAL_NUMBER getFirstAngleCT() const
Accessor on the first angle of the CT scan acquisition simulation.
const VEC3 & getCentreOfRotationPositionCT() const
unsigned int m_max_radius_Lbuffer_artefact_filter
Max radius of L-buffer artefact filter.
Image< T > convolution2D(const Image< float > &aKernel) const
bool isOuterSurface(const SceneGraphNode *apNode)
Check if a given PolygonMesh is an outer surface.
void displayLBuffer()
Display the L-buffer using OpenGL.
Some utility functions about OpenGL. Now supports GLSL450 and OpenGL 4.5.
void displayInnerSurface(unsigned int anIndex) const
Some utility functions that do not fit anywhere else.
#define XRAY_DETECTOR_CUMULATED_LBUFFERS_FBO_ID
void addOuterSurface(const SceneGraphNode *apSurface)
Add a 3D object to be rendered. It will be used as an external surface.
const Image< XRayRenderer::PixelType > & getLBuffer() const
const std::string & getProjectionOutputPathCT() const
RATIONAL_NUMBER getPhotonNumber() const
Accessor on the number of photons in the bin.
XRayDetector * m_p_detector
The X-ray detector.
void initialisePBOs()
Initialise the PBOs.
std::vector< VEC3 > m_detector_right_vector_set
Computation on CPU using OpenMP.
RATIONAL_NUMBER m_CT_first_angle
const std::string & getScreenshotOutputPathCT() const
unsigned int getWidth() const
Number of pixels along the horizontal axis.
static double getDensity(short aHounsfieldValue)
Get the density for a given material (in HU).
const SpectrumRecord & getEnergyChannel(unsigned int anID)
Accessor on a given energy bin.
static RATIONAL_NUMBER getMuFromHU(const RATIONAL_NUMBER &HU, const RATIONAL_NUMBER &anEnergy)
Convert a Hounsfield value into a linear attenuation coefficient ( ).
void createPBO(unsigned int &aPBO)
Create a PBO.
const XRayBeam * getXRayBeam() const
Returns the actual Beam.
VEC3 m_CT_centre_of_rotation_position
unsigned int getOptimalNumberOfProjectionsCT() const
SceneGraphNode * m_p_outer_surface
The 3D geometry that will wrap the ones in m_p_inner_surface_set.
unsigned int getNumberOfSourceSamples() const
std::vector< unsigned int > m_p_texture_name_set
Set of textures.
void display2DTexture(unsigned int aTextureID)
Display a 2D texture using OpenGL.
Image< PixelType > m_l_buffer_image
L-buffer.
const Image< RATIONAL_NUMBER > & getPSF() const
Accessor on the point spread function.
const VEC3 & getRotationAxisCT() const
void setMaxRadiusLbufferArtefactFilter(unsigned int aRadius)
Set the max radius of the L-buffer artefact correction filter.
void create2DTexture(unsigned int *apTextureID, int anInternalTextureFormat, int aType)
Create a 2D texture.
std::vector< SceneGraphNode * > m_p_inner_surface_set
Set of 3D geometries.
#define XRAY_DETECTOR_ENERGY_FLUENCE_FBO_ID
std::ostream & logError(const std::string &aMessage="")
static RATIONAL_NUMBER getMassAttenuationFromHU(const RATIONAL_NUMBER &HU, const RATIONAL_NUMBER &anEnergy)
Convert a Hounsfield value into a mass attenuation coefficient ( ).
void disableArtifactFilteringOnGPU()
Disable artefact filtering on GPU.
bool m_surface_per_material_set_needs_update
unsigned int getEnergyChannelNumber()
Accessor on the number of bins in the spectrum.
void init2DTextures(int anInternalTextureFormat)
Initialise the 2D textures.
Computation using OpenCL.
static std::vector< AttenuationCoefficient > m_mu_water_set
The table of water energy fluence coefficients.
std::string m_CT_projection_output_path
void resetEnergyFluence()
Reset the energy fluence FBO to 0.
bool m_CT_include_last_angle_flag
XRayBeam * m_p_xray_beam
The X-ray beam.
bool m_use_l_buffer_artefact_filtering_on_cpu
std::vector< SceneGraphNode * > m_p_internal_data_storage
RATIONAL_NUMBER * getFBO(unsigned int aFBOID)
Accessor on the raw data from a FBO.
void printLBuffer(const char *aFileName, bool useCompression=false)
Save the current L-buffer into a file.
const Image< XRayRenderer::PixelType > & getProjectionSet() const
unsigned int getWhiteImagesInFlatFieldCT() const
RATIONAL_NUMBER getElementDensity(const char *anElementSymbol)
Get the density ( ) of a chemical element.
~XRayRenderer()
Destructor.
static RATIONAL_NUMBER getDensityFromHU(const RATIONAL_NUMBER &HU)
Get the density ( ) of a tissue given a Hounsfield value.
void printSinogram(const char *aFileName, bool useCompression=false)
void enableArtefactFilteringOnCPU()
Enable artefact filtering on CPU.
const std::vector< VEC3 > & getSourcePositionSet() const
std::vector< VEC3 > m_detector_positions_set
const VEC2 & getPixelSpacingInUnitOfLength() const
Accessor on the pixel spacing (in unit of length).