-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsurface_registration.cpp
94 lines (76 loc) · 2.73 KB
/
surface_registration.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "surface_registration.h"
SurfaceRegistration::SurfaceRegistration(QObject* parent)
{
m_maxIterSteps = 100;
}
SurfaceRegistration::~SurfaceRegistration()
{
}
void SurfaceRegistration::SetDataIO(DataIO *dataIO)
{
m_dataIO = dataIO;
}
void SurfaceRegistration::SetRegistrationMethod(RegistrationMethodEnum registrationMethodEnum)
{
m_registrationMethodEnum = registrationMethodEnum;
}
void SurfaceRegistration::Update()
{
// perform initial transform
vtkSmartPointer<vtkTransform> initTransform = vtkSmartPointer<vtkTransform>::New();
initTransform->Identity();
initTransform->SetMatrix(m_dataIO->GetInitialTransform());
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter->SetTransform(initTransform);
transformFilter->SetInputData(m_dataIO->GetSourceSurface());
transformFilter->Update();
emit InitialTransformComplete();
switch (m_registrationMethodEnum)
{
case ICP:
this->ICPRegistration(transformFilter->GetOutput());
break;
case PCAICP:
this->PCAICPRegistration(transformFilter->GetOutput());
break;
case ITKICP:
this->ITKICPRegistration(transformFilter->GetOutput());
break;
}
}
void SurfaceRegistration::ICPRegistration(vtkPolyData* source)
{
vtkSmartPointer<vtkIterativeClosestPointTransform> transform = vtkSmartPointer<vtkIterativeClosestPointTransform>::New();
transform->SetSource(source);
transform->SetTarget(m_dataIO->GetTargetSurface());
transform->SetMaximumNumberOfIterations(m_maxIterSteps);
transform->GetLandmarkTransform()->SetModeToRigidBody();
transform->Update();
m_dataIO->GetRegistartionTransform()->DeepCopy(transform->GetMatrix());
emit RegistrationComplete();
}
void SurfaceRegistration::SetMaximumIterationSteps(int maxIterSteps)
{
m_maxIterSteps = maxIterSteps;
}
void SurfaceRegistration::PCAICPRegistration(vtkPolyData* source)
{
vtkSmartPointer<vtkPCA_ICP_Transform> transform = vtkSmartPointer<vtkPCA_ICP_Transform>::New();
transform->SetSource(source);
transform->SetTarget(m_dataIO->GetTargetSurface());
transform->SetMaximumNumberOfIterations(m_maxIterSteps);
transform->GetLandmarkTransform()->SetModeToRigidBody();
transform->Update();
m_dataIO->GetRegistartionTransform()->DeepCopy(transform->GetMatrix());
emit RegistrationComplete();
}
void SurfaceRegistration::ITKICPRegistration(vtkPolyData* source)
{
vtkSmartPointer<vtkITKIterativeCloestPoint> transform = vtkSmartPointer<vtkITKIterativeCloestPoint>::New();
transform->SetSource(source->GetPoints());
transform->SetTarget(m_dataIO->GetTargetSurface()->GetPoints());
transform->SetNumberOfIterations(m_maxIterSteps);
transform->Update();
m_dataIO->GetRegistartionTransform()->DeepCopy(transform->GetMatrix());
emit RegistrationComplete();
}