1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkRectilinearSynchronizedTemplates.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 /** 16 * @class vtkRectilinearSynchronizedTemplates 17 * @brief generate isosurface from rectilinear grid 18 * 19 * 20 * vtkRectilinearSynchronizedTemplates is a 3D implementation (for rectilinear 21 * grids) of the synchronized template algorithm. Note that vtkContourFilter 22 * will automatically use this class when appropriate. 23 * 24 * @warning 25 * This filter is specialized to rectilinear grids. 26 * 27 * @sa 28 * vtkContourFilter vtkSynchronizedTemplates2D vtkSynchronizedTemplates3D 29 */ 30 31 #ifndef vtkRectilinearSynchronizedTemplates_h 32 #define vtkRectilinearSynchronizedTemplates_h 33 34 #include "vtkContourValues.h" // Passes calls through 35 #include "vtkFiltersCoreModule.h" // For export macro 36 #include "vtkPolyDataAlgorithm.h" 37 38 class vtkRectilinearGrid; 39 class vtkDataArray; 40 41 class VTKFILTERSCORE_EXPORT vtkRectilinearSynchronizedTemplates : public vtkPolyDataAlgorithm 42 { 43 public: 44 static vtkRectilinearSynchronizedTemplates* New(); 45 46 vtkTypeMacro(vtkRectilinearSynchronizedTemplates, vtkPolyDataAlgorithm); 47 void PrintSelf(ostream& os, vtkIndent indent) override; 48 49 /** 50 * Because we delegate to vtkContourValues 51 */ 52 vtkMTimeType GetMTime() override; 53 54 ///@{ 55 /** 56 * Set/Get the computation of normals. Normal computation is fairly 57 * expensive in both time and storage. If the output data will be 58 * processed by filters that modify topology or geometry, it may be 59 * wise to turn Normals and Gradients off. 60 */ 61 vtkSetMacro(ComputeNormals, vtkTypeBool); 62 vtkGetMacro(ComputeNormals, vtkTypeBool); 63 vtkBooleanMacro(ComputeNormals, vtkTypeBool); 64 ///@} 65 66 ///@{ 67 /** 68 * Set/Get the computation of gradients. Gradient computation is 69 * fairly expensive in both time and storage. Note that if 70 * ComputeNormals is on, gradients will have to be calculated, but 71 * will not be stored in the output dataset. If the output data 72 * will be processed by filters that modify topology or geometry, it 73 * may be wise to turn Normals and Gradients off. 74 */ 75 vtkSetMacro(ComputeGradients, vtkTypeBool); 76 vtkGetMacro(ComputeGradients, vtkTypeBool); 77 vtkBooleanMacro(ComputeGradients, vtkTypeBool); 78 ///@} 79 80 ///@{ 81 /** 82 * Set/Get the computation of scalars. 83 */ 84 vtkSetMacro(ComputeScalars, vtkTypeBool); 85 vtkGetMacro(ComputeScalars, vtkTypeBool); 86 vtkBooleanMacro(ComputeScalars, vtkTypeBool); 87 ///@} 88 89 /** 90 * Set a particular contour value at contour number i. The index i ranges 91 * between 0<=i<NumberOfContours. 92 */ SetValue(int i,double value)93 void SetValue(int i, double value) { this->ContourValues->SetValue(i, value); } 94 95 /** 96 * Get the ith contour value. 97 */ GetValue(int i)98 double GetValue(int i) { return this->ContourValues->GetValue(i); } 99 100 /** 101 * Get a pointer to an array of contour values. There will be 102 * GetNumberOfContours() values in the list. 103 */ GetValues()104 double* GetValues() { return this->ContourValues->GetValues(); } 105 106 /** 107 * Fill a supplied list with contour values. There will be 108 * GetNumberOfContours() values in the list. Make sure you allocate 109 * enough memory to hold the list. 110 */ GetValues(double * contourValues)111 void GetValues(double* contourValues) { this->ContourValues->GetValues(contourValues); } 112 113 /** 114 * Set the number of contours to place into the list. You only really 115 * need to use this method to reduce list size. The method SetValue() 116 * will automatically increase list size as needed. 117 */ SetNumberOfContours(int number)118 void SetNumberOfContours(int number) { this->ContourValues->SetNumberOfContours(number); } 119 120 /** 121 * Get the number of contours in the list of contour values. 122 */ GetNumberOfContours()123 vtkIdType GetNumberOfContours() { return this->ContourValues->GetNumberOfContours(); } 124 125 /** 126 * Generate numContours equally spaced contour values between specified 127 * range. Contour values will include min/max range values. 128 */ GenerateValues(int numContours,double range[2])129 void GenerateValues(int numContours, double range[2]) 130 { 131 this->ContourValues->GenerateValues(numContours, range); 132 } 133 134 /** 135 * Generate numContours equally spaced contour values between specified 136 * range. Contour values will include min/max range values. 137 */ GenerateValues(int numContours,double rangeStart,double rangeEnd)138 void GenerateValues(int numContours, double rangeStart, double rangeEnd) 139 { 140 this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd); 141 } 142 143 ///@{ 144 /** 145 * Set/get which component of the scalar array to contour on; defaults to 0. 146 */ 147 vtkSetMacro(ArrayComponent, int); 148 vtkGetMacro(ArrayComponent, int); 149 ///@} 150 151 ///@{ 152 /** 153 * If this is enabled (by default), the output will be triangles 154 * otherwise, the output will be the intersection polygons 155 */ 156 vtkSetMacro(GenerateTriangles, vtkTypeBool); 157 vtkGetMacro(GenerateTriangles, vtkTypeBool); 158 vtkBooleanMacro(GenerateTriangles, vtkTypeBool); 159 ///@} 160 161 /** 162 * Compute the spacing between this point and its 6 neighbors. This method 163 * needs to be public so it can be accessed from a templated function. 164 */ 165 void ComputeSpacing( 166 vtkRectilinearGrid* data, int i, int j, int k, int extent[6], double spacing[6]); 167 168 protected: 169 vtkRectilinearSynchronizedTemplates(); 170 ~vtkRectilinearSynchronizedTemplates() override; 171 172 vtkTypeBool ComputeNormals; 173 vtkTypeBool ComputeGradients; 174 vtkTypeBool ComputeScalars; 175 vtkTypeBool GenerateTriangles; 176 177 vtkContourValues* ContourValues; 178 179 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 180 int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; 181 int FillInputPortInformation(int port, vtkInformation* info) override; 182 183 int ArrayComponent; 184 185 void* GetScalarsForExtent(vtkDataArray* array, int extent[6], vtkRectilinearGrid* input); 186 187 private: 188 vtkRectilinearSynchronizedTemplates(const vtkRectilinearSynchronizedTemplates&) = delete; 189 void operator=(const vtkRectilinearSynchronizedTemplates&) = delete; 190 }; 191 192 // template table. 193 194 extern int VTK_RECTILINEAR_SYNCHONIZED_TEMPLATES_TABLE_1[]; 195 extern int VTK_RECTILINEAR_SYNCHONIZED_TEMPLATES_TABLE_2[]; 196 197 #endif 198