1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkContourFilter.h,v $
6 Date: $Date: 2002/02/01 06:33:16 $
7 Version: $Revision: 1.1.1.1 $
10 Copyright (c) 1993-1998 Ken Martin, Will Schroeder, Bill Lorensen.
12 This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
13 The following terms apply to all files associated with the software unless
14 explicitly disclaimed in individual files. This copyright specifically does
15 not apply to the related textbook "The Visualization Toolkit" ISBN
16 013199837-4 published by Prentice Hall which is covered by its own copyright.
18 The authors hereby grant permission to use, copy, and distribute this
19 software and its documentation for any purpose, provided that existing
20 copyright notices are retained in all copies and that this notice is included
21 verbatim in any distributions. Additionally, the authors grant permission to
22 modify this software and its documentation for any purpose, provided that
23 such modifications are not distributed without the explicit consent of the
24 authors and that existing copyright notices are retained in all copies. Some
25 of the algorithms implemented by this software are patented, observe all
26 applicable patent law.
28 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
29 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
30 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
31 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
34 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35 PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN
36 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
37 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
40 =========================================================================*/
41 // .NAME vtkContourFilter - generate isosurfaces/isolines from scalar values
42 // .SECTION Description
43 // vtkContourFilter is a filter that takes as input any dataset and
44 // generates on output isosurfaces and/or isolines. The exact form
45 // of the output depends upon the dimensionality of the input data.
46 // Data consisting of 3D cells will generate isosurfaces, data
47 // consisting of 2D cells will generate isolines, and data with 1D
48 // or 0D cells will generate isopoints. Combinations of output type
49 // are possible if the input dimension is mixed.
51 // This filter will identify special dataset types (e.g., structured
52 // points) and use the appropriate specialized filter to process the
53 // data. For examples, if the input dataset type is a volume, this
54 // filter will create an internal vtkMarchingCubes instance and use
55 // it. This gives much better performance.
57 // To use this filter you must specify one or more contour values.
58 // You can either use the method SetValue() to specify each contour
59 // value, or use GenerateValues() to generate a series of evenly
60 // spaced contours. It is also possible to accelerate the operation of
61 // this filter (at the cost of extra memory) by using a
62 // vtkScalarTree. A scalar tree is used to quickly locate cells that
63 // contain a contour surface. This is especially effective if multiple
64 // contours are being extracted. If you want to use a scalar tree,
65 // invoke the method UseScalarTreeOn().
68 // For unstructured data or structured grids, normals and gradients
69 // are not computed. This calculation will be implemented in the
70 // future. In the mean time, use vtkPolyDataNormals to compute the surface
74 // vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
76 #ifndef __vtkContourFilter_h
77 #define __vtkContourFilter_h
79 #include "vtkDataSetToPolyDataFilter.h"
80 #include "vtkContourValues.h"
84 class VTK_EXPORT vtkContourFilter : public vtkDataSetToPolyDataFilter
88 static vtkContourFilter *New() {return new vtkContourFilter;};
90 const char *GetClassName() {return "vtkContourFilter";};
91 void PrintSelf(ostream& os, vtkIndent indent);
93 // Methods to set contour values
94 void SetValue(int i, float value);
95 float GetValue(int i);
97 void GetValues(float *contourValues);
98 void SetNumberOfContours(int number);
99 int GetNumberOfContours();
100 void GenerateValues(int numContours, float range[2]);
101 void GenerateValues(int numContours, float rangeStart, float rangeEnd);
103 // Because we delegate to vtkContourValues
104 unsigned long int GetMTime();
107 // Set/Get the computation of normals. Normal computation is failrly expensive
108 // in both time and storage. If the output data will be processed by filters
109 // that modify topology or geometry, it may be wise to turn Normals and Gradients off.
110 vtkSetMacro(ComputeNormals,int);
111 vtkGetMacro(ComputeNormals,int);
112 vtkBooleanMacro(ComputeNormals,int);
115 // Set/Get the computation of gradients. Gradient computation is fairly expensive
116 // in both time and storage. Note that if ComputeNormals is on, gradients will
117 // have to be calculated, but will not be stored in the output dataset.
118 // If the output data will be processed by filters that modify topology or
119 // geometry, it may be wise to turn Normals and Gradients off.
120 vtkSetMacro(ComputeGradients,int);
121 vtkGetMacro(ComputeGradients,int);
122 vtkBooleanMacro(ComputeGradients,int);
125 // Set/Get the computation of scalars.
126 vtkSetMacro(ComputeScalars,int);
127 vtkGetMacro(ComputeScalars,int);
128 vtkBooleanMacro(ComputeScalars,int);
131 // Enable the use of a scalar tree to accelerate contour extraction.
132 vtkSetMacro(UseScalarTree,int);
133 vtkGetMacro(UseScalarTree,int);
134 vtkBooleanMacro(UseScalarTree,int);
136 void SetLocator(vtkPointLocator *locator);
137 void SetLocator(vtkPointLocator& locator) {this->SetLocator(&locator);};
138 vtkGetObjectMacro(Locator,vtkPointLocator);
141 // Create default locator. Used to create one when none is specified. The locator is
142 // used to merge coincident points.
143 void CreateDefaultLocator();
148 vtkContourValues *ContourValues;
150 int ComputeGradients;
152 vtkPointLocator *Locator;
153 int SelfCreatedLocator;
155 vtkScalarTree *ScalarTree;
157 void StructuredPointsContour(int dim); //special contouring for structured points
161 // Set a particular contour value at contour number i. The index i ranges
162 // between 0<=i<NumberOfContours.
163 inline void vtkContourFilter::SetValue(int i, float value)
164 {this->ContourValues->SetValue(i,value);}
167 // Get the ith contour value.
168 inline float vtkContourFilter::GetValue(int i)
169 {return this->ContourValues->GetValue(i);}
172 // Get a pointer to an array of contour values. There will be
173 // GetNumberOfContours() values in the list.
174 inline float *vtkContourFilter::GetValues()
175 {return this->ContourValues->GetValues();}
178 // Fill a supplied list with contour values. There will be
179 // GetNumberOfContours() values in the list. Make sure you allocate
180 // enough memory to hold the list.
181 inline void vtkContourFilter::GetValues(float *contourValues)
182 {this->ContourValues->GetValues(contourValues);}
185 // Set the number of contours to place into the list. You only really
186 // need to use this method to reduce list size. The method SetValue()
187 // will automatically increase list size as needed.
188 inline void vtkContourFilter::SetNumberOfContours(int number)
189 {this->ContourValues->SetNumberOfContours(number);}
192 // Get the number of contours in the list of contour values.
193 inline int vtkContourFilter::GetNumberOfContours()
194 {return this->ContourValues->GetNumberOfContours();}
197 // Generate numContours equally spaced contour values between specified
198 // range. Contour values will include min/max range values.
199 inline void vtkContourFilter::GenerateValues(int numContours, float range[2])
200 {this->ContourValues->GenerateValues(numContours, range);}
203 // Generate numContours equally spaced contour values between specified
204 // range. Contour values will include min/max range values.
205 inline void vtkContourFilter::GenerateValues(int numContours, float
206 rangeStart, float rangeEnd)
207 {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}