1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkThreadedSynchronizedTemplates3D.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 vtkThreadedSynchronizedTemplates3D - generate isosurface from structured points
16 
17 // .SECTION Description
18 // vtkThreadedSynchronizedTemplates3D is a 3D implementation of the synchronized
19 // template algorithm. Note that vtkContourFilter will automatically
20 // use this class when appropriate.
21 
22 // .SECTION Caveats
23 // This filter is specialized to 3D images (aka volumes).
24 
25 // .SECTION See Also
26 // vtkContourFilter vtkThreadedSynchronizedTemplates2D
27 
28 #ifndef __vtkThreadedSynchronizedTemplates3D_h
29 #define __vtkThreadedSynchronizedTemplates3D_h
30 
31 #include "vtkFiltersSMPModule.h" // For export macro
32 #include "vtkMultiBlockDataSetAlgorithm.h"
33 #include "vtkContourValues.h" // Passes calls through
34 
35 class vtkImageData;
36 
37 class VTKFILTERSSMP_EXPORT vtkThreadedSynchronizedTemplates3D : public vtkMultiBlockDataSetAlgorithm
38 {
39 public:
40   static vtkThreadedSynchronizedTemplates3D *New();
41 
42   vtkTypeMacro(vtkThreadedSynchronizedTemplates3D,vtkMultiBlockDataSetAlgorithm);
43   void PrintSelf(ostream& os, vtkIndent indent);
44 
45   // Description:
46   // Because we delegate to vtkContourValues
47   unsigned long int GetMTime();
48 
49   // Description:
50   // Set/Get the computation of normals. Normal computation is fairly
51   // expensive in both time and storage. If the output data will be
52   // processed by filters that modify topology or geometry, it may be
53   // wise to turn Normals and Gradients off.
54   vtkSetMacro(ComputeNormals,int);
55   vtkGetMacro(ComputeNormals,int);
56   vtkBooleanMacro(ComputeNormals,int);
57 
58   // Description:
59   // Set/Get the computation of gradients. Gradient computation is
60   // fairly expensive in both time and storage. Note that if
61   // ComputeNormals is on, gradients will have to be calculated, but
62   // will not be stored in the output dataset.  If the output data
63   // will be processed by filters that modify topology or geometry, it
64   // may be wise to turn Normals and Gradients off.
65   vtkSetMacro(ComputeGradients,int);
66   vtkGetMacro(ComputeGradients,int);
67   vtkBooleanMacro(ComputeGradients,int);
68 
69   // Description:
70   // Set/Get the computation of scalars.
71   vtkSetMacro(ComputeScalars,int);
72   vtkGetMacro(ComputeScalars,int);
73   vtkBooleanMacro(ComputeScalars,int);
74 
75  // Description:
76   // If this is enabled (by default), the output will be triangles
77   // otherwise, the output will be the intersection polygons
78   vtkSetMacro(GenerateTriangles,int);
79   vtkGetMacro(GenerateTriangles,int);
80   vtkBooleanMacro(GenerateTriangles,int);
81 
82   // Description:
83   // Set a particular contour value at contour number i. The index i ranges
84   // between 0<=i<NumberOfContours.
SetValue(int i,double value)85   void SetValue(int i, double value) {this->ContourValues->SetValue(i,value);}
86 
87   // Description:
88   // Get the ith contour value.
GetValue(int i)89   double GetValue(int i) {return this->ContourValues->GetValue(i);}
90 
91   // Description:
92   // Get a pointer to an array of contour values. There will be
93   // GetNumberOfContours() values in the list.
GetValues()94   double *GetValues() {return this->ContourValues->GetValues();}
95 
96   // Description:
97   // Fill a supplied list with contour values. There will be
98   // GetNumberOfContours() values in the list. Make sure you allocate
99   // enough memory to hold the list.
GetValues(double * contourValues)100   void GetValues(double *contourValues) {
101     this->ContourValues->GetValues(contourValues);}
102 
103   // Description:
104   // Set the number of contours to place into the list. You only really
105   // need to use this method to reduce list size. The method SetValue()
106   // will automatically increase list size as needed.
SetNumberOfContours(int number)107   void SetNumberOfContours(int number) {
108     this->ContourValues->SetNumberOfContours(number);}
109 
110   // Description:
111   // Get the number of contours in the list of contour values.
GetNumberOfContours()112   int GetNumberOfContours() {
113     return this->ContourValues->GetNumberOfContours();}
114 
115   // Description:
116   // Generate numContours equally spaced contour values between specified
117   // range. Contour values will include min/max range values.
GenerateValues(int numContours,double range[2])118   void GenerateValues(int numContours, double range[2]) {
119     this->ContourValues->GenerateValues(numContours, range);}
120 
121   // Description:
122   // Generate numContours equally spaced contour values between specified
123   // range. Contour values will include min/max range values.
GenerateValues(int numContours,double rangeStart,double rangeEnd)124   void GenerateValues(int numContours, double rangeStart, double rangeEnd)
125     {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}
126 
127   void ThreadedExecute(vtkImageData *data,
128                        vtkInformation *inInfo,
129                        vtkInformation *outInfo,
130                        vtkDataArray *inScalars);
131 
132   // Description:
133   // Determines the chunk size fro streaming.  This filter will act like a
134   // collector: ask for many input pieces, but generate one output.  Limit is
135   // in KBytes
136   void SetInputMemoryLimit(unsigned long limit);
137   unsigned long GetInputMemoryLimit();
138 
139   // Description:
140   // Set/get which component of the scalar array to contour on; defaults to 0.
141   vtkSetMacro(ArrayComponent, int);
142   vtkGetMacro(ArrayComponent, int);
143 
144 protected:
145   vtkThreadedSynchronizedTemplates3D();
146   ~vtkThreadedSynchronizedTemplates3D();
147 
148   int ComputeNormals;
149   int ComputeGradients;
150   int ComputeScalars;
151   vtkContourValues *ContourValues;
152 
153   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
154   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
155   virtual int FillInputPortInformation(int port, vtkInformation *info);
156 
157   int ArrayComponent;
158 
159   int GenerateTriangles;
160 
161 private:
162   vtkThreadedSynchronizedTemplates3D(const vtkThreadedSynchronizedTemplates3D&);  // Not implemented.
163   void operator=(const vtkThreadedSynchronizedTemplates3D&);  // Not implemented.
164 };
165 
166 
167 // template table.
168 //BTX
169 
170 extern int VTKFILTERSSMP_EXPORT VTK_TSYNCHRONIZED_TEMPLATES_3D_TABLE_1[];
171 extern int VTKFILTERSSMP_EXPORT VTK_TSYNCHRONIZED_TEMPLATES_3D_TABLE_2[];
172 
173 //ETX
174 
175 #endif
176