Medical Imaging Interaction Toolkit  2025.12.02
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 
55 
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 
111 
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 
225 
236 
243 
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);
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
#define MITKMATCHPOINTREGISTRATION_EXPORT
Base of all data objects.
Definition: mitkBaseData.h:44
Standard implementation of BaseGeometry.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
mitk::Geometry3D GetInverseFieldRepresentation() const
bool IsEmptyTimeStep(unsigned int t) const override
Check whether object contains data (at a specified time), e.g., a set of points may be empty.
mitkClassMacro(MAPRegistrationWrapper, BaseData)
virtual unsigned int GetTargetDimensions() const
Gets the number of target dimensions.
::map::core::RegistrationBase::ValueType ValueType
void SetRequestedRegion(const itk::DataObject *) override
Identifiable::UIDType GetUID() const override
Get unique ID of an object.
void SetRequestedRegionToLargestPossibleRegion() override
::map::core::RegistrationBase * GetRegistration()
bool MapPointInverse(const ::itk::Point< mitk::ScalarType, VTargetDim > &inPoint, ::itk::Point< mitk::ScalarType, VMovingDim > &outPoint) const
bool IsEmpty() const override
Check whether object contains data (at least at one point in time), e.g., a set of points may be empt...
void SetUID(const UIDType &uid) override
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual unsigned int GetMovingDimensions() const
Gets the number of moving dimensions.
bool HasLimitedTargetRepresentation() const
MAPRegistrationWrapper(::map::core::RegistrationBase *registration)
bool GetTagValue(const TagType &tag, ValueType &value) const
returns the tag value for a specific tag
const ::map::core::RegistrationBase * GetRegistration() const
const TagMapType & GetTags() const
returns the tags associated with this registration
bool VerifyRequestedRegion() override
::map::core::RegistrationBase::Pointer m_spRegistration
mitkNewMacro1Param(Self, ::map::core::RegistrationBase *)
::map::core::RegistrationBase::TagMapType TagMapType
bool HasLimitedMovingRepresentation() const
void PrintSelf(std::ostream &os, itk::Indent indent) const override
mitk::Geometry3D GetDirectFieldRepresentation() const
bool MapPoint(const ::itk::Point< mitk::ScalarType, VMovingDim > &inPoint, ::itk::Point< mitk::ScalarType, VTargetDim > &outPoint) const
::map::core::RegistrationBase::TagType TagType
Find image slices visible on a given plane.