VTK: Filters/Hybrid/vtkImageToPolyDataFilter.h Source File

| VTK 9.3.1

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
68 #include "vtkPolyDataAlgorithm.h"
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
77 VTK_ABI_NAMESPACE_BEGIN
78 class vtkDataArray;
79 class vtkEdgeTable;
80 class vtkIdTypeArray;
81 class vtkIntArray;
82 class vtkScalarsToColors;
83 class vtkStructuredPoints;
84 class vtkTimeStamp;
85 class vtkUnsignedCharArray;
86
87 class VTKFILTERSHYBRID_EXPORT vtkImageToPolyDataFilter : public vtkPolyDataAlgorithm
88 {
89 public:
90 vtkTypeMacro(vtkImageToPolyDataFilter, vtkPolyDataAlgorithm);
91 void PrintSelf(ostream& os, vtkIndent indent) override;
92
96 static vtkImageToPolyDataFilter* New();
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); }
121 void SetColorModeToLinear256() { this->SetColorMode(VTK_COLOR_MODE_LINEAR_256); }
123
125
129 virtual void SetLookupTable(vtkScalarsToColors*);
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
195 protected:
196 vtkImageToPolyDataFilter();
197 ~vtkImageToPolyDataFilter() override;
198
199 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
200 int FillInputPortInformation(int port, vtkInformation* info) override;
201
202 int OutputStyle;
203 int ColorMode;
204 vtkTypeBool Smoothing;
205 int NumberOfSmoothingIterations;
206 vtkTypeBool Decimation;
207 double DecimationError;
208 int Error;
209 int SubImageSize;
210 vtkScalarsToColors* LookupTable;
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
219 private:
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],
234 vtkUnsignedCharArray* pointDescr, vtkPolyData* edges);
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
249 vtkImageToPolyDataFilter(const vtkImageToPolyDataFilter&) = delete;
250 void operator=(const vtkImageToPolyDataFilter&) = delete;
251 };
252
253 VTK_ABI_NAMESPACE_END
254 #endif
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkEdgeTable
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:30
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:37
vtkImageToPolyDataFilter
generate linear primitives (vtkPolyData) from an image
Definition: vtkImageToPolyDataFilter.h:88
vtkImageToPolyDataFilter::RunLengthImage
virtual void RunLengthImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
vtkImageToPolyDataFilter::SetColorModeToLinear256
void SetColorModeToLinear256()
Specify how to quantize color.
Definition: vtkImageToPolyDataFilter.h:121
vtkImageToPolyDataFilter::Smoothing
vtkTypeBool Smoothing
Definition: vtkImageToPolyDataFilter.h:204
vtkImageToPolyDataFilter::LookupTable
vtkScalarsToColors * LookupTable
Definition: vtkImageToPolyDataFilter.h:210
vtkImageToPolyDataFilter::Decimation
vtkTypeBool Decimation
Definition: vtkImageToPolyDataFilter.h:206
vtkImageToPolyDataFilter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkImageToPolyDataFilter::New
static vtkImageToPolyDataFilter * New()
Instantiate object with initial number of colors 256.
vtkImageToPolyDataFilter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkImageToPolyDataFilter::Error
int Error
Definition: vtkImageToPolyDataFilter.h:208
vtkImageToPolyDataFilter::DecimationError
double DecimationError
Definition: vtkImageToPolyDataFilter.h:207
vtkImageToPolyDataFilter::ColorMode
int ColorMode
Definition: vtkImageToPolyDataFilter.h:203
vtkImageToPolyDataFilter::SubImageSize
int SubImageSize
Definition: vtkImageToPolyDataFilter.h:209
vtkImageToPolyDataFilter::SetOutputStyleToPixelize
void SetOutputStyleToPixelize()
Specify how to create the output.
Definition: vtkImageToPolyDataFilter.h:109
vtkImageToPolyDataFilter::SetOutputStyleToPolygonalize
void SetOutputStyleToPolygonalize()
Specify how to create the output.
Definition: vtkImageToPolyDataFilter.h:110
vtkImageToPolyDataFilter::SetColorModeToLUT
void SetColorModeToLUT()
Specify how to quantize color.
Definition: vtkImageToPolyDataFilter.h:120
vtkImageToPolyDataFilter::SetLookupTable
virtual void SetLookupTable(vtkScalarsToColors *)
Set/Get the vtkLookupTable to use.
vtkImageToPolyDataFilter::PixelizeImage
virtual void PixelizeImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
vtkImageToPolyDataFilter::OutputStyle
int OutputStyle
Definition: vtkImageToPolyDataFilter.h:202
vtkImageToPolyDataFilter::~vtkImageToPolyDataFilter
~vtkImageToPolyDataFilter() override
vtkImageToPolyDataFilter::NumberOfSmoothingIterations
int NumberOfSmoothingIterations
Definition: vtkImageToPolyDataFilter.h:205
vtkImageToPolyDataFilter::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkImageToPolyDataFilter::vtkImageToPolyDataFilter
vtkImageToPolyDataFilter()
vtkImageToPolyDataFilter::PolygonalizeImage
virtual void PolygonalizeImage(vtkUnsignedCharArray *pixels, int dims[3], double origin[3], double spacing[3], vtkPolyData *output)
vtkImageToPolyDataFilter::SetOutputStyleToRunLength
void SetOutputStyleToRunLength()
Specify how to create the output.
Definition: vtkImageToPolyDataFilter.h:111
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:44
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:43
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:65
vtkStructuredPoints
A subclass of ImageData.
Definition: vtkStructuredPoints.h:37
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:40
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::mode
@ mode
Definition: vtkX3D.h:247
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkX3D::type
@ type
Definition: vtkX3D.h:516
vtkX3D::spacing
@ spacing
Definition: vtkX3D.h:481
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
edges
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
Definition: vtkBoostGraphAdapter.h:993
VTK_COLOR_MODE_LINEAR_256
#define VTK_COLOR_MODE_LINEAR_256
Definition: vtkImageToPolyDataFilter.h:75
VTK_COLOR_MODE_LUT
#define VTK_COLOR_MODE_LUT
Definition: vtkImageToPolyDataFilter.h:74
VTK_STYLE_POLYGONALIZE
#define VTK_STYLE_POLYGONALIZE
Definition: vtkImageToPolyDataFilter.h:71
VTK_STYLE_PIXELIZE
#define VTK_STYLE_PIXELIZE
Definition: vtkImageToPolyDataFilter.h:70
VTK_STYLE_RUN_LENGTH
#define VTK_STYLE_RUN_LENGTH
Definition: vtkImageToPolyDataFilter.h:72
vtkPolyDataAlgorithm.h
vtkParseResult::Error
@ Error
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:144