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 Language: C++ 00006 00007 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 00008 All rights reserved. 00009 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00010 00011 This software is distributed WITHOUT ANY WARRANTY; without even 00012 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 PURPOSE. See the above copyright notice for more information. 00014 00015 =========================================================================*/ 00070 #ifndef __vtkImageToPolyDataFilter_h 00071 #define __vtkImageToPolyDataFilter_h 00072 00073 #include "vtkStructuredPointsToPolyDataFilter.h" 00074 00075 #define VTK_STYLE_PIXELIZE 0 00076 #define VTK_STYLE_POLYGONALIZE 1 00077 #define VTK_STYLE_RUN_LENGTH 2 00078 00079 #define VTK_COLOR_MODE_LUT 0 00080 #define VTK_COLOR_MODE_LINEAR_256 1 00081 00082 class vtkAppendPolyData; 00083 class vtkDataArray; 00084 class vtkEdgeTable; 00085 class vtkIdTypeArray; 00086 class vtkIntArray; 00087 class vtkScalarsToColors; 00088 class vtkStructuredPoints; 00089 class vtkTimeStamp; 00090 class vtkUnsignedCharArray; 00091 00092 class VTK_HYBRID_EXPORT vtkImageToPolyDataFilter : public vtkStructuredPointsToPolyDataFilter 00093 { 00094 public: 00095 vtkTypeRevisionMacro(vtkImageToPolyDataFilter,vtkStructuredPointsToPolyDataFilter); 00096 void PrintSelf(ostream& os, vtkIndent indent); 00097 00099 static vtkImageToPolyDataFilter* New(); 00100 00102 00108 vtkSetClampMacro(OutputStyle,int,VTK_STYLE_PIXELIZE,VTK_STYLE_RUN_LENGTH); 00109 vtkGetMacro(OutputStyle,int); 00110 void SetOutputStyleToPixelize() 00111 {this->SetOutputStyle(VTK_STYLE_PIXELIZE);}; 00112 void SetOutputStyleToPolygonalize() 00113 {this->SetOutputStyle(VTK_STYLE_POLYGONALIZE);}; 00114 void SetOutputStyleToRunLength() 00115 {this->SetOutputStyle(VTK_STYLE_RUN_LENGTH);}; 00117 00119 00120 vtkSetClampMacro(ColorMode,int,VTK_COLOR_MODE_LUT,VTK_COLOR_MODE_LINEAR_256); 00121 vtkGetMacro(ColorMode,int); 00122 void SetColorModeToLUT() 00123 {this->SetColorMode(VTK_COLOR_MODE_LUT);}; 00124 void SetColorModeToLinear256() 00125 {this->SetColorMode(VTK_COLOR_MODE_LINEAR_256);}; 00127 00129 00131 virtual void SetLookupTable(vtkScalarsToColors*); 00132 vtkGetObjectMacro(LookupTable,vtkScalarsToColors); 00134 00136 00138 vtkSetMacro(Smoothing, int); 00139 vtkGetMacro(Smoothing, int); 00140 vtkBooleanMacro(Smoothing, int); 00142 00144 00146 vtkSetClampMacro(NumberOfSmoothingIterations,int,0,VTK_LARGE_INTEGER); 00147 vtkGetMacro(NumberOfSmoothingIterations,int); 00149 00151 00153 vtkSetMacro(Decimation, int); 00154 vtkGetMacro(Decimation, int); 00155 vtkBooleanMacro(Decimation, int); 00157 00159 00160 vtkSetClampMacro(DecimationError,float,0.0,VTK_LARGE_FLOAT); 00161 vtkGetMacro(DecimationError,float); 00163 00165 00168 vtkSetClampMacro(Error,int,0,VTK_LARGE_INTEGER); 00169 vtkGetMacro(Error,int); 00171 00173 00178 vtkSetClampMacro(SubImageSize,int,10,VTK_LARGE_INTEGER); 00179 vtkGetMacro(SubImageSize,int); 00181 00182 protected: 00183 vtkImageToPolyDataFilter(); 00184 ~vtkImageToPolyDataFilter(); 00185 00186 void Execute(); 00187 00188 int OutputStyle; 00189 int ColorMode; 00190 int Smoothing; 00191 int NumberOfSmoothingIterations; 00192 int Decimation; 00193 float DecimationError; 00194 int Error; 00195 int SubImageSize; 00196 vtkScalarsToColors *LookupTable; 00197 00198 virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3], 00199 float origin[3], float spacing[3], 00200 vtkPolyData *output); 00201 virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3], 00202 float origin[3], float spacing[3], 00203 vtkPolyData *output); 00204 virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3], 00205 float origin[3], float spacing[3], 00206 vtkPolyData *output); 00207 private: 00208 vtkUnsignedCharArray *Table; // color table used to quantize points 00209 vtkTimeStamp TableMTime; 00210 int *Visited; // traverse & mark connected regions 00211 vtkUnsignedCharArray *PolyColors; // the colors of each region -> polygon 00212 vtkEdgeTable *EdgeTable; // keep track of intersection points 00213 vtkEdgeTable *EdgeUseTable; // keep track of polygons use of edges 00214 vtkIntArray *EdgeUses; //the two polygons that use an edge 00215 //and point id associated with edge (if any) 00216 00217 vtkAppendPolyData *Append; 00218 00219 void BuildTable(unsigned char *inPixels); 00220 vtkUnsignedCharArray *QuantizeImage(vtkDataArray *inScalars, int numComp, 00221 int type, int dims[3], int ext[4]); 00222 int ProcessImage(vtkUnsignedCharArray *pixels, int dims[2]); 00223 int BuildEdges(vtkUnsignedCharArray *pixels, int dims[3], float origin[3], 00224 float spacing[3], vtkUnsignedCharArray *pointDescr, 00225 vtkPolyData *edges); 00226 void BuildPolygons(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges, 00227 int numPolys, vtkUnsignedCharArray *polyColors); 00228 void SmoothEdges(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges); 00229 void DecimateEdges(vtkPolyData *edges, vtkUnsignedCharArray *pointDescr, 00230 float tol2); 00231 void GeneratePolygons(vtkPolyData *edges, int numPolys, vtkPolyData *output, 00232 vtkUnsignedCharArray *polyColors, 00233 vtkUnsignedCharArray *pointDescr); 00234 00235 int GetNeighbors(unsigned char *ptr, int &i, int &j, int dims[3], 00236 unsigned char *neighbors[4], int mode); 00237 00238 void GetIJ(int id, int &i, int &j, int dims[3]); 00239 unsigned char *GetColor(unsigned char *rgb); 00240 int IsSameColor(unsigned char *p1, unsigned char *p2); 00241 00242 private: 00243 vtkImageToPolyDataFilter(const vtkImageToPolyDataFilter&); // Not implemented. 00244 void operator=(const vtkImageToPolyDataFilter&); // Not implemented. 00245 }; 00246 00247 #endif 00248