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 {
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_MOVE(ThreeDCircularProjectionGeometry);
55 
60 
67  using HomogeneousProjectionMatrixType = Superclass::MatrixType;
68 
70  itkNewMacro(Self);
71 
76  void
77  AddProjection(const double sid,
78  const double sdd,
79  const double gantryAngle,
80  const double projOffsetX = 0.,
81  const double projOffsetY = 0.,
82  const double outOfPlaneAngle = 0.,
83  const double inPlaneAngle = 0.,
84  const double sourceOffsetX = 0.,
85  const double sourceOffsetY = 0.);
86 
88  virtual void
89  AddProjectionInRadians(const double sid,
90  const double sdd,
91  const double gantryAngle,
92  const double projOffsetX = 0.,
93  const double projOffsetY = 0.,
94  const double outOfPlaneAngle = 0.,
95  const double inPlaneAngle = 0.,
96  const double sourceOffsetX = 0.,
97  const double sourceOffsetY = 0.);
98 
109  bool
110  AddProjection(const PointType & sourcePosition,
111  const PointType & detectorPosition,
112  const VectorType & detectorRowVector,
113  const VectorType & detectorColumnVector);
114 
115 
146  bool
147  AddProjection(const HomogeneousProjectionMatrixType & pMat);
148 
150  void
151  Clear() override;
152 
155  const std::vector<double> &
157  {
158  return this->m_GantryAngles;
159  }
160  const std::vector<double> &
162  {
163  return this->m_OutOfPlaneAngles;
164  }
165  const std::vector<double> &
167  {
168  return this->m_InPlaneAngles;
169  }
170  const std::vector<double> &
172  {
173  return this->m_SourceToIsocenterDistances;
174  }
175  const std::vector<double> &
177  {
178  return this->m_SourceOffsetsX;
179  }
180  const std::vector<double> &
182  {
183  return this->m_SourceOffsetsY;
184  }
185  const std::vector<double> &
187  {
188  return this->m_SourceToDetectorDistances;
189  }
190  const std::vector<double> &
192  {
193  return this->m_ProjectionOffsetsX;
194  }
195  const std::vector<double> &
197  {
198  return this->m_ProjectionOffsetsY;
199  }
201 
205  const std::vector<double> &
207  {
208  return this->m_SourceAngles;
209  }
210 
213  const std::vector<double>
214  GetTiltAngles() const;
215 
218  const std::multimap<double, unsigned int>
219  GetSortedAngles(const std::vector<double> & angles) const;
220 
223  const std::map<double, unsigned int>
224  GetUniqueSortedAngles(const std::vector<double> & angles) const;
225 
227  const std::vector<double>
228  GetAngularGapsWithNext(const std::vector<double> & angles) const;
229 
232  const std::vector<double>
233  GetAngularGaps(const std::vector<double> & angles);
234 
237  static ThreeDHomogeneousMatrixType
238  ComputeRotationHomogeneousMatrix(double angleX, double angleY, double angleZ);
239 
241  static TwoDHomogeneousMatrixType
242  ComputeTranslationHomogeneousMatrix(double transX, double transY);
243  static ThreeDHomogeneousMatrixType
244  ComputeTranslationHomogeneousMatrix(double transX, double transY, double transZ);
246 
249  static Superclass::MatrixType
250  ComputeProjectionMagnificationMatrix(double sdd, double sid);
251 
254  const std::vector<TwoDHomogeneousMatrixType> &
256  {
257  return this->m_ProjectionTranslationMatrices;
258  }
259  TwoDHomogeneousMatrixType
260  GetProjectionTranslationMatrix(const unsigned int i) const
261  {
262  return this->m_ProjectionTranslationMatrices[i];
263  }
265 
266  const std::vector<ThreeDHomogeneousMatrixType> &
268  {
269  return this->m_RotationMatrices;
270  }
271  ThreeDHomogeneousMatrixType
272  GetRotationMatrix(const unsigned int i) const
273  {
274  return this->m_RotationMatrices[i];
275  }
276 
277  const std::vector<ThreeDHomogeneousMatrixType> &
279  {
280  return this->m_SourceTranslationMatrices;
281  }
282  ThreeDHomogeneousMatrixType
283  GetSourceTranslationMatrices(const unsigned int i) const
284  {
285  return this->m_SourceTranslationMatrices[i];
286  }
287 
288  const std::vector<Superclass::MatrixType> &
290  {
291  return this->m_MagnificationMatrices;
292  }
293  Superclass::MatrixType
294  GetMagnificationMatrices(const unsigned int i) const
295  {
296  return this->m_MagnificationMatrices[i];
297  }
298 
300  const std::vector<double> &
302  {
303  return this->m_CollimationUInf;
304  }
305  const std::vector<double> &
307  {
308  return this->m_CollimationUSup;
309  }
310  const std::vector<double> &
312  {
313  return this->m_CollimationVInf;
314  }
315  const std::vector<double> &
317  {
318  return this->m_CollimationVSup;
319  }
321 
324  void
325  SetCollimationOfLastProjection(const double uinf, const double usup, const double vinf, const double vsup);
326 
329  const HomogeneousVectorType
330  GetSourcePosition(const unsigned int i) const;
331 
337  const ThreeDHomogeneousMatrixType
338  GetProjectionCoordinatesToDetectorSystemMatrix(const unsigned int i) const;
339 
345  const ThreeDHomogeneousMatrixType
346  GetProjectionCoordinatesToFixedSystemMatrix(const unsigned int i) const;
347 
349  static double
350  ConvertAngleBetween0And360Degrees(const double a);
351 
353  static double
354  ConvertAngleBetween0And2PIRadians(const double a);
355 
357  static double
358  ConvertAngleBetweenMinusAndPlusPIRadians(const double a);
359 
364  double
365  ToUntiltedCoordinateAtIsocenter(const unsigned int noProj, const double tiltedCoord) const;
366 
369  itkGetConstMacro(RadiusCylindricalDetector, double);
370  itkSetMacro(RadiusCylindricalDetector, double);
372 
374  itkGetConstMacro(VerifyAnglesTolerance, double);
375  itkSetMacro(VerifyAnglesTolerance, double);
377 
378  itkGetConstMacro(FixAnglesTolerance, double);
379  itkSetMacro(FixAnglesTolerance, double);
380 
381 protected:
383  ~ThreeDCircularProjectionGeometry() override = default;
384 
385  virtual void
387  {
388  this->m_ProjectionTranslationMatrices.push_back(m);
389  this->Modified();
390  }
391  virtual void
393  {
394  this->m_RotationMatrices.push_back(m);
395  this->Modified();
396  }
397  virtual void
399  {
400  this->m_SourceTranslationMatrices.push_back(m);
401  this->Modified();
402  }
403  virtual void
404  AddMagnificationMatrix(const Superclass::MatrixType & m)
405  {
406  this->m_MagnificationMatrices.push_back(m);
407  this->Modified();
408  }
409 
426  bool
427  VerifyAngles(const double outOfPlaneAngleRAD,
428  const double gantryAngleRAD,
429  const double inPlaneAngleRAD,
430  const Matrix3x3Type & referenceMatrix) const;
432 
451  bool
452  FixAngles(double & outOfPlaneAngleRAD,
453  double & gantryAngleRAD,
454  double & inPlaneAngleRAD,
455  const Matrix3x3Type & referenceMatrix) const;
457 
460  InternalClone() const override;
461 
464  std::vector<double> m_GantryAngles;
465  std::vector<double> m_OutOfPlaneAngles;
466  std::vector<double> m_InPlaneAngles;
467  std::vector<double> m_SourceAngles;
468  std::vector<double> m_SourceToIsocenterDistances;
469  std::vector<double> m_SourceOffsetsX;
470  std::vector<double> m_SourceOffsetsY;
471  std::vector<double> m_SourceToDetectorDistances;
472  std::vector<double> m_ProjectionOffsetsX;
473  std::vector<double> m_ProjectionOffsetsY;
474 
476  double m_RadiusCylindricalDetector{ 0. };
477 
485  std::vector<double> m_CollimationUInf;
486  std::vector<double> m_CollimationUSup;
487  std::vector<double> m_CollimationVInf;
488  std::vector<double> m_CollimationVSup;
489 
491  std::vector<TwoDHomogeneousMatrixType> m_ProjectionTranslationMatrices;
492  std::vector<Superclass::MatrixType> m_MagnificationMatrices;
493  std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
494  std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;
495 
497  double m_VerifyAnglesTolerance{ 1e-4 };
498  double m_FixAnglesTolerance{ 1e-6 };
499 };
500 } // namespace rtk
501 
502 
503 #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