VMTK
vtkvmtkPolyDataPotentialFit.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataPotentialFit.h,v $
5 Language: C++
6 
7  Copyright (c) Luca Antiga, David Steinman. All rights reserved.
8  See LICENSE file for details.
9 
10  Portions of this code are covered under the VTK copyright.
11  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
12  for details.
13 
14  Portions of this code are covered under the ITK copyright.
15  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm
16  for details.
17 
18  This software is distributed WITHOUT ANY WARRANTY; without even
19  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  PURPOSE. See the above copyright notices for more information.
21 
22 =========================================================================*/
32 #ifndef __vtkvmtkPolyDataPotentialFit_h
33 #define __vtkvmtkPolyDataPotentialFit_h
34 
35 #include "vtkPolyDataAlgorithm.h"
36 #include "vtkvmtkWin32Header.h"
37 
38 class vtkImageData;
39 class vtkDoubleArray;
41 
42 class VTK_VMTK_SEGMENTATION_EXPORT vtkvmtkPolyDataPotentialFit : public vtkPolyDataAlgorithm
43 {
44  public:
45  vtkTypeMacro(vtkvmtkPolyDataPotentialFit,vtkPolyDataAlgorithm);
46  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
47 
48  static vtkvmtkPolyDataPotentialFit *New();
49 
50  virtual void SetPotentialImage(vtkImageData *);
51  vtkGetObjectMacro(PotentialImage, vtkImageData);
52 
53  virtual void SetInflationImage(vtkImageData *);
54  vtkGetObjectMacro(InflationImage, vtkImageData);
55 
56  vtkSetMacro(InflationThreshold, double);
57  vtkGetMacro(InflationThreshold, double);
58 
59  vtkSetMacro(NumberOfIterations, int);
60  vtkGetMacro(NumberOfIterations, int);
61 
62  vtkSetMacro(NumberOfStiffnessSubIterations, int);
63  vtkGetMacro(NumberOfStiffnessSubIterations, int);
64 
65  vtkSetMacro(NumberOfInflationSubIterations, int);
66  vtkGetMacro(NumberOfInflationSubIterations, int);
67 
68  vtkSetMacro(Relaxation, double);
69  vtkGetMacro(Relaxation, double);
70 
71  vtkSetMacro(PotentialWeight, double);
72  vtkGetMacro(PotentialWeight, double);
73 
74  vtkSetMacro(StiffnessWeight, double);
75  vtkGetMacro(StiffnessWeight, double);
76 
77  vtkSetMacro(InflationWeight, double);
78  vtkGetMacro(InflationWeight, double);
79 
80  vtkSetMacro(Convergence, double);
81  vtkGetMacro(Convergence, double);
82 
83  vtkSetMacro(MaxTimeStep, double);
84  vtkGetMacro(MaxTimeStep, double);
85 
86  vtkSetMacro(TimeStep, double);
87  vtkGetMacro(TimeStep, double);
88 
89  vtkSetMacro(AdaptiveTimeStep, int);
90  vtkGetMacro(AdaptiveTimeStep, int);
91  vtkBooleanMacro(AdaptiveTimeStep, int);
92 
93  vtkSetMacro(FlipNormals, int);
94  vtkGetMacro(FlipNormals, int);
95  vtkBooleanMacro(FlipNormals, int);
96 
97  vtkSetMacro(UsePotentialInInflation, int);
98  vtkGetMacro(UsePotentialInInflation, int);
99  vtkBooleanMacro(UsePotentialInInflation, int);
100 
101  vtkSetMacro(Dimensionality, int);
102  vtkGetMacro(Dimensionality, int);
103 
104  protected:
107 
108  virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
109 
110  void EvaluateForce(double point[3], double force[3], bool normalize = true);
111  double EvaluatePotential(double point[3]);
112  double EvaluateInflation(double point[3]);
113  void ComputeDisplacements(bool potential, bool stiffness, bool inflation);
114  void ComputePotentialDisplacement(vtkIdType pointId, double potentialDisplacement[3]);
115  void ComputeStiffnessDisplacement(vtkIdType pointId, double stiffnessDisplacement[3]);
116  void ComputeInflationDisplacement(vtkIdType pointId, double inflationDisplacement[3]);
117  void ComputeTimeStep();
118  void ApplyDisplacements();
119 
120  int TestConvergence();
121 
122  static double ComputeMinSpacing(double spacing[3]);
123 
124  static bool IsInExtent(vtkIdType extent[6], int ijk[3], vtkIdType border)
125  {
126  return (ijk[0]>=extent[0]+border && ijk[0]<=extent[1]-border) && (ijk[1]>=extent[2]+border && ijk[1]<=extent[3]-border) && (ijk[2]>=extent[4]+border && ijk[2]<=extent[5]-border) ? true : false;
127  }
128 
129  static bool IsCellInExtent(int extent[6], int ijk[3], vtkIdType border)
130  {
131  return (ijk[0]>=extent[0]+border && ijk[0]<extent[1]-border) && (ijk[1]>=extent[2]+border && ijk[1]<extent[3]-border) && (ijk[2]>=extent[4]+border && ijk[2]<extent[5]-border) ? true : false;
132  }
133 
134  vtkImageData *PotentialImage;
135  vtkImageData *InflationImage;
136  vtkImageData *PotentialGradientImage;
137 
139 
142 
143  double TimeStep;
144  double Relaxation;
148  double Convergence;
149 
153 
157 
158  double MaxTimeStep;
160 
162 
164 
165  vtkDoubleArray *Displacements;
166 
168  vtkDataArray *Normals;
169 
170  private:
171  vtkvmtkPolyDataPotentialFit(const vtkvmtkPolyDataPotentialFit&); // Not implemented.
172  void operator=(const vtkvmtkPolyDataPotentialFit&); // Not implemented.
173 };
174 
175 #endif
Create an explicitly deformable model which evolves a surface to gradient magnitudes of an input imag...
static bool IsCellInExtent(int extent[6], int ijk[3], vtkIdType border)
static bool IsInExtent(vtkIdType extent[6], int ijk[3], vtkIdType border)
Create an empty, polydata, polydata manifold, polydata manifold extended, or unstructured grid neighb...