Hybrid/vtkImageToPolyDataFilter.h Source File

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

# 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 =========================================================================*/
    00080 #ifndef __vtkImageToPolyDataFilter_h
    00081 #define __vtkImageToPolyDataFilter_h
    00082
    00083 #include "vtkStructuredPointsToPolyDataFilter.h"
    00084
    00085 #define VTK_STYLE_PIXELIZE 0
    00086 #define VTK_STYLE_POLYGONALIZE 1
    00087 #define VTK_STYLE_RUN_LENGTH 2
    00088
    00089 #define VTK_COLOR_MODE_LUT 0
    00090 #define VTK_COLOR_MODE_LINEAR_256 1
    00091
    00092 class vtkAppendPolyData;
    00093 class vtkDataArray;
    00094 class vtkEdgeTable;
    00095 class vtkIdTypeArray;
    00096 class vtkIntArray;
    00097 class vtkScalarsToColors;
    00098 class vtkStructuredPoints;
    00099 class vtkTimeStamp;
    00100 class vtkUnsignedCharArray;
    00101
    00102 class VTK_HYBRID_EXPORT vtkImageToPolyDataFilter : public vtkStructuredPointsToPolyDataFilter
    00103 {
    00104 public:
    00105   vtkTypeRevisionMacro(vtkImageToPolyDataFilter,vtkStructuredPointsToPolyDataFilter);
    00106   void PrintSelf(ostream& os, vtkIndent indent);
    00107
    00109   static vtkImageToPolyDataFilter* New();
    00110
    00112
    00118   vtkSetClampMacro(OutputStyle,int,VTK_STYLE_PIXELIZE,VTK_STYLE_RUN_LENGTH);
    00119   vtkGetMacro(OutputStyle,int);
    00120   void SetOutputStyleToPixelize()
    00121     {this->SetOutputStyle(VTK_STYLE_PIXELIZE);};
    00122   void SetOutputStyleToPolygonalize()
    00123     {this->SetOutputStyle(VTK_STYLE_POLYGONALIZE);};
    00124   void SetOutputStyleToRunLength()
    00125     {this->SetOutputStyle(VTK_STYLE_RUN_LENGTH);};
    00127
    00129
    00130   vtkSetClampMacro(ColorMode,int,VTK_COLOR_MODE_LUT,VTK_COLOR_MODE_LINEAR_256);
    00131   vtkGetMacro(ColorMode,int);
    00132   void SetColorModeToLUT()
    00133     {this->SetColorMode(VTK_COLOR_MODE_LUT);};
    00134   void SetColorModeToLinear256()
    00135     {this->SetColorMode(VTK_COLOR_MODE_LINEAR_256);};
    00137
    00139
    00141   virtual void SetLookupTable(vtkScalarsToColors*);
    00142   vtkGetObjectMacro(LookupTable,vtkScalarsToColors);
    00144
    00146
    00148   vtkSetMacro(Smoothing, int);
    00149   vtkGetMacro(Smoothing, int);
    00150   vtkBooleanMacro(Smoothing, int);
    00152
    00154
    00156   vtkSetClampMacro(NumberOfSmoothingIterations,int,0,VTK_LARGE_INTEGER);
    00157   vtkGetMacro(NumberOfSmoothingIterations,int);
    00159
    00161
    00163   vtkSetMacro(Decimation, int);
    00164   vtkGetMacro(Decimation, int);
    00165   vtkBooleanMacro(Decimation, int);
    00167
    00169
    00170   vtkSetClampMacro(DecimationError,float,0.0,VTK_LARGE_FLOAT);
    00171   vtkGetMacro(DecimationError,float);
    00173
    00175
    00178   vtkSetClampMacro(Error,int,0,VTK_LARGE_INTEGER);
    00179   vtkGetMacro(Error,int);
    00181
    00183
    00188   vtkSetClampMacro(SubImageSize,int,10,VTK_LARGE_INTEGER);
    00189   vtkGetMacro(SubImageSize,int);
    00191
    00192 protected:
    00193   vtkImageToPolyDataFilter();
    00194   ~vtkImageToPolyDataFilter();
    00195
    00196   void Execute();
    00197
    00198   int OutputStyle;
    00199   int ColorMode;
    00200   int Smoothing;
    00201   int NumberOfSmoothingIterations;
    00202   int Decimation;
    00203   float DecimationError;
    00204   int Error;
    00205   int SubImageSize;
    00206   vtkScalarsToColors *LookupTable;
    00207
    00208   virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3],
    00209                              float origin[3], float spacing[3],
    00210                              vtkPolyData *output);
    00211   virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3],
    00212                                  float origin[3], float spacing[3],
    00213                                  vtkPolyData *output);
    00214   virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3],
    00215                               float origin[3], float spacing[3],
    00216                               vtkPolyData *output);
    00217 private:
    00218   vtkUnsignedCharArray *Table;      // color table used to quantize points
    00219   vtkTimeStamp         TableMTime;
    00220   int                  *Visited;    // traverse & mark connected regions
    00221   vtkUnsignedCharArray *PolyColors; // the colors of each region -> polygon
    00222   vtkEdgeTable         *EdgeTable;  // keep track of intersection points
    00223   vtkEdgeTable         *EdgeUseTable; // keep track of polygons use of edges
    00224   vtkIntArray          *EdgeUses; //the two polygons that use an edge
    00225                                   //and point id associated with edge (if any)
    00226
    00227   vtkAppendPolyData    *Append;
    00228
    00229   void BuildTable(unsigned char *inPixels);
    00230   vtkUnsignedCharArray *QuantizeImage(vtkDataArray *inScalars, int numComp,
    00231                                           int type, int dims[3], int ext[4]);
    00232   int ProcessImage(vtkUnsignedCharArray *pixels, int dims[2]);
    00233   int BuildEdges(vtkUnsignedCharArray *pixels, int dims[3], float origin[3],
    00234                  float spacing[3], vtkUnsignedCharArray *pointDescr,
    00235                  vtkPolyData *edges);
    00236   void BuildPolygons(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges,
    00237                      int numPolys, vtkUnsignedCharArray *polyColors);
    00238   void SmoothEdges(vtkUnsignedCharArray *pointDescr, vtkPolyData *edges);
    00239   void DecimateEdges(vtkPolyData *edges, vtkUnsignedCharArray *pointDescr,
    00240                      float tol2);
    00241   void GeneratePolygons(vtkPolyData *edges, int numPolys, vtkPolyData *output,
    00242                         vtkUnsignedCharArray *polyColors,
    00243                         vtkUnsignedCharArray *pointDescr);
    00244
    00245   int GetNeighbors(unsigned char *ptr, int &i, int &j, int dims[3],
    00246                    unsigned char *neighbors[4], int mode);
    00247
    00248   void GetIJ(int id, int &i, int &j, int dims[3]);
    00249   unsigned char *GetColor(unsigned char *rgb);
    00250   int IsSameColor(unsigned char *p1, unsigned char *p2);
    00251
    00252 private:
    00253   vtkImageToPolyDataFilter(const vtkImageToPolyDataFilter&);  // Not implemented.
    00254   void operator=(const vtkImageToPolyDataFilter&);  // Not implemented.
    00255 };
    00256
    00257 #endif
    00258