VTK  9.2.6
vtkImageToPolyDataFilter.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImageToPolyDataFilter.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
64#ifndef vtkImageToPolyDataFilter_h
65#define vtkImageToPolyDataFilter_h
66
67#include "vtkFiltersHybridModule.h" // For export macro
69
70#define VTK_STYLE_PIXELIZE 0
71#define VTK_STYLE_POLYGONALIZE 1
72#define VTK_STYLE_RUN_LENGTH 2
73
74#define VTK_COLOR_MODE_LUT 0
75#define VTK_COLOR_MODE_LINEAR_256 1
76
77class vtkDataArray;
78class vtkEdgeTable;
79class vtkIdTypeArray;
80class vtkIntArray;
83class vtkTimeStamp;
85
86class VTKFILTERSHYBRID_EXPORT vtkImageToPolyDataFilter : public vtkPolyDataAlgorithm
87{
88public:
90 void PrintSelf(ostream& os, vtkIndent indent) override;
91
96
98
106 vtkSetClampMacro(OutputStyle, int, VTK_STYLE_PIXELIZE, VTK_STYLE_RUN_LENGTH);
107 vtkGetMacro(OutputStyle, int);
108 void SetOutputStyleToPixelize() { this->SetOutputStyle(VTK_STYLE_PIXELIZE); }
109 void SetOutputStyleToPolygonalize() { this->SetOutputStyle(VTK_STYLE_POLYGONALIZE); }
110 void SetOutputStyleToRunLength() { this->SetOutputStyle(VTK_STYLE_RUN_LENGTH); }
112
114
117 vtkSetClampMacro(ColorMode, int, VTK_COLOR_MODE_LUT, VTK_COLOR_MODE_LINEAR_256);
118 vtkGetMacro(ColorMode, int);
119 void SetColorModeToLUT() { this->SetColorMode(VTK_COLOR_MODE_LUT); }
122
124
129 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
131
133
137 vtkSetMacro(Smoothing, vtkTypeBool);
138 vtkGetMacro(Smoothing, vtkTypeBool);
139 vtkBooleanMacro(Smoothing, vtkTypeBool);
141
143
147 vtkSetClampMacro(NumberOfSmoothingIterations, int, 0, VTK_INT_MAX);
148 vtkGetMacro(NumberOfSmoothingIterations, int);
150
152
156 vtkSetMacro(Decimation, vtkTypeBool);
157 vtkGetMacro(Decimation, vtkTypeBool);
158 vtkBooleanMacro(Decimation, vtkTypeBool);
160
162
168 vtkSetClampMacro(DecimationError, double, 0.0, VTK_DOUBLE_MAX);
169 vtkGetMacro(DecimationError, double);
171
173
178 vtkSetClampMacro(Error, int, 0, VTK_INT_MAX);
179 vtkGetMacro(Error, int);
181
183
190 vtkSetClampMacro(SubImageSize, int, 10, VTK_INT_MAX);
191 vtkGetMacro(SubImageSize, int);
193
194protected:
197
199 int FillInputPortInformation(int port, vtkInformation* info) override;
200
207 int Error;
210
211 virtual void PixelizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
212 double spacing[3], vtkPolyData* output);
213 virtual void PolygonalizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
214 double spacing[3], vtkPolyData* output);
215 virtual void RunLengthImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
216 double spacing[3], vtkPolyData* output);
217
218private:
219 vtkUnsignedCharArray* Table; // color table used to quantize points
220 vtkTimeStamp TableMTime;
221 int* Visited; // traverse & mark connected regions
222 vtkUnsignedCharArray* PolyColors; // the colors of each region -> polygon
223 vtkEdgeTable* EdgeTable; // keep track of intersection points
224 vtkEdgeTable* EdgeUseTable; // keep track of polygons use of edges
225 vtkIntArray* EdgeUses; // the two polygons that use an edge
226 // and point id associated with edge (if any)
227
228 void BuildTable(unsigned char* inPixels);
229 vtkUnsignedCharArray* QuantizeImage(
230 vtkDataArray* inScalars, int numComp, int type, int dims[3], int ext[4]);
231 int ProcessImage(vtkUnsignedCharArray* pixels, int dims[2]);
232 int BuildEdges(vtkUnsignedCharArray* pixels, int dims[3], double origin[3], double spacing[3],
234 void BuildPolygons(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges, int numPolys,
235 vtkUnsignedCharArray* polyColors);
236 void SmoothEdges(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges);
237 void DecimateEdges(vtkPolyData* edges, vtkUnsignedCharArray* pointDescr, double tol2);
238 void GeneratePolygons(vtkPolyData* edges, int numPolys, vtkPolyData* output,
239 vtkUnsignedCharArray* polyColors, vtkUnsignedCharArray* pointDescr);
240
241 int GetNeighbors(
242 unsigned char* ptr, int& i, int& j, int dims[3], unsigned char* neighbors[4], int mode);
243
244 void GetIJ(int id, int& i, int& j, int dims[2]);
245 unsigned char* GetColor(unsigned char* rgb);
246 int IsSameColor(unsigned char* p1, unsigned char* p2);
247
248private:
250 void operator=(const vtkImageToPolyDataFilter&) = delete;
251};
252
253#endif
abstract superclass for arrays of numeric data
keep track of edges (edge is pair of integer id's)
dynamic, self-adjusting array of vtkIdType
generate linear primitives (vtkPolyData) from an image
virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
void SetColorModeToLinear256()
Specify how to quantize color.
static vtkImageToPolyDataFilter * New()
Instantiate object with initial number of colors 256.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetOutputStyleToPixelize()
Specify how to create the output.
void SetOutputStyleToPolygonalize()
Specify how to create the output.
void SetColorModeToLUT()
Specify how to quantize color.
virtual void SetLookupTable(vtkScalarsToColors *)
Set/Get the vtkLookupTable to use.
virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
~vtkImageToPolyDataFilter() override
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
void SetOutputStyleToRunLength()
Specify how to create the output.
a simple class to control print indentation
Definition vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition vtkIntArray.h:40
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:85
Superclass for mapping scalar values to colors.
A subclass of ImageData.
record modification and/or execution time
dynamic, self-adjusting array of unsigned char
int vtkTypeBool
Definition vtkABI.h:69
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
#define VTK_COLOR_MODE_LINEAR_256
#define VTK_COLOR_MODE_LUT
#define VTK_STYLE_POLYGONALIZE
#define VTK_STYLE_PIXELIZE
#define VTK_STYLE_RUN_LENGTH
#define VTK_DOUBLE_MAX
Definition vtkType.h:165
#define VTK_INT_MAX
Definition vtkType.h:155