1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkContourFilter.h,v $
6 Date: $Date: 2003/01/09 19:21:05 $
7 Version: $Revision: 1.69 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
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.
17 =========================================================================*/
18 // .NAME vtkContourFilter - generate isosurfaces/isolines from scalar values
19 // .SECTION Description
20 // vtkContourFilter is a filter that takes as input any dataset and
21 // generates on output isosurfaces and/or isolines. The exact form
22 // of the output depends upon the dimensionality of the input data.
23 // Data consisting of 3D cells will generate isosurfaces, data
24 // consisting of 2D cells will generate isolines, and data with 1D
25 // or 0D cells will generate isopoints. Combinations of output type
26 // are possible if the input dimension is mixed.
28 // To use this filter you must specify one or more contour values.
29 // You can either use the method SetValue() to specify each contour
30 // value, or use GenerateValues() to generate a series of evenly
31 // spaced contours. It is also possible to accelerate the operation of
32 // this filter (at the cost of extra memory) by using a
33 // vtkScalarTree. A scalar tree is used to quickly locate cells that
34 // contain a contour surface. This is especially effective if multiple
35 // contours are being extracted. If you want to use a scalar tree,
36 // invoke the method UseScalarTreeOn().
38 // If the input data is structured, consider using a filter that is
39 // optimized for structured data. These can be found in the patented
43 // For unstructured data or structured grids, normals and gradients
44 // are not computed. Use vtkPolyDataNormals to compute the surface
48 // vtkMarchingContourFilter vtkKitwareContourFilter
49 // vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
50 // vtkImageMarchingCubes
52 #ifndef __vtkContourFilter_h
53 #define __vtkContourFilter_h
55 #include "vtkDataSetToPolyDataFilter.h"
57 #include "vtkContourValues.h" // Needed for inline methods
59 class vtkPointLocator;
62 class VTK_GRAPHICS_EXPORT vtkContourFilter : public vtkDataSetToPolyDataFilter
65 vtkTypeRevisionMacro(vtkContourFilter,vtkDataSetToPolyDataFilter);
66 void PrintSelf(ostream& os, vtkIndent indent);
69 // Construct object with initial range (0,1) and single contour value
71 static vtkContourFilter *New();
74 // Methods to set / get contour values.
75 void SetValue(int i, float value);
76 float GetValue(int i);
78 void GetValues(float *contourValues);
79 void SetNumberOfContours(int number);
80 int GetNumberOfContours();
81 void GenerateValues(int numContours, float range[2]);
82 void GenerateValues(int numContours, float rangeStart, float rangeEnd);
85 // Modified GetMTime Because we delegate to vtkContourValues
86 unsigned long GetMTime();
89 // Set/Get the computation of normals. Normal computation is fairly
90 // expensive in both time and storage. If the output data will be
91 // processed by filters that modify topology or geometry, it may be
92 // wise to turn Normals and Gradients off.
93 vtkSetMacro(ComputeNormals,int);
94 vtkGetMacro(ComputeNormals,int);
95 vtkBooleanMacro(ComputeNormals,int);
98 // Set/Get the computation of gradients. Gradient computation is
99 // fairly expensive in both time and storage. Note that if
100 // ComputeNormals is on, gradients will have to be calculated, but
101 // will not be stored in the output dataset. If the output data
102 // will be processed by filters that modify topology or geometry, it
103 // may be wise to turn Normals and Gradients off.
104 vtkSetMacro(ComputeGradients,int);
105 vtkGetMacro(ComputeGradients,int);
106 vtkBooleanMacro(ComputeGradients,int);
109 // Set/Get the computation of scalars.
110 vtkSetMacro(ComputeScalars,int);
111 vtkGetMacro(ComputeScalars,int);
112 vtkBooleanMacro(ComputeScalars,int);
115 // Enable the use of a scalar tree to accelerate contour extraction.
116 vtkSetMacro(UseScalarTree,int);
117 vtkGetMacro(UseScalarTree,int);
118 vtkBooleanMacro(UseScalarTree,int);
121 // Enable the use of a scalar tree to accelerate contour extraction.
122 virtual void SetScalarTree(vtkScalarTree*);
123 vtkGetObjectMacro(ScalarTree,vtkScalarTree);
126 // Set / get a spatial locator for merging points. By default,
127 // an instance of vtkMergePoints is used.
128 void SetLocator(vtkPointLocator *locator);
129 vtkGetObjectMacro(Locator,vtkPointLocator);
132 // Create default locator. Used to create one when none is
133 // specified. The locator is used to merge coincident points.
134 void CreateDefaultLocator();
142 vtkContourValues *ContourValues;
144 int ComputeGradients;
146 vtkPointLocator *Locator;
148 vtkScalarTree *ScalarTree;
150 char *InputScalarsSelection;
151 vtkSetStringMacro(InputScalarsSelection);
155 // This is temporary solution. The sub-classes must be able
156 // to call SelectInputScalars() on other instances.
157 friend class vtkKitwareContourFilter;
160 // If you want to contour by an arbitrary array, then set its name here.
161 // By default this in NULL and the filter will use the active scalar array.
162 vtkGetStringMacro(InputScalarsSelection);
163 virtual void SelectInputScalars(const char *fieldName)
164 {this->SetInputScalarsSelection(fieldName);}
169 vtkContourFilter(const vtkContourFilter&); // Not implemented.
170 void operator=(const vtkContourFilter&); // Not implemented.
174 // Set a particular contour value at contour number i. The index i ranges
175 // between 0<=i<NumberOfContours.
176 inline void vtkContourFilter::SetValue(int i, float value)
177 {this->ContourValues->SetValue(i,value);}
180 // Get the ith contour value.
181 inline float vtkContourFilter::GetValue(int i)
182 {return this->ContourValues->GetValue(i);}
185 // Get a pointer to an array of contour values. There will be
186 // GetNumberOfContours() values in the list.
187 inline float *vtkContourFilter::GetValues()
188 {return this->ContourValues->GetValues();}
191 // Fill a supplied list with contour values. There will be
192 // GetNumberOfContours() values in the list. Make sure you allocate
193 // enough memory to hold the list.
194 inline void vtkContourFilter::GetValues(float *contourValues)
195 {this->ContourValues->GetValues(contourValues);}
198 // Set the number of contours to place into the list. You only really
199 // need to use this method to reduce list size. The method SetValue()
200 // will automatically increase list size as needed.
201 inline void vtkContourFilter::SetNumberOfContours(int number)
202 {this->ContourValues->SetNumberOfContours(number);}
205 // Get the number of contours in the list of contour values.
206 inline int vtkContourFilter::GetNumberOfContours()
207 {return this->ContourValues->GetNumberOfContours();}
210 // Generate numContours equally spaced contour values between specified
211 // range. Contour values will include min/max range values.
212 inline void vtkContourFilter::GenerateValues(int numContours, float range[2])
213 {this->ContourValues->GenerateValues(numContours, range);}
216 // Generate numContours equally spaced contour values between specified
217 // range. Contour values will include min/max range values.
218 inline void vtkContourFilter::GenerateValues(int numContours, float
219 rangeStart, float rangeEnd)
220 {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}