Medical Imaging Interaction Toolkit  2023.12.99-63768887
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 
46  bool IsEmptyTimeStep(unsigned int t) const override;
47 
48  bool IsEmpty() const override;
49 
54  void SetRequestedRegionToLargestPossibleRegion() override;
55 
60  bool RequestedRegionIsOutsideOfTheBufferedRegion() override;
61 
66  bool VerifyRequestedRegion() override;
67 
72  void SetRequestedRegion(const itk::DataObject*) override;
73 
77  virtual unsigned int GetMovingDimensions() const;
78 
82  virtual unsigned int GetTargetDimensions() const;
83 
86  typedef ::map::core::RegistrationBase::TagType TagType;
87  typedef ::map::core::RegistrationBase::ValueType ValueType;
88  typedef ::map::core::RegistrationBase::TagMapType TagMapType;
89 
94  const TagMapType& GetTags() const;
95 
100  bool GetTagValue(const TagType & tag, ValueType & value) const;
101 
110  bool HasLimitedTargetRepresentation() const;
111 
120  bool HasLimitedMovingRepresentation() const;
121 
131  template <unsigned int VMovingDim, unsigned int VTargetDim>
132  bool MapPoint(const ::itk::Point<mitk::ScalarType,VMovingDim>& inPoint, ::itk::Point<mitk::ScalarType,VTargetDim>& outPoint) const
133  {
134  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
135  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
136 
137  if (m_spRegistration.IsNull())
138  {
139  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). 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 typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
181  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
182 
183  if (m_spRegistration.IsNull())
184  {
185  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
186  }
187 
188  bool result = false;
189 
190  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
191  {
192  MAPTargetPointType tempInP;
193  MAPMovingPointType tempOutP;
194  tempInP.CastFrom(inPoint);
195 
196  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
197  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
198 
199  if (!pCastedReg)
200  {
201  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
202  }
203 
204  result = pCastedReg->mapPointInverse(tempInP,tempOutP);
205  if (result)
206  {
207  outPoint.CastFrom(tempOutP);
208  }
209 
210  }
211 
212  return result;
213 };
214 
224  mitk::Geometry3D GetDirectFieldRepresentation() const;
225 
235  mitk::Geometry3D GetInverseFieldRepresentation() const;
236 
242  void PrecomputeDirectMapping();
243 
249  void PrecomputeInverseMapping();
250 
251  ::map::core::RegistrationBase* GetRegistration();
252  const ::map::core::RegistrationBase* GetRegistration() const;
253 
254 protected:
255  void PrintSelf (std::ostream &os, itk::Indent indent) const override;
256 
257  MAPRegistrationWrapper(::map::core::RegistrationBase* registration);
258  ~MAPRegistrationWrapper() override;
259 
260  void SetUID(const UIDType& uid) override;
261 
262  ::map::core::RegistrationBase::Pointer m_spRegistration;
263 
264 private:
265 
266  MAPRegistrationWrapper& operator = (const MAPRegistrationWrapper&);
268 
269 };
270 
271 }
272 
273 #endif
mitk::MAPRegistrationWrapper::TagMapType
::map::core::RegistrationBase::TagMapType TagMapType
Definition: mitkMAPRegistrationWrapper.h:88
mitk::MAPRegistrationWrapper::MapPointInverse
bool MapPointInverse(const ::itk::Point< mitk::ScalarType, VTargetDim > &inPoint, ::itk::Point< mitk::ScalarType, VMovingDim > &outPoint) const
Definition: mitkMAPRegistrationWrapper.h:178
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::Identifiable::UIDType
std::string UIDType
Definition: mitkIdentifiable.h:48
mitkGeometry3D.h
MitkMatchPointRegistrationExports.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::MAPRegistrationWrapper::m_spRegistration
::map::core::RegistrationBase::Pointer m_spRegistration
Definition: mitkMAPRegistrationWrapper.h:262
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::MAPRegistrationWrapper::MapPoint
bool MapPoint(const ::itk::Point< mitk::ScalarType, VMovingDim > &inPoint, ::itk::Point< mitk::ScalarType, VTargetDim > &outPoint) const
Definition: mitkMAPRegistrationWrapper.h:132
mitk::MAPRegistrationWrapper::TagType
::map::core::RegistrationBase::TagType TagType
Definition: mitkMAPRegistrationWrapper.h:86
mitkBaseData.h
mitk::MAPRegistrationWrapper::ValueType
::map::core::RegistrationBase::ValueType ValueType
Definition: mitkMAPRegistrationWrapper.h:87
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::MAPRegistrationWrapper
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
Definition: mitkMAPRegistrationWrapper.h:36
MITKMATCHPOINTREGISTRATION_EXPORT
#define MITKMATCHPOINTREGISTRATION_EXPORT
Definition: MitkMatchPointRegistrationExports.h:15
mitk::Geometry3D
Standard implementation of BaseGeometry.
Definition: mitkGeometry3D.h:32