VTK
dox/Graphics/vtkImageMarchingCubes.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkImageMarchingCubes.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 =========================================================================*/
00041 #ifndef __vtkImageMarchingCubes_h
00042 #define __vtkImageMarchingCubes_h
00043 
00044 #include "vtkPolyDataAlgorithm.h"
00045 
00046 #include "vtkContourValues.h" // Needed for direct access to ContourValues
00047 
00048 class vtkCellArray;
00049 class vtkFloatArray;
00050 class vtkImageData;
00051 class vtkPoints;
00052 
00053 class VTK_GRAPHICS_EXPORT vtkImageMarchingCubes : public vtkPolyDataAlgorithm
00054 {
00055 public:
00056   static vtkImageMarchingCubes *New();
00057   vtkTypeMacro(vtkImageMarchingCubes,vtkPolyDataAlgorithm);
00058   void PrintSelf(ostream& os, vtkIndent indent);
00059   
00061 
00062   void SetValue(int i, double value);
00063   double GetValue(int i);
00064   double *GetValues();
00065   void GetValues(double *contourValues);
00066   void SetNumberOfContours(int number);
00067   int GetNumberOfContours();
00068   void GenerateValues(int numContours, double range[2]);
00069   void GenerateValues(int numContours, double rangeStart, double rangeEnd);
00071 
00074   unsigned long int GetMTime();
00075 
00077 
00078   vtkSetMacro(ComputeScalars, int);
00079   vtkGetMacro(ComputeScalars, int);
00080   vtkBooleanMacro(ComputeScalars, int);
00082   
00084 
00088   vtkSetMacro(ComputeNormals, int);
00089   vtkGetMacro(ComputeNormals, int);
00090   vtkBooleanMacro(ComputeNormals, int);
00092   
00094 
00100   vtkSetMacro(ComputeGradients, int);
00101   vtkGetMacro(ComputeGradients, int);
00102   vtkBooleanMacro(ComputeGradients, int);
00104   
00105   // Should be protected, but the templated functions need these
00106   int ComputeScalars;
00107   int ComputeNormals;
00108   int ComputeGradients;
00109   int NeedGradients;
00110 
00111   vtkCellArray *Triangles;
00112   vtkFloatArray *Scalars;
00113   vtkPoints *Points;
00114   vtkFloatArray *Normals;
00115   vtkFloatArray *Gradients;
00116   
00117   int GetLocatorPoint(int cellX, int cellY, int edge);
00118   void AddLocatorPoint(int cellX, int cellY, int edge, int ptId);
00119   void IncrementLocatorZ();
00120 
00122 
00125   vtkSetMacro(InputMemoryLimit, int);
00126   vtkGetMacro(InputMemoryLimit, int);
00128 
00129 protected:
00130   vtkImageMarchingCubes();
00131   ~vtkImageMarchingCubes();
00132 
00133   int NumberOfSlicesPerChunk;
00134   int InputMemoryLimit;
00135 
00136   vtkContourValues *ContourValues;
00137    
00138   int *LocatorPointIds;
00139   int LocatorDimX;
00140   int LocatorDimY;
00141   int LocatorMinX;
00142   int LocatorMinY;
00143   
00144   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00145   virtual int FillInputPortInformation(int port, vtkInformation *info);
00146 
00147   void March(vtkImageData *inData, int chunkMin, int chunkMax,
00148              int numContours, double *values);
00149   void InitializeLocator(int min0, int max0, int min1, int max1);
00150   void DeleteLocator();
00151   int *GetLocatorPointer(int cellX, int cellY, int edge);
00152 
00153 private:
00154   vtkImageMarchingCubes(const vtkImageMarchingCubes&);  // Not implemented.
00155   void operator=(const vtkImageMarchingCubes&);  // Not implemented.
00156 };
00157 
00159 
00161 inline void vtkImageMarchingCubes::SetValue(int i, double value)
00162 {this->ContourValues->SetValue(i,value);}
00164 
00166 
00167 inline double vtkImageMarchingCubes::GetValue(int i)
00168 {return this->ContourValues->GetValue(i);}
00170 
00172 
00174 inline double *vtkImageMarchingCubes::GetValues()
00175 {return this->ContourValues->GetValues();}
00177 
00179 
00182 inline void vtkImageMarchingCubes::GetValues(double *contourValues)
00183 {this->ContourValues->GetValues(contourValues);}
00185 
00187 
00190 inline void vtkImageMarchingCubes::SetNumberOfContours(int number)
00191 {this->ContourValues->SetNumberOfContours(number);}
00193 
00195 
00196 inline int vtkImageMarchingCubes::GetNumberOfContours()
00197 {return this->ContourValues->GetNumberOfContours();}
00199 
00201 
00203 inline void vtkImageMarchingCubes::GenerateValues(int numContours, double range[2])
00204 {this->ContourValues->GenerateValues(numContours, range);}
00206 
00208 
00210 inline void vtkImageMarchingCubes::GenerateValues(int numContours, double
00211                                                  rangeStart, double rangeEnd)
00212 {this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}
00214 
00215 #endif