VTK  9.3.0
vtkImageToPolyDataFilter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
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
77VTK_ABI_NAMESPACE_BEGIN
78class vtkDataArray;
79class vtkEdgeTable;
80class vtkIdTypeArray;
81class vtkIntArray;
84class vtkTimeStamp;
86
87class VTKFILTERSHYBRID_EXPORT vtkImageToPolyDataFilter : public vtkPolyDataAlgorithm
88{
89public:
91 void PrintSelf(ostream& os, vtkIndent indent) override;
92
97
99
107 vtkSetClampMacro(OutputStyle, int, VTK_STYLE_PIXELIZE, VTK_STYLE_RUN_LENGTH);
108 vtkGetMacro(OutputStyle, int);
109 void SetOutputStyleToPixelize() { this->SetOutputStyle(VTK_STYLE_PIXELIZE); }
110 void SetOutputStyleToPolygonalize() { this->SetOutputStyle(VTK_STYLE_POLYGONALIZE); }
111 void SetOutputStyleToRunLength() { this->SetOutputStyle(VTK_STYLE_RUN_LENGTH); }
113
115
118 vtkSetClampMacro(ColorMode, int, VTK_COLOR_MODE_LUT, VTK_COLOR_MODE_LINEAR_256);
119 vtkGetMacro(ColorMode, int);
120 void SetColorModeToLUT() { this->SetColorMode(VTK_COLOR_MODE_LUT); }
123
125
130 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
132
134
138 vtkSetMacro(Smoothing, vtkTypeBool);
139 vtkGetMacro(Smoothing, vtkTypeBool);
140 vtkBooleanMacro(Smoothing, vtkTypeBool);
142
144
148 vtkSetClampMacro(NumberOfSmoothingIterations, int, 0, VTK_INT_MAX);
149 vtkGetMacro(NumberOfSmoothingIterations, int);
151
153
157 vtkSetMacro(Decimation, vtkTypeBool);
158 vtkGetMacro(Decimation, vtkTypeBool);
159 vtkBooleanMacro(Decimation, vtkTypeBool);
161
163
169 vtkSetClampMacro(DecimationError, double, 0.0, VTK_DOUBLE_MAX);
170 vtkGetMacro(DecimationError, double);
172
174
179 vtkSetClampMacro(Error, int, 0, VTK_INT_MAX);
180 vtkGetMacro(Error, int);
182
184
191 vtkSetClampMacro(SubImageSize, int, 10, VTK_INT_MAX);
192 vtkGetMacro(SubImageSize, int);
194
195protected:
198
200 int FillInputPortInformation(int port, vtkInformation* info) override;
201
208 int Error;
211
212 virtual void PixelizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
213 double spacing[3], vtkPolyData* output);
214 virtual void PolygonalizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
215 double spacing[3], vtkPolyData* output);
216 virtual void RunLengthImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
217 double spacing[3], vtkPolyData* output);
218
219private:
220 vtkUnsignedCharArray* Table; // color table used to quantize points
221 vtkTimeStamp TableMTime;
222 int* Visited; // traverse & mark connected regions
223 vtkUnsignedCharArray* PolyColors; // the colors of each region -> polygon
224 vtkEdgeTable* EdgeTable; // keep track of intersection points
225 vtkEdgeTable* EdgeUseTable; // keep track of polygons use of edges
226 vtkIntArray* EdgeUses; // the two polygons that use an edge
227 // and point id associated with edge (if any)
228
229 void BuildTable(unsigned char* inPixels);
230 vtkUnsignedCharArray* QuantizeImage(
231 vtkDataArray* inScalars, int numComp, int type, int dims[3], int ext[4]);
232 int ProcessImage(vtkUnsignedCharArray* pixels, int dims[2]);
233 int BuildEdges(vtkUnsignedCharArray* pixels, int dims[3], double origin[3], double spacing[3],
235 void BuildPolygons(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges, int numPolys,
236 vtkUnsignedCharArray* polyColors);
237 void SmoothEdges(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges);
238 void DecimateEdges(vtkPolyData* edges, vtkUnsignedCharArray* pointDescr, double tol2);
239 void GeneratePolygons(vtkPolyData* edges, int numPolys, vtkPolyData* output,
240 vtkUnsignedCharArray* polyColors, vtkUnsignedCharArray* pointDescr);
241
242 int GetNeighbors(
243 unsigned char* ptr, int& i, int& j, int dims[2], unsigned char* neighbors[4], int mode);
244
245 void GetIJ(int id, int& i, int& j, int dims[2]);
246 unsigned char* GetColor(unsigned char* rgb);
247 int IsSameColor(unsigned char* p1, unsigned char* p2);
248
250 void operator=(const vtkImageToPolyDataFilter&) = delete;
251};
252
253VTK_ABI_NAMESPACE_END
254#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:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition vtkIntArray.h:44
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:89
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:64
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:154
#define VTK_INT_MAX
Definition vtkType.h:144