1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkMarchingContourFilter.h,v $
6 Date: $Date: 2002/09/30 20:35:19 $
7 Version: $Revision: 1.21 $
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 THIS CLASS IS PATENTED UNDER UNITED STATES PATENT NUMBER 4,710,876
18 "System and Method for the Display of Surface Structures Contained
19 Within the Interior Region of a Solid Body".
20 Application of this software for commercial purposes requires
21 a license grant from GE. Contact:
24 Sr. Counsel, Intellectual Property
25 3000 N. Grandview Blvd., W-710
28 E-Mail: Carl.Horton@med.ge.com
32 =========================================================================*/
33 // .NAME vtkMarchingContourFilter - generate isosurfaces/isolines from scalar values
34 // .SECTION Description
35 // vtkMarchingContourFilter is a filter that takes as input any dataset and
36 // generates on output isosurfaces and/or isolines. The exact form
37 // of the output depends upon the dimensionality of the input data.
38 // Data consisting of 3D cells will generate isosurfaces, data
39 // consisting of 2D cells will generate isolines, and data with 1D
40 // or 0D cells will generate isopoints. Combinations of output type
41 // are possible if the input dimension is mixed.
43 // This filter will identify special dataset types (e.g., structured
44 // points) and use the appropriate specialized filter to process the
45 // data. For examples, if the input dataset type is a volume, this
46 // filter will create an internal vtkMarchingCubes instance and use
47 // it. This gives much better performance.
49 // To use this filter you must specify one or more contour values.
50 // You can either use the method SetValue() to specify each contour
51 // value, or use GenerateValues() to generate a series of evenly
52 // spaced contours. It is also possible to accelerate the operation of
53 // this filter (at the cost of extra memory) by using a
54 // vtkScalarTree. A scalar tree is used to quickly locate cells that
55 // contain a contour surface. This is especially effective if multiple
56 // contours are being extracted. If you want to use a scalar tree,
57 // invoke the method UseScalarTreeOn().
60 // For unstructured data or structured grids, normals and gradients
61 // are not computed. This calculation will be implemented in the
62 // future. In the mean time, use vtkPolyDataNormals to compute the surface
66 // vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
67 // vtkImageMarchingCubes
69 #ifndef __vtkMarchingContourFilter_h
70 #define __vtkMarchingContourFilter_h
72 #include "vtkDataSetToPolyDataFilter.h"
74 #include "vtkContourValues.h" // Needed for direct access to ContourValues
76 class vtkPointLocator;
79 class VTK_PATENTED_EXPORT vtkMarchingContourFilter : public vtkDataSetToPolyDataFilter
82 vtkTypeRevisionMacro(vtkMarchingContourFilter,vtkDataSetToPolyDataFilter);
83 void PrintSelf(ostream& os, vtkIndent indent);
86 // Construct object with initial range (0,1) and single contour value
88 static vtkMarchingContourFilter *New();
91 // Methods to set / get contour values.
92 void SetValue(int i, float value);
93 float GetValue(int i);
95 void GetValues(float *contourValues);
96 void SetNumberOfContours(int number);
97 int GetNumberOfContours();
98 void GenerateValues(int numContours, float range[2]);
99 void GenerateValues(int numContours, float rangeStart, float rangeEnd);
102 // Modified GetMTime Because we delegate to vtkContourValues
103 unsigned long GetMTime();
106 // Set/Get the computation of normals. Normal computation is fairly
107 // expensive in both time and storage. If the output data will be
108 // processed by filters that modify topology or geometry, it may be
109 // 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
116 // fairly expensive in both time and storage. Note that if
117 // ComputeNormals is on, gradients will have to be calculated, but
118 // will not be stored in the output dataset. If the output data
119 // will be processed by filters that modify topology or geometry, it
120 // may be wise to turn Normals and Gradients off.
121 vtkSetMacro(ComputeGradients,int);
122 vtkGetMacro(ComputeGradients,int);
123 vtkBooleanMacro(ComputeGradients,int);
126 // Set/Get the computation of scalars.
127 vtkSetMacro(ComputeScalars,int);
128 vtkGetMacro(ComputeScalars,int);
129 vtkBooleanMacro(ComputeScalars,int);
132 // Enable the use of a scalar tree to accelerate contour extraction.
133 vtkSetMacro(UseScalarTree,int);
134 vtkGetMacro(UseScalarTree,int);
135 vtkBooleanMacro(UseScalarTree,int);
138 // Set / get a spatial locator for merging points. By default,
139 // an instance of vtkMergePoints is used.
140 void SetLocator(vtkPointLocator *locator);
141 vtkGetObjectMacro(Locator,vtkPointLocator);
144 // Create default locator. Used to create one when none is
145 // specified. The locator is used to merge coincident points.
146 void CreateDefaultLocator();
149 vtkMarchingContourFilter();
150 ~vtkMarchingContourFilter();
154 vtkContourValues *ContourValues;
156 int ComputeGradients;
158 vtkPointLocator *Locator;
160 vtkScalarTree *ScalarTree;
162 //special contouring for structured points
163 void StructuredPointsContour(int dim);
164 //special contouring for image data
165 void ImageContour(int dim);
166 //default if not structured data
167 void DataSetContour();
169 vtkMarchingContourFilter(const vtkMarchingContourFilter&); // Not implemented.
170 void operator=(const vtkMarchingContourFilter&); // Not implemented.
174 // Set a particular contour value at contour number i. The index i ranges
175 // between 0<=i<NumberOfContours.
176 inline void vtkMarchingContourFilter::SetValue(int i, float value)
178 this->ContourValues->SetValue(i,value);
182 // Get the ith contour value.
183 inline float vtkMarchingContourFilter::GetValue(int i)
185 return this->ContourValues->GetValue(i);
189 // Get a pointer to an array of contour values. There will be
190 // GetNumberOfContours() values in the list.
191 inline float *vtkMarchingContourFilter::GetValues()
193 return this->ContourValues->GetValues();
197 // Fill a supplied list with contour values. There will be
198 // GetNumberOfContours() values in the list. Make sure you allocate
199 // enough memory to hold the list.
200 inline void vtkMarchingContourFilter::GetValues(float *contourValues)
202 this->ContourValues->GetValues(contourValues);
206 // Set the number of contours to place into the list. You only really
207 // need to use this method to reduce list size. The method SetValue()
208 // will automatically increase list size as needed.
209 inline void vtkMarchingContourFilter::SetNumberOfContours(int number)
211 this->ContourValues->SetNumberOfContours(number);
215 // Get the number of contours in the list of contour values.
216 inline int vtkMarchingContourFilter::GetNumberOfContours()
218 return this->ContourValues->GetNumberOfContours();
222 // Generate numContours equally spaced contour values between specified
223 // range. Contour values will include min/max range values.
224 inline void vtkMarchingContourFilter::GenerateValues(int numContours,
227 this->ContourValues->GenerateValues(numContours, range);
231 // Generate numContours equally spaced contour values between specified
232 // range. Contour values will include min/max range values.
233 inline void vtkMarchingContourFilter::GenerateValues(int numContours,
237 this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);