Medical Imaging Interaction Toolkit  2026.06.00
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 {
45 {
46 public:
47 
49 
50  mitkNewMacro1Param( Self, ::map::core::RegistrationBase*);
51 
56  Identifiable::UIDType GetUID() const override;
57 
63  bool IsEmptyTimeStep(unsigned int t) const override;
64 
69  bool IsEmpty() const override;
70 
76 
82 
87  bool VerifyRequestedRegion() override;
88 
93  void SetRequestedRegion(const itk::DataObject*) override;
94 
100  virtual unsigned int GetMovingDimensions() const;
101 
107  virtual unsigned int GetTargetDimensions() const;
108 
110  typedef ::map::core::RegistrationBase::TagType TagType;
112  typedef ::map::core::RegistrationBase::ValueType ValueType;
114  typedef ::map::core::RegistrationBase::TagMapType TagMapType;
115 
121  const TagMapType& GetTags() const;
122 
130  bool GetTagValue(const TagType & tag, ValueType & value) const;
131 
141 
151 
165  template <unsigned int VMovingDim, unsigned int VTargetDim>
166  bool MapPoint(const ::itk::Point<mitk::ScalarType,VMovingDim>& inPoint, ::itk::Point<mitk::ScalarType,VTargetDim>& outPoint) const
167  {
168  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
169  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
170 
171  if (m_spRegistration.IsNull())
172  {
173  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
174  }
175 
176  bool result = false;
177 
178  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
179  {
180  MAPMovingPointType tempInP;
181  MAPTargetPointType tempOutP;
182  tempInP.CastFrom(inPoint);
183 
184  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
185  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
186 
187  if (!pCastedReg)
188  {
189  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
190  }
191 
192  result = pCastedReg->mapPoint(tempInP,tempOutP);
193  if (result)
194  {
195  outPoint.CastFrom(tempOutP);
196  }
197 
198  }
199 
200  return result;
201  };
202 
215  template <unsigned int VMovingDim, unsigned int VTargetDim>
216  bool MapPointInverse(const ::itk::Point<mitk::ScalarType,VTargetDim> & inPoint, ::itk::Point<mitk::ScalarType,VMovingDim> & outPoint) const
217 {
218  typedef typename ::map::core::continuous::Elements<VMovingDim>::PointType MAPMovingPointType;
219  typedef typename ::map::core::continuous::Elements<VTargetDim>::PointType MAPTargetPointType;
220 
221  if (m_spRegistration.IsNull())
222  {
223  mapDefaultExceptionMacro(<< "Error. Cannot map point. Wrapper points to invalid registration (nullptr). Point: " << inPoint);
224  }
225 
226  bool result = false;
227 
228  if ((this->GetMovingDimensions() == VMovingDim)&&(this->GetTargetDimensions() == VTargetDim))
229  {
230  MAPTargetPointType tempInP;
231  MAPMovingPointType tempOutP;
232  tempInP.CastFrom(inPoint);
233 
234  typedef ::map::core::Registration<VMovingDim,VTargetDim> CastedRegType;
235  const CastedRegType* pCastedReg = dynamic_cast<const CastedRegType*>(m_spRegistration.GetPointer());
236 
237  if (!pCastedReg)
238  {
239  mapDefaultExceptionMacro(<< "Error. Cannot map point. Registration has invalid dimension. Point: " << inPoint);
240  }
241 
242  result = pCastedReg->mapPointInverse(tempInP,tempOutP);
243  if (result)
244  {
245  outPoint.CastFrom(tempOutP);
246  }
247 
248  }
249 
250  return result;
251 };
252 
265 
278 
288 
298 
303  ::map::core::RegistrationBase* GetRegistration();
304 
309  const ::map::core::RegistrationBase* GetRegistration() const;
310 
311 protected:
312  void PrintSelf (std::ostream &os, itk::Indent indent) const override;
313 
314  MAPRegistrationWrapper(::map::core::RegistrationBase* registration);
316 
317  void SetUID(const UIDType& uid) override;
318 
319  ::map::core::RegistrationBase::Pointer m_spRegistration;
320 
321 private:
322 
323  MAPRegistrationWrapper& operator = (const MAPRegistrationWrapper&);
325 
326 };
327 
328 }
329 
330 #endif
#define MITKMATCHPOINTREGISTRATION_EXPORT
Base class of all data objects.
Definition: mitkBaseData.h:60
Standard three-dimensional geometry.
std::string UIDType
Type alias for unique identifiers.
Wrapper class that adapts MatchPoint registration objects to the MITK data model.
mitk::Geometry3D GetInverseFieldRepresentation() const
Returns the field representation of the inverse mapping kernel as a Geometry3D.
bool IsEmptyTimeStep(unsigned int t) const override
Checks whether the registration is empty at the given time step.
mitkClassMacro(MAPRegistrationWrapper, BaseData)
virtual unsigned int GetTargetDimensions() const
Gets the number of dimensions of the target space.
::map::core::RegistrationBase::ValueType ValueType
Tag value type from the MatchPoint registration metadata.
void SetRequestedRegion(const itk::DataObject *) override
Identifiable::UIDType GetUID() const override
Returns the unique identifier of the wrapped registration.
void SetRequestedRegionToLargestPossibleRegion() override
::map::core::RegistrationBase * GetRegistration()
Returns a mutable pointer to the wrapped MatchPoint registration.
bool MapPointInverse(const ::itk::Point< mitk::ScalarType, VTargetDim > &inPoint, ::itk::Point< mitk::ScalarType, VMovingDim > &outPoint) const
Maps a point from target space to moving space using the inverse mapping kernel.
void PrecomputeInverseMapping()
Forces the inverse mapping kernel to precompute its deformation field.
bool IsEmpty() const override
Checks whether the registration wrapper contains no valid registration.
void SetUID(const UIDType &uid) override
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual unsigned int GetMovingDimensions() const
Gets the number of dimensions of the moving space.
bool HasLimitedTargetRepresentation() const
Checks whether the inverse mapping kernel has a limited representation in target space.
MAPRegistrationWrapper(::map::core::RegistrationBase *registration)
bool GetTagValue(const TagType &tag, ValueType &value) const
Retrieves the value for a specific metadata tag.
const ::map::core::RegistrationBase * GetRegistration() const
Returns a const pointer to the wrapped MatchPoint registration.
const TagMapType & GetTags() const
Returns all metadata tags associated with this registration.
bool VerifyRequestedRegion() override
::map::core::RegistrationBase::Pointer m_spRegistration
mitkNewMacro1Param(Self, ::map::core::RegistrationBase *)
::map::core::RegistrationBase::TagMapType TagMapType
Map type associating tag keys with their values.
void PrecomputeDirectMapping()
Forces the direct mapping kernel to precompute its deformation field.
bool HasLimitedMovingRepresentation() const
Checks whether the direct mapping kernel has a limited representation in moving space.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
mitk::Geometry3D GetDirectFieldRepresentation() const
Returns the field representation of the direct mapping kernel as a Geometry3D.
bool MapPoint(const ::itk::Point< mitk::ScalarType, VMovingDim > &inPoint, ::itk::Point< mitk::ScalarType, VTargetDim > &outPoint) const
Maps a point from moving space to target space using the direct mapping kernel.
::map::core::RegistrationBase::TagType TagType
Tag key type from the MatchPoint registration metadata.
Find image slices visible on a given plane.