72 #ifndef __FileDoesNotExistException_h 86 m_resolution_in_unit_of_length_per_pixel(0),
87 m_distance_source_detector(0),
88 m_vbo_need_update(true),
90 m_widget_length(5 *
mm),
91 m_source_mesh(10, m_widget_length / 2.0),
92 m_first_pixel_mesh(m_widget_length, GL_UNSIGNED_BYTE),
93 m_detector_centre_mesh(10, m_widget_length / 2.0),
94 m_source_shape(UNKNOWN_SHAPE),
95 m_update_right_vector_flag(true)
401 const VEC3& aRotationAxis)
536 return (m_p_xray_source_position_set[aSampleID]);
597 const VEC3& aRotationAxis)
615 *ite = rotation_matrix * *ite;
627 const VEC3& aRotationCentre,
628 const VEC3& aRotationAxis)
647 *ite -= aRotationCentre;
648 *ite = rotation_matrix * *ite;
649 *ite += aRotationCentre;
698 const float& aThickness)
730 std::ifstream input_stream(aFileName);
733 if (!input_stream.is_open())
740 while (input_stream >> coefficient)
743 if (!input_stream.eof())
745 m_LSF.push_back(coefficient);
750 double sum = std::accumulate(
m_LSF.begin(),
m_LSF.end(), 0.0);
751 for (std::vector<RATIONAL_NUMBER>::iterator ite(
m_LSF.begin());
768 double sum = std::accumulate(
m_LSF.begin(),
m_LSF.end(), 0.0);
769 for (std::vector<RATIONAL_NUMBER>::iterator ite(
m_LSF.begin());
855 return m_scintillator.applyEnergyResponse(anEnergy);
SourceShape
SourceShape is a type that defines the shape of X-ray sources.
void clearLSF()
Clear the LSF to use a Dirac as impulse response.
RATIONAL_NUMBER applyEnergyResponse(const RATIONAL_NUMBER &anEnergy) const
Apply the energy response if any.
void rotateFocalSpot(const RATIONAL_NUMBER &aRotationAngle, const VEC3 &aRotationAxis)
Rotate the focal spot around its centre.
void destroy()
Release the memory.
bool useParallelBeam() const
Accessor on the flag about projection.
double getScintillatorThickness()
static Matrix4x4 buildTranslationMatrix(const Vec3< RATIONAL_NUMBER > &aVector)
Build a tranlation matrix.
RATIONAL_NUMBER m_distance_source_detector
Distance between the source and the detector.
std::auto_ptr< VBO > m_parallel_beam
The triangle mesh corresponding to the parallel beam.
void setX(const T &aValue)
Set the position along the x-axis.
void loadEnergyResponse(const std::string &aFileName, const RATIONAL_NUMBER &aUnitOfEnergy)
Load the energy response of the detector from a TSV file.
void setY(const T &aValue)
Set the position along the y-axis.
void rotateSource(const RATIONAL_NUMBER &aRotationAngle, const VEC3 &aRotationCentre, const VEC3 &aRotationAxis)
Rotate the source around and arbitrary point.
void setPSF(const Image< RATIONAL_NUMBER > &aPSF)
Set the point spread function from a 2D image.
void pushModelViewMatrix()
Add the current matrix to the model/view matrix stack.
void applyModelViewMatrix()
Scintillator is a class to generate the energy response due to the scintillator of the X-Ray detector...
void setEnergyResponse(const std::vector< std::pair< float, float > > &anEnergyResponse)
void setLineSource()
Set the shape of the source as a line segment.
std::auto_ptr< VBO > m_cone_beam_highlight
The triangle mesh corresponding to the cone beam highlight.
VEC3 m_xray_source_centre
The position of the source centre.
void display()
Display the triangular mesh using OpenGL.
VEC3 m_normal
The vector normal to the detector.
Image< RATIONAL_NUMBER > m_PSF
Impulse response of the detector as a point spread function.
const VEC3 & getSourceSamplePosition(unsigned int aSampleID) const
void displaySourceWireframe()
Display the source using OpenGL.
double length() const
Get the length of the vector.
std::vector< RATIONAL_NUMBER > m_LSF
Impulse response of the detector as a line spread function.
void setLSF(const std::string &aFileName)
Set the line spread function from a file.
void create(unsigned int aNumberOfRings, unsigned int aNumberOfSectors, float aRadius, int anIndexDataType=0)
Create a new sphere.
const MATRIX4 & getRotationMatrix() const
Accessor on the rotation matrix.
T getX() const
Accessor on the position along the x-axis.
void setMaterial(const std::string &aMaterial)
void setSquareSource()
Set the shape of the source as a square.
void setScintillator(const Scintillator &aScintillator)
bool m_vbo_need_update
A flag set to true when the VBOs need to be updated.
const std::string & getScintillatorMaterial()
void setRightVector(const VEC3 &aRightVector)
Set the right vector that defines the detector's orientation.
bool m_update_right_vector_flag
RATIONAL_NUMBER getThickness()
FileDoesNotExistException is a class to handle exceptions when trying to open a read-only file that i...
T getZ() const
Accessor on the position along the z-axis.
VEC2 m_size_in_unit_of_length
The size of the detector.
void setRotationMatrix(const MATRIX4 &aMatrix)
Set the rotation matrix.
Vec3 normal() const
Get the unit vector corresponding to the normed current vector.
const VEC2 & getPixelSizeInUnitOfLength() const
const std::vector< RATIONAL_NUMBER > & getLSF() const
Accessor on the line spread function.
std::vector< VEC3 > m_p_xray_source_position_set
The sample positions of the source.
Class to handle exceptions when trying to open a read-only file that is not accessible.
VEC3 m_right_vector
The cross product between m_look_at_vector and m_up_vector.
T getX() const
Accessor on the position along the x-axis.
MATRIX4 m_rotation_matrix
The rotation matrix.
CubeMesh< float > m_first_pixel_mesh
Polygon mesh of the first pixel of the detector.
Source whose shape corresponds to a square.
Vec2ui m_size_in_number_of_pixels
Size of the detector (in number of pixels)
void autoAlignDetector(bool aFlag=true)
VEC2 m_resolution_in_unit_of_length_per_pixel
Resolution (in unit of length per pixel)
const std::vector< VEC3 > & getSourcePositionSet() const
void setCubicSource()
Set the shape of the source as a cube.
const VEC3 & getRightVector() const
Accessor on the cross product between m_look_at_vector and m_up_vector.
void reset()
Reset the data.
void updateInternalValues()
Compute the distance between the source and the detector, etc.
T getY() const
Accessor on the position along the y-axis.
static Matrix4x4 buildRotationMatrix(RATIONAL_NUMBER anAngle, RATIONAL_NUMBER x, RATIONAL_NUMBER y, RATIONAL_NUMBER z)
Build a rotation matrix.
const std::string & getMaterial() const
SourceShape m_source_shape
Source type.
RATIONAL_NUMBER m_fovy
Field of view along the Y-axis.
const Vec2ui & getNumberOfPixels() const
Accessor on the number of pixels.
RATIONAL_NUMBER m_widget_length
The length of the widgets.
SphereMesh m_detector_centre_mesh
std::auto_ptr< VBO > m_parallel_beam_highlight
The triangle mesh corresponding to the parallel beam highlight.
std::vector< GLfloat > m_p_detector_geometry_vertices
float RATIONAL_NUMBER
Type of data used to store real numbers.
Source whose shape corresponds to a line segment.
void setDetectorPosition(const VEC3 &aDetectorPosition)
Set the position of the X-ray detector.
const RATIONAL_NUMBER & getFOVY() const
Accessor on the view along the Y-axis.
Vec3< RATIONAL_NUMBER > VEC3
Type of data used to store 3D vectors.
void setXrayPointSource()
Set the shape of the source as an infinitely small point.
std::auto_ptr< VBO > m_cone_beam
The triangle mesh corresponding to the cone beam.
void normalize()
Normalize the current vector so that its length is 1.
const VEC3 & getDetectorPosition() const
Accessor on the detector position.
VEC3 m_detector_position
The position of the detector centre.
const std::vector< float > & getVertices() const
Accessor on the four corners of the X-ray detector.
void setConeBeam()
Set the projection mode to cone beam (same as point source).
void setPointSource()
Set the projection mode to point source (same as cone beam).
const double mm
millimeter
Vec2< RATIONAL_NUMBER > VEC2
Type of data used to store 2D vectors.
Source whose shape corresponds to a cube.
void updateSizeInUnitOfLength()
Compute the size of the detector.
std::vector< std::pair< RATIONAL_NUMBER, RATIONAL_NUMBER > > getEnergyResponse() const
void displayWireFrame()
Display the triangular mesh in wireframe using OpenGL.
void setEnergyResponse(const std::vector< std::pair< float, float > > &anEnergyResponse)
void clearEnergyResponse()
Clear the energy response of the detector.
void setParallelBeam()
Set the projection mode to parallel beam.
void release()
Release the data.
void getPlaneEquation(RATIONAL_NUMBER &A, RATIONAL_NUMBER &B, RATIONAL_NUMBER &C, RATIONAL_NUMBER &D)
Accessor on the plane equation (Ax + By + Cz + D = 0).
SourceShape getSourceShape() const
Accessor on the shape of the source.
XRayDetector()
Default constructor.
const VEC2 & getSizeInUnitOfLength() const
Accessor on the size of the detector (in unit of length).
Source whose shape corresponds to a rectangle.
SphereMesh m_source_mesh
Polygon mesh of the source.
const VEC3 & getXraySourceCentre() const
Accessor on the centre of the source.
void loadEnergyResponse(const std::string &aFileName, const RATIONAL_NUMBER &aUnitOfEnergy)
Load the energy response of the detector from a TSV file.
unsigned int getNumberOfSourceSamples() const
Infinitively small point source.
void rotateDetector(const RATIONAL_NUMBER &anAngle, const VEC3 &aRotationAxis)
const Image< RATIONAL_NUMBER > & getPSF() const
Accessor on the point spread function.
void setNumberOfPixels(const Vec2ui &aSizeInPixels)
Set the number of pixels.
void setSourcePositions(const std::vector< VEC3 > &aSourcePostionSet)
MATRIX4 g_current_modelview_matrix
The model/view matrices.
std::vector< std::pair< RATIONAL_NUMBER, RATIONAL_NUMBER > > getEnergyResponse() const
void setRectangleSource()
Set the shape of the source as a rectangle.
~XRayDetector()
Destructor.
std::auto_ptr< VBO > m_detector_geometry
The triangle mesh corresponding to the detector.
void release()
Release the data.
void setResolutionInUnitsOfLengthPerPixel(const RATIONAL_NUMBER &aResolution)
void updateFOVY()
Update the view along the Y-axis.
const VEC3 & getUpVector() const
Accessor on the up vector, which defines the orientation of the detector.
VEC3 m_up_vector
The "up" vector the the detector.
T getY() const
Accessor on the position along the y-axis.
void clearPSF()
Clear the PSF to use a Dirac as impulse response.
void setThickness(const RATIONAL_NUMBER &aThickness)
void setUpVector(const VEC3 &anUpVector)
Set the up vector that defines the detector's orientation.
void displaySource()
Display the source using OpenGL.
void popModelViewMatrix()
void setWidgetLength(const RATIONAL_NUMBER &aLength)
Scintillator m_scintillator
Scintillator.
void create(double aLength=1.0 *cm, int anIndexDataType=0)
Create a new cube.
const VEC2 & getPixelSpacingInUnitOfLength() const
Accessor on the pixel spacing (in unit of length).