VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkHyperOctreeCutter.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00048 #ifndef __vtkHyperOctreeCutter_h 00049 #define __vtkHyperOctreeCutter_h 00050 00051 #include "vtkFiltersHyperTreeModule.h" // For export macro 00052 #include "vtkPolyDataAlgorithm.h" 00053 00054 #include "vtkContourValues.h" // Needed for inline methods 00055 00056 #include "vtkCutter.h" // for VTK_SORT_BY_VALUE and VTK_SORT_BY_CELL 00057 00058 //#define VTK_SORT_BY_VALUE 0 00059 //#define VTK_SORT_BY_CELL 1 00060 // This does not really belong here, ut it is for a temporary 00061 // fix until this filter can be converted to geernate unstructured grids. 00062 //#define VTK_NUMBER_OF_CELL_TYPES 68 00063 00064 class vtkImplicitFunction; 00065 class vtkIncrementalPointLocator; 00066 class vtkHyperOctree; 00067 class vtkOrderedTriangulator; 00068 class vtkHyperOctreeCursor; 00069 class vtkTetra; 00070 class vtkDataSetAttributes; 00071 class vtkHyperOctreeClipCutPointsGrabber; 00072 00073 class VTKFILTERSHYPERTREE_EXPORT vtkHyperOctreeCutter : public vtkPolyDataAlgorithm 00074 { 00075 public: 00076 vtkTypeMacro(vtkHyperOctreeCutter,vtkPolyDataAlgorithm); 00077 void PrintSelf(ostream& os, vtkIndent indent); 00078 00081 static vtkHyperOctreeCutter *New(); 00082 00084 00086 void SetValue(int i, double value) 00087 {this->ContourValues->SetValue(i,value);} 00089 00091 00092 double GetValue(int i) 00093 {return this->ContourValues->GetValue(i);} 00095 00097 00099 double *GetValues() 00100 {return this->ContourValues->GetValues();} 00102 00104 00107 void GetValues(double *contourValues) 00108 {this->ContourValues->GetValues(contourValues);} 00110 00112 00115 void SetNumberOfContours(int number) 00116 {this->ContourValues->SetNumberOfContours(number);} 00118 00120 00121 int GetNumberOfContours() 00122 {return this->ContourValues->GetNumberOfContours();} 00124 00126 00128 void GenerateValues(int numContours, double range[2]) 00129 {this->ContourValues->GenerateValues(numContours, range);} 00131 00133 00135 void GenerateValues(int numContours, double rangeStart, double rangeEnd) 00136 {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);} 00138 00141 unsigned long GetMTime(); 00142 00144 00145 virtual void SetCutFunction(vtkImplicitFunction*); 00146 vtkGetObjectMacro(CutFunction,vtkImplicitFunction); 00148 00150 00153 vtkSetMacro(GenerateCutScalars,int); 00154 vtkGetMacro(GenerateCutScalars,int); 00155 vtkBooleanMacro(GenerateCutScalars,int); 00157 00159 00161 void SetLocator(vtkIncrementalPointLocator *locator); 00162 vtkGetObjectMacro(Locator,vtkIncrementalPointLocator); 00164 00166 00176 vtkSetClampMacro(SortBy,int,VTK_SORT_BY_VALUE,VTK_SORT_BY_CELL); 00177 vtkGetMacro(SortBy,int); 00178 void SetSortByToSortByValue() 00179 {this->SetSortBy(VTK_SORT_BY_VALUE);} 00180 void SetSortByToSortByCell() 00181 {this->SetSortBy(VTK_SORT_BY_CELL);} 00183 00185 00186 const char *GetSortByAsString() 00187 { 00188 if ( this->SortBy == VTK_SORT_BY_VALUE ) 00189 { 00190 return "SortByValue"; 00191 } 00192 else 00193 { 00194 return "SortByCell"; 00195 } 00196 } 00198 00201 void CreateDefaultLocator(); 00202 00203 protected: 00204 vtkHyperOctreeCutter(vtkImplicitFunction *cf=NULL); 00205 ~vtkHyperOctreeCutter(); 00206 00207 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00208 virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00209 virtual int FillInputPortInformation(int port, vtkInformation *info); 00210 00212 00214 void CutNode(vtkHyperOctreeCursor *cursor, 00215 int level, 00216 double bounds[6]); 00218 00219 vtkImplicitFunction *CutFunction; 00220 00221 00222 vtkIncrementalPointLocator *Locator; 00223 int SortBy; 00224 vtkContourValues *ContourValues; 00225 int GenerateCutScalars; 00226 00227 vtkHyperOctree *Input; 00228 vtkPolyData *Output; 00229 00230 00231 vtkCellArray *NewVerts; 00232 vtkCellArray *NewLines; 00233 vtkCellArray *NewPolys; 00234 00235 vtkDataSetAttributes *InCD; 00236 vtkCellData *OutCD; 00237 vtkPointData *OutPD; 00238 vtkOrderedTriangulator *Triangulator; 00239 vtkHyperOctreeCursor *Sibling; // to avoid allocation in the loop 00240 00241 int Iter; // iterate over contour values in case of VTK_SORT_BY_CELL 00242 00243 00244 vtkDoubleArray *CellScalars; 00245 vtkTetra *Tetra; 00246 vtkDoubleArray *TetScalars; 00247 00248 vtkPoints *Pts; 00249 vtkPolygon *Polygon; 00250 00251 vtkIdType CellTypeCounter[65536]; // up-to-65536 points per octant 00252 vtkIdType TotalCounter; 00253 vtkIdType TemplateCounter; // record the number of octants that succceed 00254 // to use the template triangulator 00255 00256 // in VTK_SORT_BY_VALUE case, rejection test need to combine all values. 00257 int *AllLess; 00258 int *AllGreater; 00259 vtkHyperOctreeClipCutPointsGrabber *Grabber; 00260 00261 private: 00262 vtkHyperOctreeCutter(const vtkHyperOctreeCutter&); // Not implemented. 00263 void operator=(const vtkHyperOctreeCutter&); // Not implemented. 00264 }; 00265 00266 #endif