RTK  2.6.0
Reconstruction Toolkit
rtkThreeDCircularProjectionGeometry.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkThreeDCircularProjectionGeometry_h
20 #define rtkThreeDCircularProjectionGeometry_h
21 
22 #include "RTKExport.h"
23 #include "rtkProjectionGeometry.h"
24 
25 namespace rtk
26 {
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(ThreeDCircularProjectionGeometry);
54 
59 
66  using HomogeneousProjectionMatrixType = Superclass::MatrixType;
67 
69  itkNewMacro(Self);
70 
75  void
76  AddProjection(const double sid,
77  const double sdd,
78  const double gantryAngle,
79  const double projOffsetX = 0.,
80  const double projOffsetY = 0.,
81  const double outOfPlaneAngle = 0.,
82  const double inPlaneAngle = 0.,
83  const double sourceOffsetX = 0.,
84  const double sourceOffsetY = 0.);
85 
87  virtual void
88  AddProjectionInRadians(const double sid,
89  const double sdd,
90  const double gantryAngle,
91  const double projOffsetX = 0.,
92  const double projOffsetY = 0.,
93  const double outOfPlaneAngle = 0.,
94  const double inPlaneAngle = 0.,
95  const double sourceOffsetX = 0.,
96  const double sourceOffsetY = 0.);
97 
108  bool
109  AddProjection(const PointType & sourcePosition,
110  const PointType & detectorPosition,
111  const VectorType & detectorRowVector,
112  const VectorType & detectorColumnVector);
113 
114 
145  bool
146  AddProjection(const HomogeneousProjectionMatrixType & pMat);
147 
149  void
150  Clear() override;
151 
154  const std::vector<double> &
156  {
157  return this->m_GantryAngles;
158  }
159  const std::vector<double> &
161  {
162  return this->m_OutOfPlaneAngles;
163  }
164  const std::vector<double> &
166  {
167  return this->m_InPlaneAngles;
168  }
169  const std::vector<double> &
171  {
172  return this->m_SourceToIsocenterDistances;
173  }
174  const std::vector<double> &
176  {
177  return this->m_SourceOffsetsX;
178  }
179  const std::vector<double> &
181  {
182  return this->m_SourceOffsetsY;
183  }
184  const std::vector<double> &
186  {
187  return this->m_SourceToDetectorDistances;
188  }
189  const std::vector<double> &
191  {
192  return this->m_ProjectionOffsetsX;
193  }
194  const std::vector<double> &
196  {
197  return this->m_ProjectionOffsetsY;
198  }
200 
204  const std::vector<double> &
206  {
207  return this->m_SourceAngles;
208  }
209 
212  const std::vector<double>
213  GetTiltAngles() const;
214 
217  const std::multimap<double, unsigned int>
218  GetSortedAngles(const std::vector<double> & angles) const;
219 
222  const std::map<double, unsigned int>
223  GetUniqueSortedAngles(const std::vector<double> & angles) const;
224 
226  const std::vector<double>
227  GetAngularGapsWithNext(const std::vector<double> & angles) const;
228 
231  const std::vector<double>
232  GetAngularGaps(const std::vector<double> & angles);
233 
236  static ThreeDHomogeneousMatrixType
237  ComputeRotationHomogeneousMatrix(double angleX, double angleY, double angleZ);
238 
240  static TwoDHomogeneousMatrixType
241  ComputeTranslationHomogeneousMatrix(double transX, double transY);
242  static ThreeDHomogeneousMatrixType
243  ComputeTranslationHomogeneousMatrix(double transX, double transY, double transZ);
245 
248  static Superclass::MatrixType
249  ComputeProjectionMagnificationMatrix(double sdd, double sid);
250 
253  const std::vector<TwoDHomogeneousMatrixType> &
255  {
256  return this->m_ProjectionTranslationMatrices;
257  }
258  TwoDHomogeneousMatrixType
259  GetProjectionTranslationMatrix(const unsigned int i) const
260  {
261  return this->m_ProjectionTranslationMatrices[i];
262  }
264 
265  const std::vector<ThreeDHomogeneousMatrixType> &
267  {
268  return this->m_RotationMatrices;
269  }
270  ThreeDHomogeneousMatrixType
271  GetRotationMatrix(const unsigned int i) const
272  {
273  return this->m_RotationMatrices[i];
274  }
275 
276  const std::vector<ThreeDHomogeneousMatrixType> &
278  {
279  return this->m_SourceTranslationMatrices;
280  }
281  ThreeDHomogeneousMatrixType
282  GetSourceTranslationMatrices(const unsigned int i) const
283  {
284  return this->m_SourceTranslationMatrices[i];
285  }
286 
287  const std::vector<Superclass::MatrixType> &
289  {
290  return this->m_MagnificationMatrices;
291  }
292  Superclass::MatrixType
293  GetMagnificationMatrices(const unsigned int i) const
294  {
295  return this->m_MagnificationMatrices[i];
296  }
297 
299  const std::vector<double> &
301  {
302  return this->m_CollimationUInf;
303  }
304  const std::vector<double> &
306  {
307  return this->m_CollimationUSup;
308  }
309  const std::vector<double> &
311  {
312  return this->m_CollimationVInf;
313  }
314  const std::vector<double> &
316  {
317  return this->m_CollimationVSup;
318  }
320 
323  void
324  SetCollimationOfLastProjection(const double uinf, const double usup, const double vinf, const double vsup);
325 
328  const HomogeneousVectorType
329  GetSourcePosition(const unsigned int i) const;
330 
336  const ThreeDHomogeneousMatrixType
337  GetProjectionCoordinatesToDetectorSystemMatrix(const unsigned int i) const;
338 
344  const ThreeDHomogeneousMatrixType
345  GetProjectionCoordinatesToFixedSystemMatrix(const unsigned int i) const;
346 
348  static double
349  ConvertAngleBetween0And360Degrees(const double a);
350 
352  static double
353  ConvertAngleBetween0And2PIRadians(const double a);
354 
356  static double
357  ConvertAngleBetweenMinusAndPlusPIRadians(const double a);
358 
363  double
364  ToUntiltedCoordinateAtIsocenter(const unsigned int noProj, const double tiltedCoord) const;
365 
368  itkGetConstMacro(RadiusCylindricalDetector, double);
369  itkSetMacro(RadiusCylindricalDetector, double);
371 
373  itkGetConstMacro(VerifyAnglesTolerance, double);
374  itkSetMacro(VerifyAnglesTolerance, double);
376 
377  itkGetConstMacro(FixAnglesTolerance, double);
378  itkSetMacro(FixAnglesTolerance, double);
379 
380 protected:
382  ~ThreeDCircularProjectionGeometry() override = default;
383 
384  virtual void
386  {
387  this->m_ProjectionTranslationMatrices.push_back(m);
388  this->Modified();
389  }
390  virtual void
392  {
393  this->m_RotationMatrices.push_back(m);
394  this->Modified();
395  }
396  virtual void
398  {
399  this->m_SourceTranslationMatrices.push_back(m);
400  this->Modified();
401  }
402  virtual void
403  AddMagnificationMatrix(const Superclass::MatrixType & m)
404  {
405  this->m_MagnificationMatrices.push_back(m);
406  this->Modified();
407  }
408 
425  bool
426  VerifyAngles(const double outOfPlaneAngleRAD,
427  const double gantryAngleRAD,
428  const double inPlaneAngleRAD,
429  const Matrix3x3Type & referenceMatrix) const;
431 
450  bool
451  FixAngles(double & outOfPlaneAngleRAD,
452  double & gantryAngleRAD,
453  double & inPlaneAngleRAD,
454  const Matrix3x3Type & referenceMatrix) const;
456 
459  InternalClone() const override;
460 
463  std::vector<double> m_GantryAngles;
464  std::vector<double> m_OutOfPlaneAngles;
465  std::vector<double> m_InPlaneAngles;
466  std::vector<double> m_SourceAngles;
467  std::vector<double> m_SourceToIsocenterDistances;
468  std::vector<double> m_SourceOffsetsX;
469  std::vector<double> m_SourceOffsetsY;
470  std::vector<double> m_SourceToDetectorDistances;
471  std::vector<double> m_ProjectionOffsetsX;
472  std::vector<double> m_ProjectionOffsetsY;
473 
475  double m_RadiusCylindricalDetector{ 0. };
476 
484  std::vector<double> m_CollimationUInf;
485  std::vector<double> m_CollimationUSup;
486  std::vector<double> m_CollimationVInf;
487  std::vector<double> m_CollimationVSup;
488 
490  std::vector<TwoDHomogeneousMatrixType> m_ProjectionTranslationMatrices;
491  std::vector<Superclass::MatrixType> m_MagnificationMatrices;
492  std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
493  std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;
494 
496  double m_VerifyAnglesTolerance{ 1e-4 };
497  double m_FixAnglesTolerance{ 1e-6 };
498 };
499 } // namespace rtk
500 
501 
502 #endif // __rtkThreeDCircularProjectionGeometry_h
std::vector< ThreeDHomogeneousMatrixType > m_SourceTranslationMatrices
const std::vector< double > & GetSourceAngles() const
virtual void AddProjectionTranslationMatrix(const TwoDHomogeneousMatrixType &m)
const std::vector< double > & GetSourceOffsetsY() const
ThreeDHomogeneousMatrixType GetRotationMatrix(const unsigned int i) const
Superclass::MatrixType GetMagnificationMatrices(const unsigned int i) const
const std::vector< ThreeDHomogeneousMatrixType > & GetSourceTranslationMatrices() const
const std::vector< double > & GetInPlaneAngles() const
std::vector< ThreeDHomogeneousMatrixType > m_RotationMatrices
virtual void AddMagnificationMatrix(const Superclass::MatrixType &m)
Projection geometry for a source and a 2-D flat panel.
const std::vector< double > & GetGantryAngles() const
#define itkSetMacro(name, type)
virtual void AddRotationMatrix(const ThreeDHomogeneousMatrixType &m)
const std::vector< ThreeDHomogeneousMatrixType > & GetRotationMatrices() const
const std::vector< TwoDHomogeneousMatrixType > & GetProjectionTranslationMatrices() const
A templated class holding a vector of M x (M+1) matrices.
const std::vector< double > & GetSourceToIsocenterDistances() const
const std::vector< double > & GetProjectionOffsetsY() const
TwoDHomogeneousMatrixType GetProjectionTranslationMatrix(const unsigned int i) const
const std::vector< double > & GetProjectionOffsetsX() const
virtual void AddSourceTranslationMatrix(const ThreeDHomogeneousMatrixType &m)
ThreeDHomogeneousMatrixType GetSourceTranslationMatrices(const unsigned int i) const
std::vector< TwoDHomogeneousMatrixType > m_ProjectionTranslationMatrices
const std::vector< Superclass::MatrixType > & GetMagnificationMatrices() const
const std::vector< double > & GetSourceOffsetsX() const
const std::vector< double > & GetCollimationUInf() const
const std::vector< double > & GetSourceToDetectorDistances() const
const std::vector< double > & GetOutOfPlaneAngles() const
const std::vector< double > & GetCollimationVInf() const
const std::vector< double > & GetCollimationVSup() const
const std::vector< double > & GetCollimationUSup() const
std::vector< Superclass::MatrixType > m_MagnificationMatrices