RTK  2.0.1
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 
67 
69  itkNewMacro( Self );
70 
75  void AddProjection(const double sid, const double sdd, const double gantryAngle,
76  const double projOffsetX=0., const double projOffsetY=0.,
77  const double outOfPlaneAngle=0., const double inPlaneAngle=0.,
78  const double sourceOffsetX=0., const double sourceOffsetY=0.);
79 
81  virtual void AddProjectionInRadians(const double sid, const double sdd, const double gantryAngle,
82  const double projOffsetX=0., const double projOffsetY=0.,
83  const double outOfPlaneAngle=0., const double inPlaneAngle=0.,
84  const double sourceOffsetX=0., const double sourceOffsetY=0.);
85 
96  bool AddProjection(const PointType &sourcePosition,
97  const PointType &detectorPosition,
98  const VectorType &detectorRowVector,
99  const VectorType &detectorColumnVector);
100 
101 
106  bool AddProjection(const HomogeneousProjectionMatrixType &pMat);
107 
109  void Clear() override;
110 
113  const std::vector<double> &GetGantryAngles() const {
114  return this->m_GantryAngles;
115  }
116  const std::vector<double> &GetOutOfPlaneAngles() const {
117  return this->m_OutOfPlaneAngles;
118  }
119  const std::vector<double> &GetInPlaneAngles() const {
120  return this->m_InPlaneAngles;
121  }
122  const std::vector<double> &GetSourceToIsocenterDistances() const {
123  return this->m_SourceToIsocenterDistances;
124  }
125  const std::vector<double> &GetSourceOffsetsX() const {
126  return this->m_SourceOffsetsX;
127  }
128  const std::vector<double> &GetSourceOffsetsY() const {
129  return this->m_SourceOffsetsY;
130  }
131  const std::vector<double> &GetSourceToDetectorDistances() const {
132  return this->m_SourceToDetectorDistances;
133  }
134  const std::vector<double> &GetProjectionOffsetsX() const {
135  return this->m_ProjectionOffsetsX;
136  }
137  const std::vector<double> &GetProjectionOffsetsY() const {
138  return this->m_ProjectionOffsetsY;
139  }
141 
145  const std::vector<double> &GetSourceAngles() const {
146  return this->m_SourceAngles;
147  }
148 
151  const std::vector<double> GetTiltAngles();
152 
155  const std::multimap<double,unsigned int> GetSortedAngles(const std::vector<double> &angles) const;
156 
159  const std::map<double,unsigned int> GetUniqueSortedAngles(const std::vector<double> &angles) const;
160 
162  const std::vector<double> GetAngularGapsWithNext(const std::vector<double> &angles) const;
163 
166  const std::vector<double> GetAngularGaps(const std::vector<double> &angles);
167 
171  ComputeRotationHomogeneousMatrix(double angleX,
172  double angleY,
173  double angleZ);
174 
177  ComputeTranslationHomogeneousMatrix(double transX,
178  double transY);
180  ComputeTranslationHomogeneousMatrix(double transX,
181  double transY,
182  double transZ);
184 
187  static Superclass::MatrixType ComputeProjectionMagnificationMatrix(double sdd,
188  double sid);
189 
192  const std::vector<TwoDHomogeneousMatrixType> &GetProjectionTranslationMatrices() const {
193  return this->m_ProjectionTranslationMatrices;
194  }
196  return this->m_ProjectionTranslationMatrices[i];
197  }
199 
200  const std::vector<ThreeDHomogeneousMatrixType> &GetRotationMatrices() const {
201  return this->m_RotationMatrices;
202  }
203  ThreeDHomogeneousMatrixType GetRotationMatrix(const unsigned int i) const {
204  return this->m_RotationMatrices[i];
205  }
206 
207  const std::vector<ThreeDHomogeneousMatrixType> &GetSourceTranslationMatrices() const {
208  return this->m_SourceTranslationMatrices;
209  }
211  return this->m_SourceTranslationMatrices[i];
212  }
213 
214  const std::vector<Superclass::MatrixType> &GetMagnificationMatrices() const {
215  return this->m_MagnificationMatrices;
216  }
217  Superclass::MatrixType GetMagnificationMatrices(const unsigned int i) const {
218  return this->m_MagnificationMatrices[i];
219  }
220 
221 
223  const std::vector<double> &GetCollimationUInf() const {
224  return this->m_CollimationUInf;
225  }
226  const std::vector<double> &GetCollimationUSup() const {
227  return this->m_CollimationUSup;
228  }
229  const std::vector<double> &GetCollimationVInf() const {
230  return this->m_CollimationVInf;
231  }
232  const std::vector<double> &GetCollimationVSup() const {
233  return this->m_CollimationVSup;
234  }
236 
239  void SetCollimationOfLastProjection(const double uinf,
240  const double usup,
241  const double vinf,
242  const double vsup);
243 
246  const HomogeneousVectorType GetSourcePosition(const unsigned int i) const;
247 
253  const ThreeDHomogeneousMatrixType GetProjectionCoordinatesToDetectorSystemMatrix(const unsigned int i) const;
254 
260  const ThreeDHomogeneousMatrixType GetProjectionCoordinatesToFixedSystemMatrix(const unsigned int i) const;
261 
263  static double ConvertAngleBetween0And360Degrees(const double a);
264 
266  static double ConvertAngleBetween0And2PIRadians(const double a);
267 
269  static double ConvertAngleBetweenMinusAndPlusPIRadians(const double a);
270 
275  double ToUntiltedCoordinateAtIsocenter(const unsigned int noProj,
276  const double tiltedCoord) const;
277 
280  itkGetConstMacro(RadiusCylindricalDetector, double)
281  itkSetMacro(RadiusCylindricalDetector, double)
282 
283 protected:
285  ~ThreeDCircularProjectionGeometry() override = default;
286 
288  this->m_ProjectionTranslationMatrices.push_back(m);
289  this->Modified();
290  }
292  this->m_RotationMatrices.push_back(m);
293  this->Modified();
294  }
296  this->m_SourceTranslationMatrices.push_back(m);
297  this->Modified();
298  }
300  this->m_MagnificationMatrices.push_back(m);
301  this->Modified();
302  }
303 
320  bool VerifyAngles(const double outOfPlaneAngleRAD, const double gantryAngleRAD,
321  const double inPlaneAngleRAD,
322  const Matrix3x3Type &referenceMatrix) const;
324 
343  bool FixAngles(double &outOfPlaneAngleRAD, double &gantryAngleRAD,
344  double &inPlaneAngleRAD,
345  const Matrix3x3Type &referenceMatrix) const;
347 
349  itk::LightObject::Pointer InternalClone() const override;
350 
353  std::vector<double> m_GantryAngles;
354  std::vector<double> m_OutOfPlaneAngles;
355  std::vector<double> m_InPlaneAngles;
356  std::vector<double> m_SourceAngles;
357  std::vector<double> m_SourceToIsocenterDistances;
358  std::vector<double> m_SourceOffsetsX;
359  std::vector<double> m_SourceOffsetsY;
360  std::vector<double> m_SourceToDetectorDistances;
361  std::vector<double> m_ProjectionOffsetsX;
362  std::vector<double> m_ProjectionOffsetsY;
363 
365  double m_RadiusCylindricalDetector{0.};
366 
374  std::vector<double> m_CollimationUInf;
375  std::vector<double> m_CollimationUSup;
376  std::vector<double> m_CollimationVInf;
377  std::vector<double> m_CollimationVSup;
378 
380  std::vector<TwoDHomogeneousMatrixType> m_ProjectionTranslationMatrices;
381  std::vector<Superclass::MatrixType> m_MagnificationMatrices;
382  std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
383  std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;
384 };
385 }
386 
387 
388 #endif // __rtkThreeDCircularProjectionGeometry_h
const std::vector< double > & GetOutOfPlaneAngles() const
const std::vector< double > & GetCollimationUSup() const
const std::vector< double > & GetCollimationVInf() const
std::vector< ThreeDHomogeneousMatrixType > m_SourceTranslationMatrices
const std::vector< double > & GetSourceToDetectorDistances() const
virtual void AddProjectionTranslationMatrix(const TwoDHomogeneousMatrixType &m)
ThreeDHomogeneousMatrixType GetRotationMatrix(const unsigned int i) const
const std::vector< Superclass::MatrixType > & GetMagnificationMatrices() const
typename itk::Matrix< double, TDimension, TDimension+1 > MatrixType
const std::vector< double > & GetSourceToIsocenterDistances() const
const std::vector< double > & GetGantryAngles() const
std::vector< ThreeDHomogeneousMatrixType > m_RotationMatrices
virtual void AddMagnificationMatrix(const Superclass::MatrixType &m)
const std::vector< TwoDHomogeneousMatrixType > & GetProjectionTranslationMatrices() const
Projection geometry for a source and a 2-D flat panel.
virtual void AddRotationMatrix(const ThreeDHomogeneousMatrixType &m)
A templated class holding a vector of M x (M+1) matrices.
ThreeDHomogeneousMatrixType GetSourceTranslationMatrices(const unsigned int i) const
const std::vector< double > & GetCollimationVSup() const
Superclass::MatrixType GetMagnificationMatrices(const unsigned int i) const
const std::vector< double > & GetSourceOffsetsX() const
const std::vector< double > & GetSourceAngles() const
virtual void AddSourceTranslationMatrix(const ThreeDHomogeneousMatrixType &m)
const std::vector< double > & GetCollimationUInf() const
const std::vector< double > & GetSourceOffsetsY() const
TwoDHomogeneousMatrixType GetProjectionTranslationMatrix(const unsigned int i) const
const std::vector< double > & GetProjectionOffsetsX() const
std::vector< TwoDHomogeneousMatrixType > m_ProjectionTranslationMatrices
const std::vector< ThreeDHomogeneousMatrixType > & GetRotationMatrices() const
const std::vector< ThreeDHomogeneousMatrixType > & GetSourceTranslationMatrices() const
const std::vector< double > & GetInPlaneAngles() const
std::vector< Superclass::MatrixType > m_MagnificationMatrices
const std::vector< double > & GetProjectionOffsetsY() const
#define itkSetMacro(name, type)