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=========================================================================*/
67#ifndef vtkImageToPolyDataFilter_h
68#define vtkImageToPolyDataFilter_h
69
70#include "vtkFiltersHybridModule.h" // For export macro
72
73#define VTK_STYLE_PIXELIZE 0
74#define VTK_STYLE_POLYGONALIZE 1
75#define VTK_STYLE_RUN_LENGTH 2
76
77#define VTK_COLOR_MODE_LUT 0
78#define VTK_COLOR_MODE_LINEAR_256 1
79
80class vtkDataArray;
81class vtkEdgeTable;
82class vtkIdTypeArray;
83class vtkIntArray;
86class vtkTimeStamp;
88
89class VTKFILTERSHYBRID_EXPORT vtkImageToPolyDataFilter : public vtkPolyDataAlgorithm
90{
91public:
93 void PrintSelf(ostream& os, vtkIndent indent) override;
94
99
101
109 vtkSetClampMacro(OutputStyle, int, VTK_STYLE_PIXELIZE, VTK_STYLE_RUN_LENGTH);
110 vtkGetMacro(OutputStyle, int);
111 void SetOutputStyleToPixelize() { this->SetOutputStyle(VTK_STYLE_PIXELIZE); }
112 void SetOutputStyleToPolygonalize() { this->SetOutputStyle(VTK_STYLE_POLYGONALIZE); }
113 void SetOutputStyleToRunLength() { this->SetOutputStyle(VTK_STYLE_RUN_LENGTH); }
115
117
120 vtkSetClampMacro(ColorMode, int, VTK_COLOR_MODE_LUT, VTK_COLOR_MODE_LINEAR_256);
121 vtkGetMacro(ColorMode, int);
122 void SetColorModeToLUT() { this->SetColorMode(VTK_COLOR_MODE_LUT); }
125
127
132 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
134
136
140 vtkSetMacro(Smoothing, vtkTypeBool);
141 vtkGetMacro(Smoothing, vtkTypeBool);
142 vtkBooleanMacro(Smoothing, vtkTypeBool);
144
146
150 vtkSetClampMacro(NumberOfSmoothingIterations, int, 0, VTK_INT_MAX);
151 vtkGetMacro(NumberOfSmoothingIterations, int);
153
155
159 vtkSetMacro(Decimation, vtkTypeBool);
160 vtkGetMacro(Decimation, vtkTypeBool);
161 vtkBooleanMacro(Decimation, vtkTypeBool);
163
165
171 vtkSetClampMacro(DecimationError, double, 0.0, VTK_DOUBLE_MAX);
172 vtkGetMacro(DecimationError, double);
174
176
181 vtkSetClampMacro(Error, int, 0, VTK_INT_MAX);
182 vtkGetMacro(Error, int);
184
186
193 vtkSetClampMacro(SubImageSize, int, 10, VTK_INT_MAX);
194 vtkGetMacro(SubImageSize, int);
196
197protected:
200
202 int FillInputPortInformation(int port, vtkInformation* info) override;
203
210 int Error;
213
214 virtual void PixelizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
215 double spacing[3], vtkPolyData* output);
216 virtual void PolygonalizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
217 double spacing[3], vtkPolyData* output);
218 virtual void RunLengthImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
219 double spacing[3], vtkPolyData* output);
220
221private:
222 vtkUnsignedCharArray* Table; // color table used to quantize points
223 vtkTimeStamp TableMTime;
224 int* Visited; // traverse & mark connected regions
225 vtkUnsignedCharArray* PolyColors; // the colors of each region -> polygon
226 vtkEdgeTable* EdgeTable; // keep track of intersection points
227 vtkEdgeTable* EdgeUseTable; // keep track of polygons use of edges
228 vtkIntArray* EdgeUses; // the two polygons that use an edge
229 // and point id associated with edge (if any)
230
231 void BuildTable(unsigned char* inPixels);
232 vtkUnsignedCharArray* QuantizeImage(
233 vtkDataArray* inScalars, int numComp, int type, int dims[3], int ext[4]);
234 int ProcessImage(vtkUnsignedCharArray* pixels, int dims[2]);
235 int BuildEdges(vtkUnsignedCharArray* pixels, int dims[3], double origin[3], double spacing[3],
237 void BuildPolygons(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges, int numPolys,
238 vtkUnsignedCharArray* polyColors);
239 void SmoothEdges(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges);
240 void DecimateEdges(vtkPolyData* edges, vtkUnsignedCharArray* pointDescr, double tol2);
241 void GeneratePolygons(vtkPolyData* edges, int numPolys, vtkPolyData* output,
242 vtkUnsignedCharArray* polyColors, vtkUnsignedCharArray* pointDescr);
243
244 int GetNeighbors(
245 unsigned char* ptr, int& i, int& j, int dims[3], unsigned char* neighbors[4], int mode);
246
247 void GetIJ(int id, int& i, int& j, int dims[2]);
248 unsigned char* GetColor(unsigned char* rgb);
249 int IsSameColor(unsigned char* p1, unsigned char* p2);
250
251private:
253 void operator=(const vtkImageToPolyDataFilter&) = delete;
254};
255
256#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:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition vtkIntArray.h:46
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:91
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