VTK  9.1.0
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=========================================================================*/
73#ifndef vtkImageToPolyDataFilter_h
74#define vtkImageToPolyDataFilter_h
75
76#include "vtkFiltersHybridModule.h" // For export macro
78
79#define VTK_STYLE_PIXELIZE 0
80#define VTK_STYLE_POLYGONALIZE 1
81#define VTK_STYLE_RUN_LENGTH 2
82
83#define VTK_COLOR_MODE_LUT 0
84#define VTK_COLOR_MODE_LINEAR_256 1
85
86class vtkDataArray;
87class vtkEdgeTable;
88class vtkIdTypeArray;
89class vtkIntArray;
92class vtkTimeStamp;
94
95class VTKFILTERSHYBRID_EXPORT vtkImageToPolyDataFilter : public vtkPolyDataAlgorithm
96{
97public:
99 void PrintSelf(ostream& os, vtkIndent indent) override;
100
105
107
115 vtkSetClampMacro(OutputStyle, int, VTK_STYLE_PIXELIZE, VTK_STYLE_RUN_LENGTH);
116 vtkGetMacro(OutputStyle, int);
117 void SetOutputStyleToPixelize() { this->SetOutputStyle(VTK_STYLE_PIXELIZE); }
118 void SetOutputStyleToPolygonalize() { this->SetOutputStyle(VTK_STYLE_POLYGONALIZE); }
119 void SetOutputStyleToRunLength() { this->SetOutputStyle(VTK_STYLE_RUN_LENGTH); }
121
123
126 vtkSetClampMacro(ColorMode, int, VTK_COLOR_MODE_LUT, VTK_COLOR_MODE_LINEAR_256);
127 vtkGetMacro(ColorMode, int);
128 void SetColorModeToLUT() { this->SetColorMode(VTK_COLOR_MODE_LUT); }
131
133
138 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
140
142
146 vtkSetMacro(Smoothing, vtkTypeBool);
147 vtkGetMacro(Smoothing, vtkTypeBool);
148 vtkBooleanMacro(Smoothing, vtkTypeBool);
150
152
156 vtkSetClampMacro(NumberOfSmoothingIterations, int, 0, VTK_INT_MAX);
157 vtkGetMacro(NumberOfSmoothingIterations, int);
159
161
165 vtkSetMacro(Decimation, vtkTypeBool);
166 vtkGetMacro(Decimation, vtkTypeBool);
167 vtkBooleanMacro(Decimation, vtkTypeBool);
169
171
177 vtkSetClampMacro(DecimationError, double, 0.0, VTK_DOUBLE_MAX);
178 vtkGetMacro(DecimationError, double);
180
182
187 vtkSetClampMacro(Error, int, 0, VTK_INT_MAX);
188 vtkGetMacro(Error, int);
190
192
199 vtkSetClampMacro(SubImageSize, int, 10, VTK_INT_MAX);
200 vtkGetMacro(SubImageSize, int);
202
203protected:
206
209
216 int Error;
219
220 virtual void PixelizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
221 double spacing[3], vtkPolyData* output);
222 virtual void PolygonalizeImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
223 double spacing[3], vtkPolyData* output);
224 virtual void RunLengthImage(vtkUnsignedCharArray* pixels, int dims[3], double origin[3],
225 double spacing[3], vtkPolyData* output);
226
227private:
228 vtkUnsignedCharArray* Table; // color table used to quantize points
229 vtkTimeStamp TableMTime;
230 int* Visited; // traverse & mark connected regions
231 vtkUnsignedCharArray* PolyColors; // the colors of each region -> polygon
232 vtkEdgeTable* EdgeTable; // keep track of intersection points
233 vtkEdgeTable* EdgeUseTable; // keep track of polygons use of edges
234 vtkIntArray* EdgeUses; // the two polygons that use an edge
235 // and point id associated with edge (if any)
236
237 void BuildTable(unsigned char* inPixels);
238 vtkUnsignedCharArray* QuantizeImage(
239 vtkDataArray* inScalars, int numComp, int type, int dims[3], int ext[4]);
240 int ProcessImage(vtkUnsignedCharArray* pixels, int dims[2]);
241 int BuildEdges(vtkUnsignedCharArray* pixels, int dims[3], double origin[3], double spacing[3],
243 void BuildPolygons(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges, int numPolys,
244 vtkUnsignedCharArray* polyColors);
245 void SmoothEdges(vtkUnsignedCharArray* pointDescr, vtkPolyData* edges);
246 void DecimateEdges(vtkPolyData* edges, vtkUnsignedCharArray* pointDescr, double tol2);
247 void GeneratePolygons(vtkPolyData* edges, int numPolys, vtkPolyData* output,
248 vtkUnsignedCharArray* polyColors, vtkUnsignedCharArray* pointDescr);
249
250 int GetNeighbors(
251 unsigned char* ptr, int& i, int& j, int dims[3], unsigned char* neighbors[4], int mode);
252
253 void GetIJ(int id, int& i, int& j, int dims[2]);
254 unsigned char* GetColor(unsigned char* rgb);
255 int IsSameColor(unsigned char* p1, unsigned char* p2);
256
257private:
259 void operator=(const vtkImageToPolyDataFilter&) = delete;
260};
261
262#endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:59
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
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:43
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:49
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
Superclass for mapping scalar values to colors.
A subclass of ImageData.
record modification and/or execution time
Definition: vtkTimeStamp.h:42
dynamic, self-adjusting array of unsigned char
@ info
Definition: vtkX3D.h:382
@ mode
Definition: vtkX3D.h:253
@ port
Definition: vtkX3D.h:453
@ type
Definition: vtkX3D.h:522
@ spacing
Definition: vtkX3D.h:487
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