Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkMAPRegistrationWrapper.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef mitkMAPRegistrationWrapper_h
15 #define mitkMAPRegistrationWrapper_h
16 
17 //MITK
18 #include <mitkBaseData.h>
19 #include <mitkGeometry3D.h>
20 
21 //MatchPoint
22 #include <mapRegistrationBase.h>
23 #include <mapRegistration.h>
24 #include <mapExceptionObjectMacros.h>
25 #include <mapContinuousElements.h>
26 
27 //MITK
29 
30 namespace mitk
31 {
37 {
38 public:
39 
41 
42  itkNewMacro( Self );
43 
48  void SetRequestedRegionToLargestPossibleRegion() override;
49 
54  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
55 
60  bool VerifyRequestedRegion() override;
61 
66  void SetRequestedRegion(const itk::DataObject*) override;
67 
71  virtual unsigned int GetMovingDimensions() const;
72 
76  virtual unsigned int GetTargetDimensions() const;
77 
80  typedef ::map::core::RegistrationBase::TagType TagType;
82  typedef ::map::core::RegistrationBase::TagMapType TagMapType;
83 
88  const TagMapType& GetTags() const;
89 
94  bool GetTagValue(const TagType & tag, ValueType & value) const;
95 
104  bool HasLimitedTargetRepresentation() const;
105 
114  bool HasLimitedMovingRepresentation() const;
115 
125  template <unsigned int VMovingDim, unsigned int VTargetDim>
126  bool MapPoint(const ::itk::Point<mitk::ScalarType,VMovingDim>& inPoint, ::itk::Point<mitk::ScalarType,VTargetDim>& outPoint) const
127  {
128  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
129  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
130 
131  if (m_spRegistration.IsNull())
132  {
133  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
134  }
135 
136  bool result = false;
137 
138  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
139  {
140  MAPMovingPointType tempInP;
141  MAPTargetPointType tempOutP;
142  tempInP.CastFrom(inPoint);
143 
144  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
145  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
146 
147  if (!pCastedReg)
148  {
149  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
150  }
151 
152  result = pCastedReg->mapPoint(tempInP,tempOutP);
153  if (result)
154  {
155  outPoint.CastFrom(tempOutP);
156  }
157 
158  }
159 
160  return result;
161  };
162 
171  template <unsigned int VMovingDim, unsigned int VTargetDim>
172  bool MapPointInverse(const ::itk::Point<mitk::ScalarType,VTargetDim> & inPoint, ::itk::Point<mitk::ScalarType,VMovingDim> & outPoint) const
173 {
174  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
175  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
176 
177  if (m_spRegistration.IsNull())
178  {
179  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
180  }
181 
182  bool result = false;
183 
184  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
185  {
186  MAPTargetPointType tempInP;
187  MAPMovingPointType tempOutP;
188  tempInP.CastFrom(inPoint);
189 
190  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
191  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
192 
193  if (!pCastedReg)
194  {
195  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
196  }
197 
198  result = pCastedReg->mapPointInverse(tempInP,tempOutP);
199  if (result)
200  {
201  outPoint.CastFrom(tempOutP);
202  }
203 
204  }
205 
206  return result;
207 };
208 
218  mitk::Geometry3D GetDirectFieldRepresentation() const;
219 
229  mitk::Geometry3D GetInverseFieldRepresentation() const;
230 
236  void PrecomputeDirectMapping();
237 
243  void PrecomputeInverseMapping();
244 
245  ::map::core::RegistrationBase* GetRegistration();
246  const ::map::core::RegistrationBase* GetRegistration() const;
247 
248  void SetRegistration(::map::core::RegistrationBase* pReg);
249 
250 protected:
251  void PrintSelf (std::ostream &os, itk::Indent indent) const override;
252 
254  ~MAPRegistrationWrapper() override;
255 
256  ::map::core::RegistrationBase::Pointer m_spRegistration;
257 
258 private:
259 
260  MAPRegistrationWrapper& operator = (const MAPRegistrationWrapper&);
262 
263 };
264 
265 }
266 
267 #endif
268 
Standard implementation of BaseGeometry.
::map::core::RegistrationBase::ValueType ValueType
Base of all data objects.
Definition: mitkBaseData.h:37
DataCollection - Class to facilitate loading/accessing structured data.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
::map::core::RegistrationBase::TagType TagType
bool MapPoint(const ::itk::Point< mitk::ScalarType, VMovingDim > &inPoint, ::itk::Point< mitk::ScalarType, VTargetDim > &outPoint) const
#define MITKMATCHPOINTREGISTRATION_EXPORT
ValueType
Type of the value held by a Value object.
Definition: jsoncpp.h:345
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
::map::core::RegistrationBase::Pointer m_spRegistration
::map::core::RegistrationBase::TagMapType TagMapType
bool MapPointInverse(const ::itk::Point< mitk::ScalarType, VTargetDim > &inPoint, ::itk::Point< mitk::ScalarType, VMovingDim > &outPoint) const