gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
XRayDetector.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2013-2023, Dr Franck P. Vidal, Bangor University, All rights reserved.
4 Copyright (c) 2023-present, Prof Franck P. Vidal (franck.vidal@stfc.ac.uk),
5 UK Research and Innovation, All rights reserved.
6 
7 
8 Redistribution and use in source and binary forms, with or without modification,
9 are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice,
12 this list of conditions and the following disclaimer.
13 
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation and/or
16 other materials provided with the distribution.
17 
18 3. Neither the name of Bangor University, UK Research and Innovation nor the
19 names of its contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21 
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 */
34 
35 
63 //******************************************************************************
64 // Include
65 //******************************************************************************
66 
67 #include <cmath>
68 #include <fstream>
69 #include <iostream>
70 #include <numeric> // To sum all the elements of the LSF
71 
72 #ifndef __FileDoesNotExistException_h
74 #endif
75 
76 
77 //******************************************************************************
78 // namespace
79 //******************************************************************************
80 namespace gVirtualXRay {
81 
82 
83 //----------------------------------------------
85 //----------------------------------------------
86  m_resolution_in_unit_of_length_per_pixel(0),
87  m_distance_source_detector(0),
88  m_vbo_need_update(true),
89  //m_source_mesh(10, 10, 0.5 * cm),
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)
96 //----------------------------------------------
97 {
98 }
99 
100 
101 //----------------------------------
103 //----------------------------------
104 {
105  release();
106 }
107 
108 
109 //---------------------------------
111 //---------------------------------
112 {
114  m_detector_geometry.reset();
115  m_parallel_beam.reset();
116  m_cone_beam.reset();
118  m_cone_beam_highlight.reset();
122 }
123 
124 
125 //-----------------------------------------------------------------------
127 //-----------------------------------------------------------------------
128 {
129  m_widget_length = aLength;
130 
132  m_first_pixel_mesh.create(m_widget_length, GL_UNSIGNED_BYTE),
134 }
135 
136 
137 //---------------------------------------
139 //---------------------------------------
140 {
141  // Display all the sub-sources
142  for (std::vector<VEC3>::const_iterator ite(m_p_xray_source_position_set.begin());
143  ite != m_p_xray_source_position_set.end();
144  ++ite)
145  {
146  // Store the model/view matrix
148 
149  g_current_modelview_matrix *= MATRIX4::buildTranslationMatrix(ite->getX(), ite->getY(), ite->getZ());
151 
152  // Draw sphere
154 
155  // Restore the model/view matrix
157  }
158 }
159 
160 
161 //------------------------------------------------
163 //------------------------------------------------
164 {
165  // Display all the sub-sources
166  for (std::vector<VEC3>::const_iterator ite(m_p_xray_source_position_set.begin());
167  ite != m_p_xray_source_position_set.end();
168  ++ite)
169  {
170  // Store the model/view matrix
172 
173  g_current_modelview_matrix *= MATRIX4::buildTranslationMatrix(ite->getX(), ite->getY(), ite->getZ());
175 
176  // Draw sphere
178 
179  // Restore the model/view matrix
181  }
182 }
183 
184 
185 //------------------------------------------------------------------------------------------------
187 //------------------------------------------------------------------------------------------------
188 {
189  // The resolution has changed
190  m_resolution_in_unit_of_length_per_pixel = VEC2(aResolution, aResolution);
191 
192  // Update the size of the detector
194 
195  // Update the distance between the source and the detector, etc.
197 
198  // The VBOs need to be updated
199  m_vbo_need_update = true;
200 }
201 
202 
203 //-------------------------------------------------------------------------------------
205 //-------------------------------------------------------------------------------------
206 {
207  // The resolution has changed
209 
210  // Update the size of the detector
212 
213  // Update the distance between the source and the detector, etc.
215 
216  // The VBOs need to be updated
217  m_vbo_need_update = true;
218 }
219 
220 
221 //----------------------------------------------------------------------
222 inline void XRayDetector::setNumberOfPixels(const Vec2ui& aSizeInPixels)
223 //----------------------------------------------------------------------
224 {
225  // The number of pixels has changed
226  m_size_in_number_of_pixels = aSizeInPixels;
227 
228  // Update the size of the detector
230 
231  // Update the distance between the source and the detector, etc.
233 
234  // The VBOs need to be updated
235  m_vbo_need_update = true;
236 }
237 
238 
239 //--------------------------------------------------------------------------
240 inline void XRayDetector::setDetectorPosition(const VEC3& aDetectorPosition)
241 //--------------------------------------------------------------------------
242 {
243  // The position of the source has changed
244  m_detector_position = aDetectorPosition;
245 
246  // Update the distance between the source and the detector, etc.
248 
249  // The VBOs need to be updated
250  m_vbo_need_update = true;
251 }
252 
253 
254 //---------------------------------------------------------------------------
255 inline void XRayDetector::setXrayPointSource(const VEC3& aXraySourcePosition)
256 //---------------------------------------------------------------------------
257 {
258  // Store the centre position
259  m_xray_source_centre = aXraySourcePosition;
260 
261  // Clear the sample set
263 
264  // Add the centre
266 
267  // Save the source type
269 
270  // Update the distance between the source and the detector, etc.
272 
273  // The VBOs need to be updated
274  m_vbo_need_update = true;
275 }
276 
277 
278 //--------------------------------------------
280 //--------------------------------------------
281 {
282  // Save the source type
284 
285  // Update the distance between the source and the detector, etc.
287 
288  // The VBOs need to be updated
289  m_vbo_need_update = true;
290 }
291 
292 
293 //----------------------------------------
295 //----------------------------------------
296 {
297  // Save the source type
299 
300  // Update the distance between the source and the detector, etc.
302 
303  // The VBOs need to be updated
304  m_vbo_need_update = true;
305 }
306 
307 
308 //-----------------------------------------
310 //-----------------------------------------
311 {
312  // Save the source type
314 
315  // Update the distance between the source and the detector, etc.
317 
318  // The VBOs need to be updated
319  m_vbo_need_update = true;
320 }
321 
322 
323 //--------------------------------------------
325 //--------------------------------------------
326 {
327  // Save the source type
329 
330  // Update the distance between the source and the detector, etc.
332 
333  // The VBOs need to be updated
334  m_vbo_need_update = true;
335 }
336 
337 
338 //---------------------------------------
340 //---------------------------------------
341 {
342  // Save the source type
344 
345  // Update the distance between the source and the detector, etc.
347 
348  // The VBOs need to be updated
349  m_vbo_need_update = true;
350 }
351 
352 
353 //-----------------------------------------------------------
354 inline void XRayDetector::setUpVector(const VEC3& anUpVector)
355 //-----------------------------------------------------------
356 {
357  m_up_vector = anUpVector.normal();
358 
359  // Update the distance between the source and the detector, etc.
361 
362  // The VBOs need to be updated
363  m_vbo_need_update = true;
364 }
365 
366 
367 //----------------------------------------------------------------
368 inline void XRayDetector::setRightVector(const VEC3& aRightVector)
369 //----------------------------------------------------------------
370 {
372  m_right_vector = aRightVector.normal();
373 
374  // Update the distance between the source and the detector, etc.
376 
377  // The VBOs need to be updated
378  m_vbo_need_update = true;
379 }
380 
381 
382 //-----------------------------------------------------
383 inline void XRayDetector::autoAlignDetector(bool aFlag)
384 //-----------------------------------------------------
385 {
387 
389  {
390  // Update the distance between the source and the detector, etc.
392 
393  // The VBOs need to be updated
394  m_vbo_need_update = true;
395  }
396 }
397 
398 
399 //----------------------------------------------------------------------
401  const VEC3& aRotationAxis)
402 //----------------------------------------------------------------------
403 {
404  // Rotate around the centre of the detector
405  MATRIX4 transformation_matrix;
406  transformation_matrix *= MATRIX4::buildRotationMatrix(anAngle, aRotationAxis.normal());
407 
408  // Apply the rotation
409  m_up_vector = transformation_matrix * m_up_vector;
410  m_right_vector = transformation_matrix * m_right_vector;
411 
412  // Update the distance between the source and the detector, etc.
414 
415  // The VBOs need to be updated
416  m_vbo_need_update = true;
417 }
418 
419 
420 //-----------------------------------------------------------------
421 inline void XRayDetector::setRotationMatrix(const MATRIX4& aMatrix)
422 //-----------------------------------------------------------------
423 {
424  m_rotation_matrix = aMatrix;
425 
426  // Update the distance between the source and the detector, etc.
428 
429  // The VBOs need to be updated
430  m_vbo_need_update = true;
431 }
432 
433 
434 //-----------------------------------------
436 //-----------------------------------------
437 {
438  // Save the source type
440 
441  // Clear the sample set
443 
444  // Add the centre
446 
447  // Update the distance between the source and the detector, etc.
449 
450  // The VBOs need to be updated
451  m_vbo_need_update = true;
452 }
453 
454 
455 //-------------------------------------
457 //-------------------------------------
458 {
459  // Save the source type
461 
462  // Clear the sample set
464 
465  // Add the centre
467 
468  // Update the distance between the source and the detector, etc.
470 
471  // The VBOs need to be updated
472  m_vbo_need_update = true;
473 }
474 
475 
476 //----------------------------------------
478 //----------------------------------------
479 {
480  setConeBeam();
481 }
482 
483 
484 //----------------------------------------------------------
486 //----------------------------------------------------------
487 {
489 }
490 
491 
492 //------------------------------------------------------------
494 //------------------------------------------------------------
495 {
496  return (m_size_in_unit_of_length);
497 }
498 
499 
500 //--------------------------------------------------------------------
502 //--------------------------------------------------------------------
503 {
505 }
506 
507 
508 //----------------------------------------------------------
510 //----------------------------------------------------------
511 {
512  return (m_detector_position);
513 }
514 
515 
516 //----------------------------------------------------------
518 //----------------------------------------------------------
519 {
520  return (m_xray_source_centre);
521 }
522 
523 
524 //----------------------------------------------------------------
525 inline unsigned int XRayDetector::getNumberOfSourceSamples() const
526 //----------------------------------------------------------------
527 {
528  return (m_p_xray_source_position_set.size());
529 }
530 
531 
532 //------------------------------------------------------------------------------------
533 inline const VEC3& XRayDetector::getSourceSamplePosition(unsigned int aSampleID) const
534 //------------------------------------------------------------------------------------
535 {
536  return (m_p_xray_source_position_set[aSampleID]);
537 }
538 
539 
540 //--------------------------------------------------
541 inline const VEC3& XRayDetector::getUpVector() const
542 //--------------------------------------------------
543 {
544  return (m_up_vector);
545 }
546 
547 
548 //-----------------------------------------------------
549 inline const VEC3& XRayDetector::getRightVector() const
550 //-----------------------------------------------------
551 {
552  return (m_right_vector);
553 }
554 
555 
556 //-----------------------------------------------------------
558 //-----------------------------------------------------------
559 {
560  return (m_rotation_matrix);
561 }
562 
563 
564 //-------------------------------------------------------------------
566 //-------------------------------------------------------------------
567 {
568  return (m_source_shape);
569 }
570 
571 
572 //------------------------------------------------------------------------
573 inline const std::vector<VEC3>& XRayDetector::getSourcePositionSet() const
574 //------------------------------------------------------------------------
575 {
577 }
578 
579 
580 //--------------------------------------------------------------------------------------
581 inline void XRayDetector::setSourcePositions(const std::vector<VEC3>& aSourcePostionSet)
582 //--------------------------------------------------------------------------------------
583 {
584  // Set the position of sources
585  m_p_xray_source_position_set = aSourcePostionSet;
586 
587  // Update the distance between the source and the detector, etc.
589 
590  // The VBOs need to be updated
591  m_vbo_need_update = true;
592 }
593 
594 
595 //------------------------------------------------------------------------------
596 inline void XRayDetector::rotateFocalSpot(const RATIONAL_NUMBER& aRotationAngle,
597  const VEC3& aRotationAxis)
598 //------------------------------------------------------------------------------
599 {
600  RATIONAL_NUMBER l = aRotationAxis.length();
601  RATIONAL_NUMBER x = aRotationAxis[0] / l;
602  RATIONAL_NUMBER y = aRotationAxis[1] / l;
603  RATIONAL_NUMBER z = aRotationAxis[2] / l;
604 
605  MATRIX4 rotation_matrix = MATRIX4::buildRotationMatrix(aRotationAngle, x, y, z);
606 
607  // Set the position of sources
608  if (m_p_xray_source_position_set.size() > 1)
609  {
610  for (std::vector<VEC3>::iterator ite = m_p_xray_source_position_set.begin();
611  ite != m_p_xray_source_position_set.end();
612  ++ite)
613  {
614  *ite -= m_xray_source_centre;
615  *ite = rotation_matrix * *ite;
616  *ite += m_xray_source_centre;
617  }
618  }
619 
620  // The VBOs need to be updated
621  m_vbo_need_update = true;
622 }
623 
624 
625 //---------------------------------------------------------------------------
626 inline void XRayDetector::rotateSource(const RATIONAL_NUMBER& aRotationAngle,
627  const VEC3& aRotationCentre,
628  const VEC3& aRotationAxis)
629 //---------------------------------------------------------------------------
630 {
631  RATIONAL_NUMBER l = aRotationAxis.length();
632  RATIONAL_NUMBER x = aRotationAxis[0] / l;
633  RATIONAL_NUMBER y = aRotationAxis[1] / l;
634  RATIONAL_NUMBER z = aRotationAxis[2] / l;
635 
636  MATRIX4 rotation_matrix = MATRIX4::buildRotationMatrix(aRotationAngle, x, y, z);
637 
638  // Set the position of sources
639  if (m_p_xray_source_position_set.size() > 0)
640  {
642 
643  for (std::vector<VEC3>::iterator ite = m_p_xray_source_position_set.begin();
644  ite != m_p_xray_source_position_set.end();
645  ++ite)
646  {
647  *ite -= aRotationCentre;
648  *ite = rotation_matrix * *ite;
649  *ite += aRotationCentre;
650 
651  m_xray_source_centre += *ite;
652  }
653 
657  }
658 
659  // The VBOs need to be updated
660  m_vbo_need_update = true;
661 }
662 
663 
664 //-----------------------------------------------
665 inline bool XRayDetector::useParallelBeam() const
666 //-----------------------------------------------
667 {
668  return (m_source_shape == PARALLEL);
669 }
670 
671 
672 //---------------------------------------------------------
674 //---------------------------------------------------------
675 {
676  return (m_fovy);
677 }
678 
679 
680 //---------------------------------------------
682 //---------------------------------------------
683 {
685 }
686 
687 
688 //--------------------------------------------------------------------------
689 inline void XRayDetector::setScintillator(const Scintillator& aScintillator)
690 //--------------------------------------------------------------------------
691 {
692  m_scintillator = aScintillator;
693 }
694 
695 
696 //---------------------------------------------------------------------
697 inline void XRayDetector::setScintillator(const std::string& aMaterial,
698  const float& aThickness)
699 //---------------------------------------------------------------------
700 {
701  m_scintillator.setMaterial(aMaterial);
702  m_scintillator.setThickness(aThickness);
703 }
704 
705 
706 //---------------------------------------------------------------
707 inline const std::string& XRayDetector::getScintillatorMaterial()
708 //---------------------------------------------------------------
709 {
710  return m_scintillator.getMaterial();
711 }
712 
713 
714 //----------------------------------------------------
716 //----------------------------------------------------
717 {
718  return m_scintillator.getThickness();
719 }
720 
721 
722 //------------------------------------------------------------
723 inline void XRayDetector::setLSF(const std::string& aFileName)
724 //------------------------------------------------------------
725 {
726  // Empty the current LSF
727  m_LSF.clear();
728 
729  // Open the file
730  std::ifstream input_stream(aFileName);
731 
732  // The file is not open
733  if (!input_stream.is_open())
734  {
735  throw FileDoesNotExistException(__FILE__, __FUNCTION__, __LINE__, aFileName);
736  }
737 
738  // Load the file
739  double coefficient;
740  while (input_stream >> coefficient)
741  {
742  // The record is valid
743  if (!input_stream.eof())
744  {
745  m_LSF.push_back(coefficient);
746  }
747  }
748 
749  // Normalise the array (divide by sum)
750  double sum = std::accumulate(m_LSF.begin(), m_LSF.end(), 0.0);
751  for (std::vector<RATIONAL_NUMBER>::iterator ite(m_LSF.begin());
752  ite != m_LSF.end();
753  ++ite)
754  {
755  *ite /= sum;
756  }
757 }
758 
759 
760 //------------------------------------------------------------------------
761 inline void XRayDetector::setLSF(const std::vector<RATIONAL_NUMBER>& aLSF)
762 //------------------------------------------------------------------------
763 {
764  // Copy the LSF
765  m_LSF = aLSF;
766 
767  // Normalise the array (divide by sum)
768  double sum = std::accumulate(m_LSF.begin(), m_LSF.end(), 0.0);
769  for (std::vector<RATIONAL_NUMBER>::iterator ite(m_LSF.begin());
770  ite != m_LSF.end();
771  ++ite)
772  {
773  *ite /= sum;
774  }
775 }
776 
777 
778 //---------------------------------------------------------------------
779 inline const std::vector<RATIONAL_NUMBER>& XRayDetector::getLSF() const
780 //---------------------------------------------------------------------
781 {
782  return m_LSF;
783 }
784 
785 
786 //----------------------------------
788 //----------------------------------
789 {
790  m_LSF.clear();
791 }
792 
793 
794 //------------------------------------------------------------------
796 //------------------------------------------------------------------
797 {
798  m_PSF = aPSF;
799 }
800 
801 
802 //---------------------------------------------------------------
804 //---------------------------------------------------------------
805 {
806  return m_PSF;
807 }
808 
809 
810 //----------------------------------
812 //----------------------------------
813 {
814  m_PSF.destroy();
815 }
816 
817 
818 //--------------------------------------------------------------------------------
819 inline void XRayDetector::loadEnergyResponse(const std::string& aFileName,
820  const RATIONAL_NUMBER& aUnitOfEnergy)
821 //--------------------------------------------------------------------------------
822 {
823  m_scintillator.loadEnergyResponse(aFileName, aUnitOfEnergy);
824 }
825 
826 
827 //--------------------------------------------------------------------------------------------------------
828 inline void XRayDetector::setEnergyResponse(const std::vector<std::pair<float, float> >& anEnergyResponse)
829 //--------------------------------------------------------------------------------------------------------
830 {
831  m_scintillator.setEnergyResponse(anEnergyResponse);
832 }
833 
834 
835 //----------------------------------------------------------------------------------------------------------
836 inline void XRayDetector::setEnergyResponse(const std::vector<std::pair<double, double> >& anEnergyResponse)
837 //---------------------------------------------------------------------------------------------------------
838 {
839  m_scintillator.setEnergyResponse(anEnergyResponse);
840 }
841 
842 
843 //------------------------------------------------------------------------------------------------------
844 inline std::vector<std::pair<RATIONAL_NUMBER, RATIONAL_NUMBER> > XRayDetector::getEnergyResponse() const
845 //------------------------------------------------------------------------------------------------------
846 {
848 }
849 
850 
851 //---------------------------------------------------------------------------------------------
853 //---------------------------------------------------------------------------------------------
854 {
855  return m_scintillator.applyEnergyResponse(anEnergy);
856 }
857 
858 
859 //--------------------------------------------------
861 //--------------------------------------------------
862 {
865 }
866 
867 
868 //-----------------------------------------------------------------
870 //-----------------------------------------------------------------
871 {
873 }
874 
875 
876 //----------------------------------------------
878 //----------------------------------------------
879 {
880  // The distance between the source and the detector has changed
882 
883  // Compute the normal vector
886 
889 
891 
892  // Compute the position of each vertex
897 
898  // Vertices
900 
901  m_p_detector_geometry_vertices.push_back(v0.getX());
902  m_p_detector_geometry_vertices.push_back(v0.getY());
903  m_p_detector_geometry_vertices.push_back(v0.getZ());
904 
905  m_p_detector_geometry_vertices.push_back(v1.getX());
906  m_p_detector_geometry_vertices.push_back(v1.getY());
907  m_p_detector_geometry_vertices.push_back(v1.getZ());
908 
909  m_p_detector_geometry_vertices.push_back(v2.getX());
910  m_p_detector_geometry_vertices.push_back(v2.getY());
911  m_p_detector_geometry_vertices.push_back(v2.getZ());
912 
913  m_p_detector_geometry_vertices.push_back(v0.getX());
914  m_p_detector_geometry_vertices.push_back(v0.getY());
915  m_p_detector_geometry_vertices.push_back(v0.getZ());
916 
917  m_p_detector_geometry_vertices.push_back(v2.getX());
918  m_p_detector_geometry_vertices.push_back(v2.getY());
919  m_p_detector_geometry_vertices.push_back(v2.getZ());
920 
921  m_p_detector_geometry_vertices.push_back(v3.getX());
922  m_p_detector_geometry_vertices.push_back(v3.getY());
923  m_p_detector_geometry_vertices.push_back(v3.getZ());
924 
925  // Update the view along the Y-axis
926  updateFOVY();
927 
929  m_first_pixel_mesh.create(m_size_in_unit_of_length[0] * 0.05, GL_UNSIGNED_BYTE);
930 
931 }
932 
933 
934 //------------------------------------------------------------------
936  RATIONAL_NUMBER& B,
937  RATIONAL_NUMBER& C,
938  RATIONAL_NUMBER& D)
939 //------------------------------------------------------------------
940 {
941  // Transform the normal
942  VEC3 normal(m_rotation_matrix * m_normal);
943 
944  // Compute the plane equation
945  A = normal.getX();
946  B = normal.getY();
947  C = normal.getZ();
949 }
950 
951 
952 //----------------------------------------------------------------
953 inline const std::vector<float>& XRayDetector::getVertices() const
954 //----------------------------------------------------------------
955 {
957 }
958 
959 
960 //------------------------------------
962 //------------------------------------
963 {
965 }
966 
967 
968 
969 } // namespace gVirtualXRay
SourceShape
SourceShape is a type that defines the shape of X-ray sources.
Definition: XRayDetector.h:128
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.
Definition: Image.inl:694
bool useParallelBeam() const
Accessor on the flag about projection.
static Matrix4x4 buildTranslationMatrix(const Vec3< RATIONAL_NUMBER > &aVector)
Build a tranlation matrix.
Definition: Matrix4x4.inl:249
RATIONAL_NUMBER m_distance_source_detector
Distance between the source and the detector.
Definition: XRayDetector.h:748
std::auto_ptr< VBO > m_parallel_beam
The triangle mesh corresponding to the parallel beam.
Definition: XRayDetector.h:770
void setX(const T &aValue)
Set the position along the x-axis.
Definition: Vec2.inl:78
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.
Definition: Vec2.inl:86
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...
Definition: Scintillator.h:101
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.
Definition: XRayDetector.h:794
VEC3 m_xray_source_centre
The position of the source centre.
Definition: XRayDetector.h:724
void display()
Display the triangular mesh using OpenGL.
VEC3 m_normal
The vector normal to the detector.
Definition: XRayDetector.h:818
Image< RATIONAL_NUMBER > m_PSF
Impulse response of the detector as a point spread function.
Definition: XRayDetector.h:843
const VEC3 & getSourceSamplePosition(unsigned int aSampleID) const
void displaySourceWireframe()
Display the source using OpenGL.
double length() const
Get the length of the vector.
Definition: Vec3.inl:139
std::vector< RATIONAL_NUMBER > m_LSF
Impulse response of the detector as a line spread function.
Definition: XRayDetector.h:839
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.
Definition: Vec3.inl:115
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.
Definition: XRayDetector.h:756
const std::string & getScintillatorMaterial()
void setRightVector(const VEC3 &aRightVector)
Set the right vector that defines the detector&#39;s orientation.
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.
Definition: Vec3.inl:131
VEC2 m_size_in_unit_of_length
The size of the detector.
Definition: XRayDetector.h:740
void setRotationMatrix(const MATRIX4 &aMatrix)
Set the rotation matrix.
Vec3 normal() const
Get the unit vector corresponding to the normed current vector.
Definition: Vec3.inl:147
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.
Definition: XRayDetector.h:728
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.
Definition: XRayDetector.h:827
T getX() const
Accessor on the position along the x-axis.
Definition: Vec2.inl:94
MATRIX4 m_rotation_matrix
The rotation matrix.
Definition: XRayDetector.h:736
CubeMesh< float > m_first_pixel_mesh
Polygon mesh of the first pixel of the detector.
Definition: XRayDetector.h:809
Source whose shape corresponds to a square.
Definition: XRayDetector.h:131
Vec2ui m_size_in_number_of_pixels
Size of the detector (in number of pixels)
Definition: XRayDetector.h:752
void autoAlignDetector(bool aFlag=true)
VEC2 m_resolution_in_unit_of_length_per_pixel
Resolution (in unit of length per pixel)
Definition: XRayDetector.h:744
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.
Definition: Vec3.inl:123
static Matrix4x4 buildRotationMatrix(RATIONAL_NUMBER anAngle, RATIONAL_NUMBER x, RATIONAL_NUMBER y, RATIONAL_NUMBER z)
Build a rotation matrix.
Definition: Matrix4x4.inl:307
const std::string & getMaterial() const
SourceShape m_source_shape
Source type.
Definition: XRayDetector.h:814
RATIONAL_NUMBER m_fovy
Field of view along the Y-axis.
Definition: XRayDetector.h:831
const Vec2ui & getNumberOfPixels() const
Accessor on the number of pixels.
RATIONAL_NUMBER m_widget_length
The length of the widgets.
Definition: XRayDetector.h:801
std::auto_ptr< VBO > m_parallel_beam_highlight
The triangle mesh corresponding to the parallel beam highlight.
Definition: XRayDetector.h:786
std::vector< GLfloat > m_p_detector_geometry_vertices
Definition: XRayDetector.h:766
float RATIONAL_NUMBER
Type of data used to store real numbers.
Definition: Types.h:107
Source whose shape corresponds to a line segment.
Definition: XRayDetector.h:134
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.
Definition: Types.h:115
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.
Definition: XRayDetector.h:778
void normalize()
Normalize the current vector so that its length is 1.
Definition: Vec3.inl:155
const VEC3 & getDetectorPosition() const
Accessor on the detector position.
VEC3 m_detector_position
The position of the detector centre.
Definition: XRayDetector.h:720
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
Definition: Units.h:107
Vec2< RATIONAL_NUMBER > VEC2
Type of data used to store 2D vectors.
Definition: Types.h:111
Source whose shape corresponds to a cube.
Definition: XRayDetector.h:133
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.
Definition: XRayDetector.h:132
SphereMesh m_source_mesh
Polygon mesh of the source.
Definition: XRayDetector.h:805
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.
Definition: XRayDetector.h:130
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.
std::auto_ptr< VBO > m_detector_geometry
The triangle mesh corresponding to the detector.
Definition: XRayDetector.h:761
const double Pi
Pi.
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.
Definition: XRayDetector.h:732
T getY() const
Accessor on the position along the y-axis.
Definition: Vec2.inl:102
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&#39;s orientation.
void displaySource()
Display the source using OpenGL.
void popModelViewMatrix()
void setWidgetLength(const RATIONAL_NUMBER &aLength)
Scintillator m_scintillator
Scintillator.
Definition: XRayDetector.h:835
void create(double aLength=1.0 *cm, int anIndexDataType=0)
Create a new cube.
Definition: CubeMesh.inl:82
const VEC2 & getPixelSpacingInUnitOfLength() const
Accessor on the pixel spacing (in unit of length).