VTK
dox/Graphics/vtkHyperOctreeCutter.h
Go to the documentation of this file.
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 "vtkPolyDataAlgorithm.h"
00052 
00053 #include "vtkContourValues.h" // Needed for inline methods
00054 
00055 #include "vtkCutter.h" // for VTK_SORT_BY_VALUE and VTK_SORT_BY_CELL
00056 
00057 //#define VTK_SORT_BY_VALUE 0
00058 //#define VTK_SORT_BY_CELL 1
00059 // This does not really belong here,  ut it is for a temporary
00060 // fix until this filter can be converted to geernate unstructured grids.
00061 //#define VTK_NUMBER_OF_CELL_TYPES 68
00062 
00063 class vtkImplicitFunction;
00064 class vtkIncrementalPointLocator;
00065 class vtkHyperOctree;
00066 class vtkOrderedTriangulator;
00067 class vtkHyperOctreeCursor;
00068 class vtkTetra;
00069 class vtkDataSetAttributes;
00070 class vtkHyperOctreeClipCutPointsGrabber;
00071 
00072 class VTK_GRAPHICS_EXPORT vtkHyperOctreeCutter : public vtkPolyDataAlgorithm
00073 {
00074 public:
00075   vtkTypeMacro(vtkHyperOctreeCutter,vtkPolyDataAlgorithm);
00076   void PrintSelf(ostream& os, vtkIndent indent);
00077 
00080   static vtkHyperOctreeCutter *New();
00081 
00083 
00085   void SetValue(int i, double value) 
00086     {this->ContourValues->SetValue(i,value);}
00088   
00090 
00091   double GetValue(int i) 
00092     {return this->ContourValues->GetValue(i);}
00094 
00096 
00098   double *GetValues() 
00099     {return this->ContourValues->GetValues();}
00101 
00103 
00106   void GetValues(double *contourValues)
00107     {this->ContourValues->GetValues(contourValues);}
00109   
00111 
00114   void SetNumberOfContours(int number) 
00115     {this->ContourValues->SetNumberOfContours(number);}
00117 
00119 
00120   int GetNumberOfContours() 
00121     {return this->ContourValues->GetNumberOfContours();}
00123 
00125 
00127   void GenerateValues(int numContours, double range[2]) 
00128     {this->ContourValues->GenerateValues(numContours, range);}
00130 
00132 
00134   void GenerateValues(int numContours, double rangeStart, double rangeEnd) 
00135     {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}
00137 
00140   unsigned long GetMTime();
00141 
00143 
00144   virtual void SetCutFunction(vtkImplicitFunction*);
00145   vtkGetObjectMacro(CutFunction,vtkImplicitFunction);
00147 
00149 
00152   vtkSetMacro(GenerateCutScalars,int);
00153   vtkGetMacro(GenerateCutScalars,int);
00154   vtkBooleanMacro(GenerateCutScalars,int);
00156 
00158 
00160   void SetLocator(vtkIncrementalPointLocator *locator);
00161   vtkGetObjectMacro(Locator,vtkIncrementalPointLocator);
00163 
00165 
00175   vtkSetClampMacro(SortBy,int,VTK_SORT_BY_VALUE,VTK_SORT_BY_CELL);
00176   vtkGetMacro(SortBy,int);
00177   void SetSortByToSortByValue() 
00178     {this->SetSortBy(VTK_SORT_BY_VALUE);}
00179   void SetSortByToSortByCell() 
00180     {this->SetSortBy(VTK_SORT_BY_CELL);}
00182   
00184 
00185   const char *GetSortByAsString()
00186     {
00187       if ( this->SortBy == VTK_SORT_BY_VALUE ) 
00188         {
00189         return "SortByValue";
00190         }
00191       else 
00192         {
00193         return "SortByCell";
00194         }
00195     }
00197 
00200   void CreateDefaultLocator();
00201 
00202 protected:
00203   vtkHyperOctreeCutter(vtkImplicitFunction *cf=NULL);
00204   ~vtkHyperOctreeCutter();
00205 
00206   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00207   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00208   virtual int FillInputPortInformation(int port, vtkInformation *info);
00209  
00211 
00213   void CutNode(vtkHyperOctreeCursor *cursor,
00214                int level,
00215                double bounds[6]);
00217   
00218   vtkImplicitFunction *CutFunction;
00219 
00220 
00221   vtkIncrementalPointLocator *Locator;
00222   int SortBy;
00223   vtkContourValues *ContourValues;
00224   int GenerateCutScalars;
00225   
00226   vtkHyperOctree *Input;
00227   vtkPolyData *Output;
00228   
00229  
00230   vtkCellArray *NewVerts;
00231   vtkCellArray *NewLines;
00232   vtkCellArray *NewPolys;
00233   
00234   vtkDataSetAttributes *InCD;
00235   vtkCellData *OutCD;
00236   vtkPointData *OutPD;
00237   vtkOrderedTriangulator *Triangulator;
00238   vtkHyperOctreeCursor *Sibling; // to avoid allocation in the loop
00239   
00240   int Iter; // iterate over contour values in case of VTK_SORT_BY_CELL
00241   
00242   
00243   vtkDoubleArray *CellScalars;
00244   vtkTetra *Tetra;
00245   vtkDoubleArray *TetScalars;
00246   
00247   vtkPoints *Pts;
00248   vtkPolygon *Polygon;
00249   
00250   vtkIdType CellTypeCounter[65536]; // up-to-65536 points per octant
00251   vtkIdType TotalCounter;
00252   vtkIdType TemplateCounter; // record the number of octants that succceed
00253   // to use the template triangulator
00254   
00255   // in VTK_SORT_BY_VALUE case, rejection test need to combine all values.
00256   int *AllLess;
00257   int *AllGreater;
00258   vtkHyperOctreeClipCutPointsGrabber *Grabber;
00259   
00260 private:
00261   vtkHyperOctreeCutter(const vtkHyperOctreeCutter&);  // Not implemented.
00262   void operator=(const vtkHyperOctreeCutter&);  // Not implemented.
00263 };
00264 
00265 #endif