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

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 "vtkPolyDataAlgorithm.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 vtkPolyDataAlgorithm
00089 {
00090 public:
00091   vtkTypeRevisionMacro(vtkImageToPolyDataFilter,vtkPolyDataAlgorithm);
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   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00186   virtual int FillInputPortInformation(int port, vtkInformation *info);
00187 
00188   int OutputStyle;
00189   int ColorMode;
00190   int Smoothing;
00191   int NumberOfSmoothingIterations;
00192   int Decimation;
00193   double DecimationError;
00194   int Error;
00195   int SubImageSize;
00196   vtkScalarsToColors *LookupTable;
00197 
00198   virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3], 
00199                              double origin[3], double spacing[3], 
00200                              vtkPolyData *output);
00201   virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3], 
00202                                  double origin[3], double spacing[3], 
00203                                  vtkPolyData *output);
00204   virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3], 
00205                               double origin[3], double 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], double origin[3],
00224                  double 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                      double 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

Generated on Mon Jan 21 23:07:27 2008 for VTK by  doxygen 1.4.3-20050530