Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
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  mitkNewMacro1Param( Self, ::map::core::RegistrationBase*);
43 
44  Identifiable::UIDType GetUID() const override;
45 
50  void SetRequestedRegionToLargestPossibleRegion() override;
51 
56  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
57 
62  bool VerifyRequestedRegion() override;
63 
68  void SetRequestedRegion(const itk::DataObject*) override;
69 
73  virtual unsigned int GetMovingDimensions() const;
74 
78  virtual unsigned int GetTargetDimensions() const;
79 
82  typedef ::map::core::RegistrationBase::TagType TagType;
84  typedef ::map::core::RegistrationBase::TagMapType TagMapType;
85 
90  const TagMapType& GetTags() const;
91 
96  bool GetTagValue(const TagType & tag, ValueType & value) const;
97 
106  bool HasLimitedTargetRepresentation() const;
107 
116  bool HasLimitedMovingRepresentation() const;
117 
127  template <unsigned int VMovingDim, unsigned int VTargetDim>
128  bool MapPoint(const ::itk::Point<mitk::ScalarType,VMovingDim>& inPoint, ::itk::Point<mitk::ScalarType,VTargetDim>& outPoint) const
129  {
130  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
131  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
132 
133  if (m_spRegistration.IsNull())
134  {
135  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
136  }
137 
138  bool result = false;
139 
140  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
141  {
142  MAPMovingPointType tempInP;
143  MAPTargetPointType tempOutP;
144  tempInP.CastFrom(inPoint);
145 
146  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
147  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
148 
149  if (!pCastedReg)
150  {
151  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
152  }
153 
154  result = pCastedReg->mapPoint(tempInP,tempOutP);
155  if (result)
156  {
157  outPoint.CastFrom(tempOutP);
158  }
159 
160  }
161 
162  return result;
163  };
164 
173  template <unsigned int VMovingDim, unsigned int VTargetDim>
174  bool MapPointInverse(const ::itk::Point<mitk::ScalarType,VTargetDim> & inPoint, ::itk::Point<mitk::ScalarType,VMovingDim> & outPoint) const
175 {
176  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
177  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
178 
179  if (m_spRegistration.IsNull())
180  {
181  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
182  }
183 
184  bool result = false;
185 
186  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
187  {
188  MAPTargetPointType tempInP;
189  MAPMovingPointType tempOutP;
190  tempInP.CastFrom(inPoint);
191 
192  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
193  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
194 
195  if (!pCastedReg)
196  {
197  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
198  }
199 
200  result = pCastedReg->mapPointInverse(tempInP,tempOutP);
201  if (result)
202  {
203  outPoint.CastFrom(tempOutP);
204  }
205 
206  }
207 
208  return result;
209 };
210 
220  mitk::Geometry3D GetDirectFieldRepresentation() const;
221 
231  mitk::Geometry3D GetInverseFieldRepresentation() const;
232 
238  void PrecomputeDirectMapping();
239 
245  void PrecomputeInverseMapping();
246 
247  ::map::core::RegistrationBase* GetRegistration();
248  const ::map::core::RegistrationBase* GetRegistration() const;
249 
250 protected:
251  void PrintSelf (std::ostream &os, itk::Indent indent) const override;
252 
253  MAPRegistrationWrapper(::map::core::RegistrationBase* registration);
254  ~MAPRegistrationWrapper() override;
255 
256  void SetUID(const UIDType& uid) override;
257 
258  ::map::core::RegistrationBase::Pointer m_spRegistration;
259 
260 private:
261 
262  MAPRegistrationWrapper& operator = (const MAPRegistrationWrapper&);
264 
265 };
266 
267 }
268 
269 #endif
270 
Standard implementation of BaseGeometry.
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
::map::core::RegistrationBase::ValueType ValueType
Base of all data objects.
Definition: mitkBaseData.h:42
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