-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLandmarkTransform.h
More file actions
128 lines (105 loc) · 4.17 KB
/
LandmarkTransform.h
File metadata and controls
128 lines (105 loc) · 4.17 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*=========================================================================
Program: Visualization Toolkit
Module: vtkLandmarkTransform.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt orhttp://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkLandmarkTransform - a linear transform specified by two corresponding point sets
// .SECTION Description
// A vtkLandmarkTransform is defined by two sets of landmarks, the
// transform computed gives the best fit mapping one onto the other, in a
// least squares sense. The indices are taken to correspond, so point 1
// in the first set will get mapped close to point 1 in the second set,
// etc. Call SetSourceLandmarks and SetTargetLandmarks to specify the two
// sets of landmarks, ensure they have the same number of points.
// .SECTION Caveats
// Whenever you add, subtract, or set points you must call Modified()
// on the vtkPoints object, or the transformation might not update.
// .SECTION see also
// vtkLinearTransform
#ifndef __LandmarkTransform_h
#define __LandmarkTransform_h
#include "vtkCommonTransformsModule.h" // For export macro
#include "vtkLinearTransform.h"
#include <vtkFloatArray.h>
#define VTK_LANDMARK_RIGIDBODY 6
#define VTK_LANDMARK_SIMILARITY 7
#define VTK_LANDMARK_AFFINE 12
class VTKCOMMONTRANSFORMS_EXPORT LandmarkTransform : public vtkLinearTransform
{
public:
static LandmarkTransform *New();
vtkTypeMacro(LandmarkTransform,vtkLinearTransform);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the source and target landmark sets. The two sets must have
// the same number of points. If you add or change points in these objects,
// you must call Modified() on them or the transformation might not update.
void SetSourceLandmarks(vtkPoints *points);
void SetTargetLandmarks(vtkPoints *points);
void SetLandmarksWeight(vtkFloatArray *weight);
vtkGetObjectMacro(SourceLandmarks, vtkPoints);
vtkGetObjectMacro(TargetLandmarks, vtkPoints);
// Description:
// Set the number of degrees of freedom to constrain the solution to.
// Rigidbody (VTK_LANDMARK_RIGIDBODY): rotation and translation only.
// Similarity (VTK_LANDMARK_SIMILARITY): rotation, translation and
// isotropic scaling.
// Affine (VTK_LANDMARK_AFFINE): collinearity is preserved.
// Ratios of distances along a line are preserved.
// The default is similarity.
vtkSetMacro(Mode,int);
void SetModeToRigidBody() { this->SetMode(VTK_LANDMARK_RIGIDBODY); };
void SetModeToSimilarity() { this->SetMode(VTK_LANDMARK_SIMILARITY); };
void SetModeToAffine() { this->SetMode(VTK_LANDMARK_AFFINE); };
// Description:
// Get the current transformation mode.
vtkGetMacro(Mode,int);
const char *GetModeAsString();
// Description:
// Invert the transformation. This is done by switching the
// source and target landmarks.
void Inverse();
// Description:
// Get the MTime.
unsigned long GetMTime();
// Description:
// Make another transform of the same type.
vtkAbstractTransform *MakeTransform();
protected:
LandmarkTransform();
~LandmarkTransform();
// Update the matrix from the quaternion.
void InternalUpdate();
// Description:
// This method does no type checking, use DeepCopy instead.
void InternalDeepCopy(vtkAbstractTransform *transform);
vtkPoints* SourceLandmarks;
vtkPoints* TargetLandmarks;
vtkFloatArray* LandmarksWeight;
int Mode;
private:
LandmarkTransform(const LandmarkTransform&); // Not implemented.
void operator=(const LandmarkTransform&); // Not implemented.
};
//BTX
inline const char *LandmarkTransform::GetModeAsString()
{
switch (this->Mode)
{
case VTK_LANDMARK_RIGIDBODY:
return "RigidBody";
case VTK_LANDMARK_SIMILARITY:
return "Similarity";
case VTK_LANDMARK_AFFINE:
return "Affine";
default:
return "Unrecognized";
}
}
//ETX
#endif