RTK  2.1.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  * http://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 #if ITK_VERSION_MAJOR == 5 && ITK_VERSION_MINOR == 1
54  ITK_DISALLOW_COPY_AND_ASSIGN(ThreeDCircularProjectionGeometry);
55 #else
56  ITK_DISALLOW_COPY_AND_MOVE(ThreeDCircularProjectionGeometry);
57 #endif
58 
63 
70  using HomogeneousProjectionMatrixType = Superclass::MatrixType;
71 
73  itkNewMacro(Self);
74 
79  void
80  AddProjection(const double sid,
81  const double sdd,
82  const double gantryAngle,
83  const double projOffsetX = 0.,
84  const double projOffsetY = 0.,
85  const double outOfPlaneAngle = 0.,
86  const double inPlaneAngle = 0.,
87  const double sourceOffsetX = 0.,
88  const double sourceOffsetY = 0.);
89 
91  virtual void
92  AddProjectionInRadians(const double sid,
93  const double sdd,
94  const double gantryAngle,
95  const double projOffsetX = 0.,
96  const double projOffsetY = 0.,
97  const double outOfPlaneAngle = 0.,
98  const double inPlaneAngle = 0.,
99  const double sourceOffsetX = 0.,
100  const double sourceOffsetY = 0.);
101 
112  bool
113  AddProjection(const PointType & sourcePosition,
114  const PointType & detectorPosition,
115  const VectorType & detectorRowVector,
116  const VectorType & detectorColumnVector);
117 
118 
123  bool
124  AddProjection(const HomogeneousProjectionMatrixType & pMat);
125 
127  void
128  Clear() override;
129 
132  const std::vector<double> &
134  {
135  return this->m_GantryAngles;
136  }
137  const std::vector<double> &
139  {
140  return this->m_OutOfPlaneAngles;
141  }
142  const std::vector<double> &
144  {
145  return this->m_InPlaneAngles;
146  }
147  const std::vector<double> &
149  {
150  return this->m_SourceToIsocenterDistances;
151  }
152  const std::vector<double> &
154  {
155  return this->m_SourceOffsetsX;
156  }
157  const std::vector<double> &
159  {
160  return this->m_SourceOffsetsY;
161  }
162  const std::vector<double> &
164  {
165  return this->m_SourceToDetectorDistances;
166  }
167  const std::vector<double> &
169  {
170  return this->m_ProjectionOffsetsX;
171  }
172  const std::vector<double> &
174  {
175  return this->m_ProjectionOffsetsY;
176  }
178 
182  const std::vector<double> &
184  {
185  return this->m_SourceAngles;
186  }
187 
190  const std::vector<double>
191  GetTiltAngles() const;
192 
195  const std::multimap<double, unsigned int>
196  GetSortedAngles(const std::vector<double> & angles) const;
197 
200  const std::map<double, unsigned int>
201  GetUniqueSortedAngles(const std::vector<double> & angles) const;
202 
204  const std::vector<double>
205  GetAngularGapsWithNext(const std::vector<double> & angles) const;
206 
209  const std::vector<double>
210  GetAngularGaps(const std::vector<double> & angles);
211 
214  static ThreeDHomogeneousMatrixType
215  ComputeRotationHomogeneousMatrix(double angleX, double angleY, double angleZ);
216 
218  static TwoDHomogeneousMatrixType
219  ComputeTranslationHomogeneousMatrix(double transX, double transY);
220  static ThreeDHomogeneousMatrixType
221  ComputeTranslationHomogeneousMatrix(double transX, double transY, double transZ);
223 
226  static Superclass::MatrixType
227  ComputeProjectionMagnificationMatrix(double sdd, double sid);
228 
231  const std::vector<TwoDHomogeneousMatrixType> &
233  {
234  return this->m_ProjectionTranslationMatrices;
235  }
236  TwoDHomogeneousMatrixType
237  GetProjectionTranslationMatrix(const unsigned int i) const
238  {
239  return this->m_ProjectionTranslationMatrices[i];
240  }
242 
243  const std::vector<ThreeDHomogeneousMatrixType> &
245  {
246  return this->m_RotationMatrices;
247  }
248  ThreeDHomogeneousMatrixType
249  GetRotationMatrix(const unsigned int i) const
250  {
251  return this->m_RotationMatrices[i];
252  }
253 
254  const std::vector<ThreeDHomogeneousMatrixType> &
256  {
257  return this->m_SourceTranslationMatrices;
258  }
259  ThreeDHomogeneousMatrixType
260  GetSourceTranslationMatrices(const unsigned int i) const
261  {
262  return this->m_SourceTranslationMatrices[i];
263  }
264 
265  const std::vector<Superclass::MatrixType> &
267  {
268  return this->m_MagnificationMatrices;
269  }
270  Superclass::MatrixType
271  GetMagnificationMatrices(const unsigned int i) const
272  {
273  return this->m_MagnificationMatrices[i];
274  }
275 
276 
278  const std::vector<double> &
280  {
281  return this->m_CollimationUInf;
282  }
283  const std::vector<double> &
285  {
286  return this->m_CollimationUSup;
287  }
288  const std::vector<double> &
290  {
291  return this->m_CollimationVInf;
292  }
293  const std::vector<double> &
295  {
296  return this->m_CollimationVSup;
297  }
299 
302  void
303  SetCollimationOfLastProjection(const double uinf, const double usup, const double vinf, const double vsup);
304 
307  const HomogeneousVectorType
308  GetSourcePosition(const unsigned int i) const;
309 
315  const ThreeDHomogeneousMatrixType
316  GetProjectionCoordinatesToDetectorSystemMatrix(const unsigned int i) const;
317 
323  const ThreeDHomogeneousMatrixType
324  GetProjectionCoordinatesToFixedSystemMatrix(const unsigned int i) const;
325 
327  static double
328  ConvertAngleBetween0And360Degrees(const double a);
329 
331  static double
332  ConvertAngleBetween0And2PIRadians(const double a);
333 
335  static double
336  ConvertAngleBetweenMinusAndPlusPIRadians(const double a);
337 
342  double
343  ToUntiltedCoordinateAtIsocenter(const unsigned int noProj, const double tiltedCoord) const;
344 
347  itkGetConstMacro(RadiusCylindricalDetector, double);
348  itkSetMacro(RadiusCylindricalDetector, double);
350 
351 protected:
353  ~ThreeDCircularProjectionGeometry() override = default;
354 
355  virtual void
357  {
358  this->m_ProjectionTranslationMatrices.push_back(m);
359  this->Modified();
360  }
361  virtual void
363  {
364  this->m_RotationMatrices.push_back(m);
365  this->Modified();
366  }
367  virtual void
369  {
370  this->m_SourceTranslationMatrices.push_back(m);
371  this->Modified();
372  }
373  virtual void
374  AddMagnificationMatrix(const Superclass::MatrixType & m)
375  {
376  this->m_MagnificationMatrices.push_back(m);
377  this->Modified();
378  }
379 
396  bool
397  VerifyAngles(const double outOfPlaneAngleRAD,
398  const double gantryAngleRAD,
399  const double inPlaneAngleRAD,
400  const Matrix3x3Type & referenceMatrix) const;
402 
421  bool
422  FixAngles(double & outOfPlaneAngleRAD,
423  double & gantryAngleRAD,
424  double & inPlaneAngleRAD,
425  const Matrix3x3Type & referenceMatrix) const;
427 
430  InternalClone() const override;
431 
434  std::vector<double> m_GantryAngles;
435  std::vector<double> m_OutOfPlaneAngles;
436  std::vector<double> m_InPlaneAngles;
437  std::vector<double> m_SourceAngles;
438  std::vector<double> m_SourceToIsocenterDistances;
439  std::vector<double> m_SourceOffsetsX;
440  std::vector<double> m_SourceOffsetsY;
441  std::vector<double> m_SourceToDetectorDistances;
442  std::vector<double> m_ProjectionOffsetsX;
443  std::vector<double> m_ProjectionOffsetsY;
444 
446  double m_RadiusCylindricalDetector{ 0. };
447 
455  std::vector<double> m_CollimationUInf;
456  std::vector<double> m_CollimationUSup;
457  std::vector<double> m_CollimationVInf;
458  std::vector<double> m_CollimationVSup;
459 
461  std::vector<TwoDHomogeneousMatrixType> m_ProjectionTranslationMatrices;
462  std::vector<Superclass::MatrixType> m_MagnificationMatrices;
463  std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
464  std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;
465 };
466 } // namespace rtk
467 
468 
469 #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