Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkThinPlateSplineCurvedGeometry.cpp
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 
14 #include <vtkPoints.h>
15 #include <vtkThinPlateSplineTransform.h>
16 
18 {
19  m_InterpolatingAbstractTransform = m_ThinPlateSplineTransform = vtkThinPlateSplineTransform::New();
20 
21  m_VtkTargetLandmarks = vtkPoints::New();
22  m_VtkProjectedLandmarks = vtkPoints::New();
23  m_ThinPlateSplineTransform->SetInverseIterations(5000);
24 }
25 
27  : Superclass(other)
28 {
29  this->SetSigma(other.GetSigma());
30 }
31 
33 {
34  // don't need to delete m_ThinPlateSplineTransform, because it is
35  // the same as m_InterpolatingAbstractTransform, which will be deleted
36  // by the superclass.
37 
38  if (m_VtkTargetLandmarks != nullptr)
39  m_VtkTargetLandmarks->Delete();
40  if (m_VtkProjectedLandmarks != nullptr)
41  m_VtkProjectedLandmarks->Delete();
42 }
43 
45 {
46  return m_TargetLandmarks.IsNotNull() && (m_TargetLandmarks->Size() >= 3) && m_LandmarkProjector.IsNotNull();
47 }
48 
50 {
51  m_ThinPlateSplineTransform->SetSigma(sigma);
52 }
53 
55 {
56  return m_ThinPlateSplineTransform->GetSigma();
57 }
58 
60 {
62 
63  const mitk::PointSet::DataType::PointsContainer *finalTargetLandmarks, *projectedTargetLandmarks;
64 
65  finalTargetLandmarks = m_LandmarkProjector->GetFinalTargetLandmarks();
66  projectedTargetLandmarks = m_LandmarkProjector->GetProjectedLandmarks();
67 
68  mitk::PointSet::DataType::PointsContainer::ConstIterator targetIt, projectedIt;
69 
70  targetIt = finalTargetLandmarks->Begin();
71  projectedIt = projectedTargetLandmarks->Begin();
72 
73  // initialize Thin-Plate-Spline
74  m_VtkTargetLandmarks->Reset();
75  m_VtkProjectedLandmarks->Reset();
76  vtkIdType id;
77  int size = finalTargetLandmarks->Size();
78  for (id = 0; id < size; ++id, ++targetIt, ++projectedIt)
79  {
80  const mitk::PointSet::PointType &target = targetIt->Value();
81  m_VtkTargetLandmarks->InsertPoint(id, target[0], target[1], target[2]);
82  const mitk::PointSet::PointType &projected = projectedIt->Value();
83  m_VtkProjectedLandmarks->InsertPoint(id, projected[0], projected[1], projected[2]);
84  }
85  m_VtkTargetLandmarks->Modified();
86  m_VtkProjectedLandmarks->Modified();
87 
90 }
91 
92 itk::LightObject::Pointer mitk::ThinPlateSplineCurvedGeometry::InternalClone() const
93 {
94  mitk::BaseGeometry::Pointer newGeometry = new Self(*this);
95  newGeometry->UnRegister();
96  return newGeometry.GetPointer();
97 }
Thin-plate-spline-based landmark-based curved geometry.
itk::LightObject::Pointer InternalClone() const override
clones the geometry
vtkThinPlateSplineTransform * m_ThinPlateSplineTransform
bool IsValid() const override
Is this BaseGeometry in a state that is valid?
mitk::PointSet::DataType::PointsContainer::ConstPointer m_TargetLandmarks
Describes a two-dimensional, rectangular plane.