Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
18 #include <vtkPoints.h>
19 #include <vtkThinPlateSplineTransform.h>
20 
22 {
24 
27  m_ThinPlateSplineTransform->SetInverseIterations(5000);
28 }
29 
31  : Superclass(other)
32 {
33  this->SetSigma(other.GetSigma());
34 }
35 
37 {
38  // don't need to delete m_ThinPlateSplineTransform, because it is
39  // the same as m_InterpolatingAbstractTransform, which will be deleted
40  // by the superclass.
41 
42  if (m_VtkTargetLandmarks != nullptr)
43  m_VtkTargetLandmarks->Delete();
44  if (m_VtkProjectedLandmarks != nullptr)
45  m_VtkProjectedLandmarks->Delete();
46 }
47 
49 {
50  return m_TargetLandmarks.IsNotNull() && (m_TargetLandmarks->Size() >= 3) && m_LandmarkProjector.IsNotNull();
51 }
52 
54 {
55  m_ThinPlateSplineTransform->SetSigma(sigma);
56 }
57 
59 {
60  return m_ThinPlateSplineTransform->GetSigma();
61 }
62 
64 {
65  Superclass::ComputeGeometry();
66 
67  const mitk::PointSet::DataType::PointsContainer *finalTargetLandmarks, *projectedTargetLandmarks;
68 
69  finalTargetLandmarks = m_LandmarkProjector->GetFinalTargetLandmarks();
70  projectedTargetLandmarks = m_LandmarkProjector->GetProjectedLandmarks();
71 
72  mitk::PointSet::DataType::PointsContainer::ConstIterator targetIt, projectedIt;
73 
74  targetIt = finalTargetLandmarks->Begin();
75  projectedIt = projectedTargetLandmarks->Begin();
76 
77  // initialize Thin-Plate-Spline
78  m_VtkTargetLandmarks->Reset();
79  m_VtkProjectedLandmarks->Reset();
80  vtkIdType id;
81  int size = finalTargetLandmarks->Size();
82  for (id = 0; id < size; ++id, ++targetIt, ++projectedIt)
83  {
84  const mitk::PointSet::PointType &target = targetIt->Value();
85  m_VtkTargetLandmarks->InsertPoint(id, target[0], target[1], target[2]);
86  const mitk::PointSet::PointType &projected = projectedIt->Value();
87  m_VtkProjectedLandmarks->InsertPoint(id, projected[0], projected[1], projected[2]);
88  }
89  m_VtkTargetLandmarks->Modified();
90  m_VtkProjectedLandmarks->Modified();
91 
92  m_ThinPlateSplineTransform->SetSourceLandmarks(m_VtkProjectedLandmarks);
93  m_ThinPlateSplineTransform->SetTargetLandmarks(m_VtkTargetLandmarks);
94 }
95 
97 {
98  mitk::BaseGeometry::Pointer newGeometry = new Self(*this);
99  newGeometry->UnRegister();
100  return newGeometry.GetPointer();
101 }
Thin-plate-spline-based landmark-based curved geometry.
itk::SmartPointer< Self > Pointer
virtual itk::LightObject::Pointer InternalClone() const override
clones the geometry
vtkThinPlateSplineTransform * m_ThinPlateSplineTransform
virtual bool IsValid() const override
Is this BaseGeometry in a state that is valid?
Describes a geometry defined by an vtkAbstractTransform and a plane.
Describes a two-dimensional, rectangular plane.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.