MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
IterativeClosestPointRegistration.cpp
Go to the documentation of this file.
1/*===================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center,
6Division of Medical and Biological Informatics.
7All rights reserved.
8
9This software is distributed WITHOUT ANY WARRANTY; without
10even the implied warranty of MERCHANTABILITY or FITNESS FOR
11A PARTICULAR PURPOSE.
12
13See LICENSE.txt or http://www.mitk.org for details.
14
15===================================================================*/
16
17
18// Blueberry
19#include <berryISelectionService.h>
20#include <berryIWorkbenchWindow.h>
21
22// Qmitk
24
25// Qt
26#include <QMessageBox>
27
28// Mitk
29#include <mitkImage.h>
30#include <mitkNodePredicateDataType.h>
31#include <mitkSurface.h>
32#include <mitkPointSet.h>
34
35const std::string IterativeClosestPointRegistration::VIEW_ID = "org.mitk.views.iterativeclosestpointregistration";
36
40
42{
43 // create GUI widgets from the Qt Designer's .ui file
44 m_Controls.setupUi(parent);
45 connect(m_Controls.m_performICP, &QPushButton::clicked, this, &IterativeClosestPointRegistration::PerformICP);
46 connect(m_Controls.m_moveBack, &QPushButton::clicked, this, &IterativeClosestPointRegistration::MoveSurfaceBack);
47 //initialize Combo Boxes
48 m_Controls.m_comboBoxFixedSurface->SetDataStorage(this->GetDataStorage());
49 m_Controls.m_comboBoxFixedSurface->SetAutoSelectNewItems(false);
50 m_Controls.m_comboBoxFixedSurface->SetPredicate(mitk::NodePredicateDataType::New("Surface"));
51 m_Controls.m_comboBoxMovingSurface->SetDataStorage(this->GetDataStorage());
52 m_Controls.m_comboBoxMovingSurface->SetAutoSelectNewItems(false);
53 m_Controls.m_comboBoxMovingSurface->SetPredicate(mitk::NodePredicateDataType::New("Surface"));
54
55}
56
57void IterativeClosestPointRegistration::OnSelectionChanged(berry::IWorkbenchPart::Pointer /*source*/,
58 const QList<mitk::DataNode::Pointer> &nodes)
59{
60
61}
62
64{
65mitk::Surface::Pointer MovingSurface = dynamic_cast<mitk::Surface*>(m_Controls.m_comboBoxMovingSurface->GetSelectedNode()->GetData());
66mitk::Surface::Pointer FixedSurface = dynamic_cast<mitk::Surface*>(m_Controls.m_comboBoxFixedSurface->GetSelectedNode()->GetData());
67double Threshold = m_Controls.m_threshold->value();
68int maxIterations = m_Controls.m_maxIterations->value();
69itk::Matrix<double,3,3> TransformationR;
70itk::Vector<double,3> TransformationT;
71double FRE;
72int n;
73std::string ErrorMessage;
75 FixedSurface->GetVtkPolyData(),
76 Threshold,
77 TransformationR,
78 TransformationT,
79 FRE, n, ErrorMessage,maxIterations);
80mitk::AffineTransform3D::Pointer T = mitk::AffineTransform3D::New();
81T->SetTranslation(TransformationT);
82T->SetMatrix(TransformationR);
83m_OldTransformation = MovingSurface->GetGeometry()->GetIndexToWorldTransform();
84MovingSurface->GetGeometry()->SetIndexToWorldTransform(T);
85MITK_INFO << "Performed ICP";
86MITK_INFO << "n:" << n;
87MITK_INFO << "R:" << TransformationR;
88MITK_INFO << "T:" << TransformationT;
89MITK_INFO << "Message:" << ErrorMessage;
90m_Controls.m_moveBack->setEnabled(true);
91this->RequestRenderWindowUpdate();
92}
93
95 mitk::Surface::Pointer MovingSurface = dynamic_cast<mitk::Surface*>(m_Controls.m_comboBoxMovingSurface->GetSelectedNode()->GetData());
96 MovingSurface->GetGeometry()->SetIndexToWorldTransform(m_OldTransformation);
97 this->RequestRenderWindowUpdate();
98}
virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer source, const QList< mitk::DataNode::Pointer > &nodes) override
called by QmitkFunctionality when DataManager's selection has changed
void PerformICP()
Called when the user clicks the GUI button perform the ICP.
void MoveSurfaceBack()
Called when the user clicks the GUI button to move the surface back.
Ui::IterativeClosestPointRegistrationControls m_Controls
virtual void CreateQtPartControl(QWidget *parent) override
mitk::AffineTransform3D::Pointer m_OldTransformation
static bool StandardICPPointRegisterAlgorithm(mitk::PointSet::Pointer MovingSet, mitk::PointSet::Pointer StaticSet, double Threshold, itk::Matrix< double, 3, 3 > &TransformationR, itk::Vector< double, 3 > &TransformationT, double &FRE, int &n, std::string &ErrorMessage, int max_iterations=100)
This method executes the standard iterative closest point algorithm to register a moving pointset X o...