1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkContourGrid.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15 // .NAME vtkContourGrid - generate isosurfaces/isolines from scalar values (specialized for unstructured grids)
16 // .SECTION Description
17 // vtkContourGrid is a filter that takes as input datasets of type
18 // vtkUnstructuredGrid and generates on output isosurfaces and/or
19 // isolines. The exact form of the output depends upon the dimensionality of
20 // the input data. Data consisting of 3D cells will generate isosurfaces,
21 // data consisting of 2D cells will generate isolines, and data with 1D or 0D
22 // cells will generate isopoints. Combinations of output type are possible if
23 // the input dimension is mixed.
24 //
25 // To use this filter you must specify one or more contour values.
26 // You can either use the method SetValue() to specify each contour
27 // value, or use GenerateValues() to generate a series of evenly
28 // spaced contours. It is also possible to accelerate the operation of
29 // this filter (at the cost of extra memory) by using a
30 // vtkScalarTree. A scalar tree is used to quickly locate cells that
31 // contain a contour surface. This is especially effective if multiple
32 // contours are being extracted. If you want to use a scalar tree,
33 // invoke the method UseScalarTreeOn().
34 //
35
36 // .SECTION Caveats
37 // For unstructured data or structured grids, normals and gradients
38 // are not computed. Use vtkPolyDataNormals to compute the surface
39 // normals of the resulting isosurface.
40
41 // .SECTION See Also
42 // vtkMarchingContourFilter
43 // vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
44 // vtkImageMarchingCubes
45
46 #ifndef vtkContourGrid_h
47 #define vtkContourGrid_h
48
49 #include "vtkFiltersCoreModule.h" // For export macro
50 #include "vtkPolyDataAlgorithm.h"
51
52 #include "vtkContourValues.h" // Needed for inline methods
53
54 class vtkEdgeTable;
55 class vtkScalarTree;
56 class vtkIncrementalPointLocator;
57
58 class VTKFILTERSCORE_EXPORT vtkContourGrid : public vtkPolyDataAlgorithm
59 {
60 public:
61 vtkTypeMacro(vtkContourGrid,vtkPolyDataAlgorithm);
62 void PrintSelf(ostream& os, vtkIndent indent);
63
64 // Description:
65 // Construct object with initial range (0,1) and single contour value
66 // of 0.0.
67 static vtkContourGrid *New();
68
69 // Description:
70 // Methods to set / get contour values.
71 void SetValue(int i, double value);
72 double GetValue(int i);
73 double *GetValues();
74 void GetValues(double *contourValues);
75 void SetNumberOfContours(int number);
76 int GetNumberOfContours();
77 void GenerateValues(int numContours, double range[2]);
78 void GenerateValues(int numContours, double rangeStart, double rangeEnd);
79
80 // Description:
81 // Modified GetMTime Because we delegate to vtkContourValues
82 unsigned long GetMTime();
83
84 // Description:
85 // Set/Get the computation of normals. Normal computation is fairly
86 // expensive in both time and storage. If the output data will be
87 // processed by filters that modify topology or geometry, it may be
88 // wise to turn Normals and Gradients off.
89 vtkSetMacro(ComputeNormals,int);
90 vtkGetMacro(ComputeNormals,int);
91 vtkBooleanMacro(ComputeNormals,int);
92
93 // Description:
94 // Set/Get the computation of gradients. Gradient computation is
95 // fairly expensive in both time and storage. Note that if
96 // ComputeNormals is on, gradients will have to be calculated, but
97 // will not be stored in the output dataset. If the output data
98 // will be processed by filters that modify topology or geometry, it
99 // may be wise to turn Normals and Gradients off.
100 // @deprecated ComputeGradients is not used so these methods don't affect anything (VTK 6.0).
101 vtkSetMacro(ComputeGradients,int);
102 vtkGetMacro(ComputeGradients,int);
103 vtkBooleanMacro(ComputeGradients,int);
104
105 // Description:
106 // Set/Get the computation of scalars.
107 vtkSetMacro(ComputeScalars,int);
108 vtkGetMacro(ComputeScalars,int);
109 vtkBooleanMacro(ComputeScalars,int);
110
111 // Description:
112 // Enable the use of a scalar tree to accelerate contour extraction.
113 vtkSetMacro(UseScalarTree,int);
114 vtkGetMacro(UseScalarTree,int);
115 vtkBooleanMacro(UseScalarTree,int);
116
117 // Description:
118 // Set / get a spatial locator for merging points. By default,
119 // an instance of vtkMergePoints is used.
120 void SetLocator(vtkIncrementalPointLocator *locator);
121 vtkGetObjectMacro(Locator,vtkIncrementalPointLocator);
122
123
124 // Description:
125 // If this is enabled (by default), the output will be triangles
126 // otherwise, the output will be the intersection polygons
127 // WARNING: if the cutting function is not a plane, the output
128 // will be 3D poygons, which might be nice to look at but hard
129 // to compute with downstream.
130 vtkSetMacro(GenerateTriangles,int);
131 vtkGetMacro(GenerateTriangles,int);
132 vtkBooleanMacro(GenerateTriangles,int);
133
134
135 // Description:
136 // Create default locator. Used to create one when none is
137 // specified. The locator is used to merge coincident points.
138 void CreateDefaultLocator();
139
140 // Description:
141 // Set/get the desired precision for the output types. See the documentation
142 // for the vtkAlgorithm::DesiredOutputPrecision enum for an explaination of
143 // the available precision settings.
144 void SetOutputPointsPrecision(int precision);
145 int GetOutputPointsPrecision() const;
146
147 protected:
148 vtkContourGrid();
149 ~vtkContourGrid();
150
151 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
152 virtual int FillInputPortInformation(int port, vtkInformation *info);
153
154 vtkContourValues *ContourValues;
155 int ComputeNormals;
156 int ComputeGradients;
157 int ComputeScalars;
158 int GenerateTriangles;
159
160 vtkIncrementalPointLocator *Locator;
161 int UseScalarTree;
162 int OutputPointsPrecision;
163 vtkScalarTree *ScalarTree;
164 vtkEdgeTable *EdgeTable;
165
166 private:
167 vtkContourGrid(const vtkContourGrid&); // Not implemented.
168 void operator=(const vtkContourGrid&); // Not implemented.
169 };
170
171 // Description:
172 // Set a particular contour value at contour number i. The index i ranges
173 // between 0<=i<NumberOfContours.
SetValue(int i,double value)174 inline void vtkContourGrid::SetValue(int i, double value)
175 {this->ContourValues->SetValue(i,value);}
176
177 // Description:
178 // Get the ith contour value.
GetValue(int i)179 inline double vtkContourGrid::GetValue(int i)
180 {return this->ContourValues->GetValue(i);}
181
182 // Description:
183 // Get a pointer to an array of contour values. There will be
184 // GetNumberOfContours() values in the list.
GetValues()185 inline double *vtkContourGrid::GetValues()
186 {return this->ContourValues->GetValues();}
187
188 // Description:
189 // Fill a supplied list with contour values. There will be
190 // GetNumberOfContours() values in the list. Make sure you allocate
191 // enough memory to hold the list.
GetValues(double * contourValues)192 inline void vtkContourGrid::GetValues(double *contourValues)
193 {this->ContourValues->GetValues(contourValues);}
194
195 // Description:
196 // Set the number of contours to place into the list. You only really
197 // need to use this method to reduce list size. The method SetValue()
198 // will automatically increase list size as needed.
SetNumberOfContours(int number)199 inline void vtkContourGrid::SetNumberOfContours(int number)
200 {this->ContourValues->SetNumberOfContours(number);}
201
202 // Description:
203 // Get the number of contours in the list of contour values.
GetNumberOfContours()204 inline int vtkContourGrid::GetNumberOfContours()
205 {return this->ContourValues->GetNumberOfContours();}
206
207 // Description:
208 // Generate numContours equally spaced contour values between specified
209 // range. Contour values will include min/max range values.
GenerateValues(int numContours,double range[2])210 inline void vtkContourGrid::GenerateValues(int numContours, double range[2])
211 {this->ContourValues->GenerateValues(numContours, range);}
212
213 // Description:
214 // Generate numContours equally spaced contour values between specified
215 // range. Contour values will include min/max range values.
GenerateValues(int numContours,double rangeStart,double rangeEnd)216 inline void vtkContourGrid::GenerateValues(int numContours, double
217 rangeStart, double rangeEnd)
218 {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}
219
220
221 #endif
222
223
224