Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

dox/Hybrid/vtkImageToPolyDataFilter.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkImageToPolyDataFilter.h,v $ 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 =========================================================================*/ 00066 #ifndef __vtkImageToPolyDataFilter_h 00067 #define __vtkImageToPolyDataFilter_h 00068 00069 #include "vtkStructuredPointsToPolyDataFilter.h" 00070 00071 #define VTK_STYLE_PIXELIZE 0 00072 #define VTK_STYLE_POLYGONALIZE 1 00073 #define VTK_STYLE_RUN_LENGTH 2 00074 00075 #define VTK_COLOR_MODE_LUT 0 00076 #define VTK_COLOR_MODE_LINEAR_256 1 00077 00078 class vtkAppendPolyData; 00079 class vtkDataArray; 00080 class vtkEdgeTable; 00081 class vtkIdTypeArray; 00082 class vtkIntArray; 00083 class vtkScalarsToColors; 00084 class vtkStructuredPoints; 00085 class vtkTimeStamp; 00086 class vtkUnsignedCharArray; 00087 00088 class VTK_HYBRID_EXPORT vtkImageToPolyDataFilter : public vtkStructuredPointsToPolyDataFilter 00089 { 00090 public: 00091 vtkTypeRevisionMacro(vtkImageToPolyDataFilter,vtkStructuredPointsToPolyDataFilter); 00092 void PrintSelf(ostream& os, vtkIndent indent); 00093 00095 static vtkImageToPolyDataFilter* New(); 00096 00098 00104 vtkSetClampMacro(OutputStyle,int,VTK_STYLE_PIXELIZE,VTK_STYLE_RUN_LENGTH); 00105 vtkGetMacro(OutputStyle,int); 00106 void SetOutputStyleToPixelize() 00107 {this->SetOutputStyle(VTK_STYLE_PIXELIZE);}; 00108 void SetOutputStyleToPolygonalize() 00109 {this->SetOutputStyle(VTK_STYLE_POLYGONALIZE);}; 00110 void SetOutputStyleToRunLength() 00111 {this->SetOutputStyle(VTK_STYLE_RUN_LENGTH);}; 00113 00115 00116 vtkSetClampMacro(ColorMode,int,VTK_COLOR_MODE_LUT,VTK_COLOR_MODE_LINEAR_256); 00117 vtkGetMacro(ColorMode,int); 00118 void SetColorModeToLUT() 00119 {this->SetColorMode(VTK_COLOR_MODE_LUT);}; 00120 void SetColorModeToLinear256() 00121 {this->SetColorMode(VTK_COLOR_MODE_LINEAR_256);}; 00123 00125 00127 virtual void SetLookupTable(vtkScalarsToColors*); 00128 vtkGetObjectMacro(LookupTable,vtkScalarsToColors); 00130 00132 00134 vtkSetMacro(Smoothing, int); 00135 vtkGetMacro(Smoothing, int); 00136 vtkBooleanMacro(Smoothing, int); 00138 00140 00142 vtkSetClampMacro(NumberOfSmoothingIterations,int,0,VTK_LARGE_INTEGER); 00143 vtkGetMacro(NumberOfSmoothingIterations,int); 00145 00147 00149 vtkSetMacro(Decimation, int); 00150 vtkGetMacro(Decimation, int); 00151 vtkBooleanMacro(Decimation, int); 00153 00155 00159 vtkSetClampMacro(DecimationError,double,0.0,VTK_DOUBLE_MAX); 00160 vtkGetMacro(DecimationError,double); 00162 00164 00167 vtkSetClampMacro(Error,int,0,VTK_LARGE_INTEGER); 00168 vtkGetMacro(Error,int); 00170 00172 00177 vtkSetClampMacro(SubImageSize,int,10,VTK_LARGE_INTEGER); 00178 vtkGetMacro(SubImageSize,int); 00180 00181 protected: 00182 vtkImageToPolyDataFilter(); 00183 ~vtkImageToPolyDataFilter(); 00184 00185 void Execute(); 00186 00187 int OutputStyle; 00188 int ColorMode; 00189 int Smoothing; 00190 int NumberOfSmoothingIterations; 00191 int Decimation; 00192 double DecimationError; 00193 int Error; 00194 int SubImageSize; 00195 vtkScalarsToColors *LookupTable; 00196 00197 virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3], 00198 double origin[3], double spacing[3], 00199 vtkPolyData *output); 00200 virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3], 00201 double origin[3], double spacing[3], 00202 vtkPolyData *output); 00203 virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3], 00204 double origin[3], double spacing[3], 00205 vtkPolyData *output); 00206 private: 00207 vtkUnsignedCharArray *Table; // color table used to quantize points 00208 vtkTimeStamp TableMTime; 00209 int *Visited; // traverse & mark connected regions 00210 vtkUnsignedCharArray *PolyColors; // the colors of each region -> polygon 00211 vtkEdgeTable *EdgeTable; // keep track of intersection points 00212 vtkEdgeTable *EdgeUseTable; // keep track of polygons use of edges 00213 vtkIntArray *EdgeUses; //the two polygons that use an edge 00214 //and point id associated with edge (if any) 00215 00216 vtkAppendPolyData *Append; 00217 00218 void BuildTable(unsigned char *inPixels); 00219 vtkUnsignedCharArray *QuantizeImage(vtkDataArray *inScalars, int numComp, 00220 int type, int dims[3], int ext[4]); 00221 int ProcessImage(vtkUnsignedCharArray *pixels, int dims[2]); 00222 int BuildEdges(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], 00223 double spacing[3], vtkUnsignedCharArray *pointDescr, 00224 vtkPolyData *edges); 00225 void BuildPolygons(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges, 00226 int numPolys, vtkUnsignedCharArray *polyColors); 00227 void SmoothEdges(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges); 00228 void DecimateEdges(vtkPolyData *edges, vtkUnsignedCharArray *pointDescr, 00229 double tol2); 00230 void GeneratePolygons(vtkPolyData *edges, int numPolys, vtkPolyData *output, 00231 vtkUnsignedCharArray *polyColors, 00232 vtkUnsignedCharArray *pointDescr); 00233 00234 int GetNeighbors(unsigned char *ptr, int &i, int &j, int dims[3], 00235 unsigned char *neighbors[4], int mode); 00236 00237 void GetIJ(int id, int &i, int &j, int dims[3]); 00238 unsigned char *GetColor(unsigned char *rgb); 00239 int IsSameColor(unsigned char *p1, unsigned char *p2); 00240 00241 private: 00242 vtkImageToPolyDataFilter(const vtkImageToPolyDataFilter&); // Not implemented. 00243 void operator=(const vtkImageToPolyDataFilter&); // Not implemented. 00244 }; 00245 00246 #endif 00247