OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkIterativeClosestPointTransform.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkIterativeClosestPointTransform.h,v $
5   Language:  C++
6   Date:      $Date: 2002/01/22 15:30:32 $
7   Version:   $Revision: 1.8 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18
19 // .NAME vtkIterativeClosestPointTransform - Implementation of the ICP algorithm.
20 // .SECTION Description
21 // Match two surfaces using the iterative closest point (ICP) algorithm.
22 // The core of the algorithm is to match each vertex in one surface with 
23 // the closest surface point on the other, then apply the transformation
24 // that modify one surface to best match the other (in a least square sense).
25 // This has to be iterated to get proper convergence of the surfaces.
26 // .SECTION Note
27 // Use vtkTransformPolyDataFilter to apply the resulting ICP transform to 
28 // your data. You might also set it to your actor's user transform.
29 // .SECTION Note
30 // This class makes use of vtkLandmarkTransform internally to compute the
31 // best fit. Use the GetLandmarkTransform member to get a pointer to that
32 // transform and set its parameters. You might, for example, constrain the
33 // number of degrees of freedom of the solution (i.e. rigid body, similarity,
34 // etc.) by checking the vtkLandmarkTransform documentation for its SetMode
35 // member.
36 // .SECTION see also
37 // vtkLandmarkTransform
38
39
40 #ifndef __vtkIterativeClosestPointTransform_h
41 #define __vtkIterativeClosestPointTransform_h
42
43 #include "vtkLinearTransform.h"
44
45 #define VTK_ICP_MODE_RMS 0
46 #define VTK_ICP_MODE_AV 1
47
48 class vtkCellLocator;
49 class vtkLandmarkTransform;
50 class vtkDataSet;
51
52 class VTK_HYBRID_EXPORT vtkIterativeClosestPointTransform : public vtkLinearTransform
53 {
54 public:
55   static vtkIterativeClosestPointTransform *New();
56   vtkTypeRevisionMacro(vtkIterativeClosestPointTransform,vtkLinearTransform);
57   void PrintSelf(ostream& os, vtkIndent indent);
58
59   // Description:
60   // Specify the source and target data sets.
61   void SetSource(vtkDataSet *source);
62   void SetTarget(vtkDataSet *target);
63   vtkGetObjectMacro(Source, vtkDataSet);
64   vtkGetObjectMacro(Target, vtkDataSet);
65
66   // Description:
67   // Set/Get a spatial locator for speeding up the search process. 
68   // An instance of vtkCellLocator is used by default.
69   void SetLocator(vtkCellLocator *locator);
70   vtkGetObjectMacro(Locator,vtkCellLocator);
71
72   // Description: 
73   // Set/Get the  maximum number of iterations
74   vtkSetMacro(MaximumNumberOfIterations, int);
75   vtkGetMacro(MaximumNumberOfIterations, int);
76
77   // Description: 
78   // Get the number of iterations since the last update
79   vtkGetMacro(NumberOfIterations, int);
80
81   // Description: 
82   // Force the algorithm to check the mean distance between two iteration.
83   vtkSetMacro(CheckMeanDistance, int);
84   vtkGetMacro(CheckMeanDistance, int);
85   vtkBooleanMacro(CheckMeanDistance, int);
86
87   // Description:
88   // Specify the mean distance mode. This mode expresses how the mean 
89   // distance is computed. The RMS mode is the square root of the average
90   // of the sum of squares of the closest point distances. The Absolute
91   // Value mode is the mean of the sum of absolute values of the closest
92   // point distances.
93   vtkSetClampMacro(MeanDistanceMode,int,
94                    VTK_ICP_MODE_RMS,VTK_ICP_MODE_AV);
95   vtkGetMacro(MeanDistanceMode,int);
96   void SetMeanDistanceModeToRMS()
97     {this->SetMeanDistanceMode(VTK_ICP_MODE_RMS);}
98   void SetMeanDistanceModeToAbsoluteValue()
99     {this->SetMeanDistanceMode(VTK_ICP_MODE_AV);}
100   const char *GetMeanDistanceModeAsString();
101
102   // Description: 
103   // Set/Get the maximum mean distance between two iteration. If the mean
104   // distance is lower than this, the convergence stops.
105   vtkSetMacro(MaximumMeanDistance, float);
106   vtkGetMacro(MaximumMeanDistance, float);
107   
108   // Description: 
109   // Get the mean distance between the last two iterations.
110   vtkGetMacro(MeanDistance, float);
111   
112   // Description: 
113   // Set/Get the maximum number of landmarks sampled in your dataset.
114   // If your dataset is dense, then you will typically not need all the 
115   // points to compute the ICP transform. 
116   vtkSetMacro(MaximumNumberOfLandmarks, int);
117   vtkGetMacro(MaximumNumberOfLandmarks, int);
118
119   // Description: 
120   // Starts the process by translating source centroid to target centroid.
121   vtkSetMacro(StartByMatchingCentroids, int);
122   vtkGetMacro(StartByMatchingCentroids, int);
123   vtkBooleanMacro(StartByMatchingCentroids, int);
124
125   // Description: 
126   // Get the internal landmark transform. Use it to constrain the number of
127   // degrees of freedom of the solution (i.e. rigid body, similarity, etc.).
128   vtkGetObjectMacro(LandmarkTransform,vtkLandmarkTransform);
129   
130   // Description:
131   // Invert the transformation.  This is done by switching the
132   // source and target.
133   void Inverse();
134
135   // Description:
136   // Make another transform of the same type.
137   vtkAbstractTransform *MakeTransform();
138
139 protected:
140
141   // Description:
142   // Release source and target
143   void ReleaseSource(void);
144   void ReleaseTarget(void);
145
146   // Description:
147   // Release locator
148   void ReleaseLocator(void);
149
150   // Description:
151   // Create default locator. Used to create one when none is specified.
152   void CreateDefaultLocator(void);
153
154   // Description:
155   // Get the MTime of this object also considering the locator.
156   unsigned long int GetMTime();
157
158   vtkIterativeClosestPointTransform();
159   ~vtkIterativeClosestPointTransform();
160
161   void InternalUpdate();
162
163   // Description:
164   // This method does no type checking, use DeepCopy instead.
165   void InternalDeepCopy(vtkAbstractTransform *transform);
166
167   vtkDataSet* Source;
168   vtkDataSet* Target;
169   vtkCellLocator *Locator;
170   int MaximumNumberOfIterations;
171   int CheckMeanDistance;
172   int MeanDistanceMode;
173   float MaximumMeanDistance;
174   int MaximumNumberOfLandmarks;
175   int StartByMatchingCentroids;
176
177   int NumberOfIterations;
178   float MeanDistance;
179   vtkLandmarkTransform *LandmarkTransform;
180 private:
181   vtkIterativeClosestPointTransform(const vtkIterativeClosestPointTransform&);  // Not implemented.
182   void operator=(const vtkIterativeClosestPointTransform&);  // Not implemented.
183 };
184
185 #endif