Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 
18 #ifndef mitkMAPRegistrationWrapper_h
19 #define mitkMAPRegistrationWrapper_h
20 
21 //MITK
22 #include <mitkBaseData.h>
23 #include <mitkGeometry3D.h>
24 
25 //MatchPoint
26 #include <mapRegistrationBase.h>
27 #include <mapRegistration.h>
28 #include <mapExceptionObjectMacros.h>
29 #include <mapContinuousElements.h>
30 
31 //MITK
33 
34 namespace mitk
35 {
41 {
42 public:
43 
45 
46  itkNewMacro( Self );
47 
52  virtual void SetRequestedRegionToLargestPossibleRegion();
53 
58  virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
59 
64  virtual bool VerifyRequestedRegion();
65 
70  virtual void SetRequestedRegion(const itk::DataObject*);
71 
75  virtual unsigned int GetMovingDimensions() const;
76 
80  virtual unsigned int GetTargetDimensions() const;
81 
84  typedef ::map::core::RegistrationBase::TagType TagType;
86  typedef ::map::core::RegistrationBase::TagMapType TagMapType;
87 
92  const TagMapType& GetTags() const;
93 
98  bool GetTagValue(const TagType & tag, ValueType & value) const;
99 
108  bool HasLimitedTargetRepresentation() const;
109 
118  bool HasLimitedMovingRepresentation() const;
119 
129  template <unsigned int VMovingDim, unsigned int VTargetDim>
130  bool MapPoint(const ::itk::Point<mitk::ScalarType,VMovingDim>& inPoint, ::itk::Point<mitk::ScalarType,VTargetDim>& outPoint) const
131  {
132  typedef ::itk::Point<mitk::ScalarType,VMovingDim> MITKMovingPointType;
133  typedef ::itk::Point<mitk::ScalarType,VTargetDim> MITKTargetPointType;
136 
137  if (m_spRegistration.IsNull())
138  {
139  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (NULL). Point: " << inPoint);
140  }
141 
142  bool result = false;
143 
144  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
145  {
146  MAPMovingPointType tempInP;
147  MAPTargetPointType tempOutP;
148  tempInP.CastFrom(inPoint);
149 
150  typedef map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
151  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
152 
153  if (!pCastedReg)
154  {
155  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
156  }
157 
158  result = pCastedReg->mapPoint(tempInP,tempOutP);
159  if (result)
160  {
161  outPoint.CastFrom(tempOutP);
162  }
163 
164  }
165 
166  return result;
167  };
168 
177  template <unsigned int VMovingDim, unsigned int VTargetDim>
178  bool MapPointInverse(const ::itk::Point<mitk::ScalarType,VTargetDim> & inPoint, ::itk::Point<mitk::ScalarType,VMovingDim> & outPoint) const
179 {
180  typedef ::itk::Point<mitk::ScalarType,VMovingDim> MITKMovingPointType;
181  typedef ::itk::Point<mitk::ScalarType,VTargetDim> MITKTargetPointType;
184 
185  if (m_spRegistration.IsNull())
186  {
187  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (NULL). Point: " << inPoint);
188  }
189 
190  bool result = false;
191 
192  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
193  {
194  MAPTargetPointType tempInP;
195  MAPMovingPointType tempOutP;
196  tempInP.CastFrom(inPoint);
197 
198  typedef map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
199  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
200 
201  if (!pCastedReg)
202  {
203  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
204  }
205 
206  result = pCastedReg->mapPointInverse(tempInP,tempOutP);
207  if (result)
208  {
209  outPoint.CastFrom(tempOutP);
210  }
211 
212  }
213 
214  return result;
215 };
216 
226  mitk::Geometry3D GetDirectFieldRepresentation() const;
227 
237  mitk::Geometry3D GetInverseFieldRepresentation() const;
238 
244  void PrecomputeDirectMapping();
245 
251  void PrecomputeInverseMapping();
252 
253  map::core::RegistrationBase* GetRegistration();
254  const map::core::RegistrationBase* GetRegistration() const;
255 
256  void SetRegistration(map::core::RegistrationBase* pReg);
257 
258 protected:
259  virtual void PrintSelf (std::ostream &os, itk::Indent indent) const;
260 
262  virtual ~MAPRegistrationWrapper();
263 
265 
266 private:
267 
268  MAPRegistrationWrapper& operator = (const MAPRegistrationWrapper&);
270 
271 };
272 
273 }
274 
275 #endif
276 
mitk::Point3D PointType
itk::SmartPointer< Self > Pointer
Standard implementation of BaseGeometry.
::map::core::RegistrationBase::ValueType ValueType
Base of all data objects.
Definition: mitkBaseData.h:39
bool MapPoint(const ::itk::Point< mitk::ScalarType, VMovingDim > &inPoint,::itk::Point< mitk::ScalarType, VTargetDim > &outPoint) const
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
#define MITKMATCHPOINTREGISTRATION_EXPORT
ValueType
Type of the value held by a Value object.
Definition: jsoncpp.h:345
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
bool MapPointInverse(const ::itk::Point< mitk::ScalarType, VTargetDim > &inPoint,::itk::Point< mitk::ScalarType, VMovingDim > &outPoint) const
::map::core::RegistrationBase::TagMapType TagMapType
map::core::RegistrationBase::Pointer m_spRegistration