OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkMarchingContourFilter.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkMarchingContourFilter.h,v $
5   Language:  C++
6   Date:      $Date: 2002/09/30 20:35:19 $
7   Version:   $Revision: 1.21 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
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:
22
23          Carl B. Horton
24          Sr. Counsel, Intellectual Property
25          3000 N. Grandview Blvd., W-710
26          Waukesha, WI  53188
27          Phone:  (262) 513-4022
28          E-Mail: Carl.Horton@med.ge.com
29
30      for more information.
31
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.
42 //
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.
48 // 
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().
58
59 // .SECTION Caveats
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
63 // normals.
64
65 // .SECTION See Also
66 // vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
67 // vtkImageMarchingCubes
68
69 #ifndef __vtkMarchingContourFilter_h
70 #define __vtkMarchingContourFilter_h
71
72 #include "vtkDataSetToPolyDataFilter.h"
73
74 #include "vtkContourValues.h" // Needed for direct access to ContourValues
75
76 class vtkPointLocator;
77 class vtkScalarTree;
78
79 class VTK_PATENTED_EXPORT vtkMarchingContourFilter : public vtkDataSetToPolyDataFilter
80 {
81 public:
82   vtkTypeRevisionMacro(vtkMarchingContourFilter,vtkDataSetToPolyDataFilter);
83   void PrintSelf(ostream& os, vtkIndent indent);
84
85   // Description:
86   // Construct object with initial range (0,1) and single contour value
87   // of 0.0.
88   static vtkMarchingContourFilter *New();
89
90   // Description:
91   // Methods to set / get contour values.
92   void SetValue(int i, float value);
93   float GetValue(int i);
94   float *GetValues();
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);
100
101   // Description:
102   // Modified GetMTime Because we delegate to vtkContourValues
103   unsigned long GetMTime();
104
105   // Description:
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);
113
114   // Description:
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);
124
125   // Description:
126   // Set/Get the computation of scalars.
127   vtkSetMacro(ComputeScalars,int);
128   vtkGetMacro(ComputeScalars,int);
129   vtkBooleanMacro(ComputeScalars,int);
130
131   // Description:
132   // Enable the use of a scalar tree to accelerate contour extraction.
133   vtkSetMacro(UseScalarTree,int);
134   vtkGetMacro(UseScalarTree,int);
135   vtkBooleanMacro(UseScalarTree,int);
136
137   // Description:
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);
142
143   // Description:
144   // Create default locator. Used to create one when none is
145   // specified. The locator is used to merge coincident points.
146   void CreateDefaultLocator();
147
148 protected:
149   vtkMarchingContourFilter();
150   ~vtkMarchingContourFilter();
151
152   void Execute();
153
154   vtkContourValues *ContourValues;
155   int ComputeNormals;
156   int ComputeGradients;
157   int ComputeScalars;
158   vtkPointLocator *Locator;
159   int UseScalarTree;
160   vtkScalarTree *ScalarTree;
161   
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();
168 private:
169   vtkMarchingContourFilter(const vtkMarchingContourFilter&);  // Not implemented.
170   void operator=(const vtkMarchingContourFilter&);  // Not implemented.
171 };
172
173 // Description:
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)
177 {
178   this->ContourValues->SetValue(i,value);
179 }
180
181 // Description:
182 // Get the ith contour value.
183 inline float vtkMarchingContourFilter::GetValue(int i)
184 {
185   return this->ContourValues->GetValue(i);
186 }
187
188 // Description:
189 // Get a pointer to an array of contour values. There will be
190 // GetNumberOfContours() values in the list.
191 inline float *vtkMarchingContourFilter::GetValues()
192 {
193   return this->ContourValues->GetValues();
194 }
195
196 // Description:
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)
201 {
202   this->ContourValues->GetValues(contourValues);
203 }
204
205 // Description:
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)
210 {
211   this->ContourValues->SetNumberOfContours(number);
212 }
213
214 // Description:
215 // Get the number of contours in the list of contour values.
216 inline int vtkMarchingContourFilter::GetNumberOfContours()
217 {
218   return this->ContourValues->GetNumberOfContours();
219 }
220
221 // Description:
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,
225                                                      float range[2])
226 {
227   this->ContourValues->GenerateValues(numContours, range);
228 }
229
230 // Description:
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,
234                                                      float rangeStart,
235                                                      float rangeEnd)
236 {
237   this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);
238 }
239
240 #endif