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  ITK_DISALLOW_COPY_AND_ASSIGN(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 
119  bool
120  AddProjection(const HomogeneousProjectionMatrixType & pMat);
121 
123  void
124  Clear() override;
125 
128  const std::vector<double> &
130  {
131  return this->m_GantryAngles;
132  }
133  const std::vector<double> &
135  {
136  return this->m_OutOfPlaneAngles;
137  }
138  const std::vector<double> &
140  {
141  return this->m_InPlaneAngles;
142  }
143  const std::vector<double> &
145  {
146  return this->m_SourceToIsocenterDistances;
147  }
148  const std::vector<double> &
150  {
151  return this->m_SourceOffsetsX;
152  }
153  const std::vector<double> &
155  {
156  return this->m_SourceOffsetsY;
157  }
158  const std::vector<double> &
160  {
161  return this->m_SourceToDetectorDistances;
162  }
163  const std::vector<double> &
165  {
166  return this->m_ProjectionOffsetsX;
167  }
168  const std::vector<double> &
170  {
171  return this->m_ProjectionOffsetsY;
172  }
174 
178  const std::vector<double> &
180  {
181  return this->m_SourceAngles;
182  }
183 
186  const std::vector<double>
187  GetTiltAngles() const;
188 
191  const std::multimap<double, unsigned int>
192  GetSortedAngles(const std::vector<double> & angles) const;
193 
196  const std::map<double, unsigned int>
197  GetUniqueSortedAngles(const std::vector<double> & angles) const;
198 
200  const std::vector<double>
201  GetAngularGapsWithNext(const std::vector<double> & angles) const;
202 
205  const std::vector<double>
206  GetAngularGaps(const std::vector<double> & angles);
207 
210  static ThreeDHomogeneousMatrixType
211  ComputeRotationHomogeneousMatrix(double angleX, double angleY, double angleZ);
212 
214  static TwoDHomogeneousMatrixType
215  ComputeTranslationHomogeneousMatrix(double transX, double transY);
216  static ThreeDHomogeneousMatrixType
217  ComputeTranslationHomogeneousMatrix(double transX, double transY, double transZ);
219 
222  static Superclass::MatrixType
223  ComputeProjectionMagnificationMatrix(double sdd, double sid);
224 
227  const std::vector<TwoDHomogeneousMatrixType> &
229  {
230  return this->m_ProjectionTranslationMatrices;
231  }
232  TwoDHomogeneousMatrixType
233  GetProjectionTranslationMatrix(const unsigned int i) const
234  {
235  return this->m_ProjectionTranslationMatrices[i];
236  }
238 
239  const std::vector<ThreeDHomogeneousMatrixType> &
241  {
242  return this->m_RotationMatrices;
243  }
244  ThreeDHomogeneousMatrixType
245  GetRotationMatrix(const unsigned int i) const
246  {
247  return this->m_RotationMatrices[i];
248  }
249 
250  const std::vector<ThreeDHomogeneousMatrixType> &
252  {
253  return this->m_SourceTranslationMatrices;
254  }
255  ThreeDHomogeneousMatrixType
256  GetSourceTranslationMatrices(const unsigned int i) const
257  {
258  return this->m_SourceTranslationMatrices[i];
259  }
260 
261  const std::vector<Superclass::MatrixType> &
263  {
264  return this->m_MagnificationMatrices;
265  }
266  Superclass::MatrixType
267  GetMagnificationMatrices(const unsigned int i) const
268  {
269  return this->m_MagnificationMatrices[i];
270  }
271 
272 
274  const std::vector<double> &
276  {
277  return this->m_CollimationUInf;
278  }
279  const std::vector<double> &
281  {
282  return this->m_CollimationUSup;
283  }
284  const std::vector<double> &
286  {
287  return this->m_CollimationVInf;
288  }
289  const std::vector<double> &
291  {
292  return this->m_CollimationVSup;
293  }
295 
298  void
299  SetCollimationOfLastProjection(const double uinf, const double usup, const double vinf, const double vsup);
300 
303  const HomogeneousVectorType
304  GetSourcePosition(const unsigned int i) const;
305 
311  const ThreeDHomogeneousMatrixType
312  GetProjectionCoordinatesToDetectorSystemMatrix(const unsigned int i) const;
313 
319  const ThreeDHomogeneousMatrixType
320  GetProjectionCoordinatesToFixedSystemMatrix(const unsigned int i) const;
321 
323  static double
324  ConvertAngleBetween0And360Degrees(const double a);
325 
327  static double
328  ConvertAngleBetween0And2PIRadians(const double a);
329 
331  static double
332  ConvertAngleBetweenMinusAndPlusPIRadians(const double a);
333 
338  double
339  ToUntiltedCoordinateAtIsocenter(const unsigned int noProj, const double tiltedCoord) const;
340 
343  itkGetConstMacro(RadiusCylindricalDetector, double);
344  itkSetMacro(RadiusCylindricalDetector, double);
346 
347 protected:
349  ~ThreeDCircularProjectionGeometry() override = default;
350 
351  virtual void
353  {
354  this->m_ProjectionTranslationMatrices.push_back(m);
355  this->Modified();
356  }
357  virtual void
359  {
360  this->m_RotationMatrices.push_back(m);
361  this->Modified();
362  }
363  virtual void
365  {
366  this->m_SourceTranslationMatrices.push_back(m);
367  this->Modified();
368  }
369  virtual void
370  AddMagnificationMatrix(const Superclass::MatrixType & m)
371  {
372  this->m_MagnificationMatrices.push_back(m);
373  this->Modified();
374  }
375 
392  bool
393  VerifyAngles(const double outOfPlaneAngleRAD,
394  const double gantryAngleRAD,
395  const double inPlaneAngleRAD,
396  const Matrix3x3Type & referenceMatrix) const;
398 
417  bool
418  FixAngles(double & outOfPlaneAngleRAD,
419  double & gantryAngleRAD,
420  double & inPlaneAngleRAD,
421  const Matrix3x3Type & referenceMatrix) const;
423 
426  InternalClone() const override;
427 
430  std::vector<double> m_GantryAngles;
431  std::vector<double> m_OutOfPlaneAngles;
432  std::vector<double> m_InPlaneAngles;
433  std::vector<double> m_SourceAngles;
434  std::vector<double> m_SourceToIsocenterDistances;
435  std::vector<double> m_SourceOffsetsX;
436  std::vector<double> m_SourceOffsetsY;
437  std::vector<double> m_SourceToDetectorDistances;
438  std::vector<double> m_ProjectionOffsetsX;
439  std::vector<double> m_ProjectionOffsetsY;
440 
442  double m_RadiusCylindricalDetector{ 0. };
443 
451  std::vector<double> m_CollimationUInf;
452  std::vector<double> m_CollimationUSup;
453  std::vector<double> m_CollimationVInf;
454  std::vector<double> m_CollimationVSup;
455 
457  std::vector<TwoDHomogeneousMatrixType> m_ProjectionTranslationMatrices;
458  std::vector<Superclass::MatrixType> m_MagnificationMatrices;
459  std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
460  std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;
461 };
462 } // namespace rtk
463 
464 
465 #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