forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkPolyDataConnectivityFilter.h
264 lines (223 loc) · 9.24 KB
/
vtkPolyDataConnectivityFilter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPolyDataConnectivityFilter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPolyDataConnectivityFilter - extract polygonal data based on geometric connectivity
// .SECTION Description
// vtkPolyDataConnectivityFilter is a filter that extracts cells that
// share common points and/or satisfy a scalar threshold
// criterion. (Such a group of cells is called a region.) The filter
// works in one of six ways: 1) extract the largest (most points) connected region
// in the dataset; 2) extract specified region numbers; 3) extract all
// regions sharing specified point ids; 4) extract all regions sharing
// specified cell ids; 5) extract the region closest to the specified
// point; or 6) extract all regions (used to color regions).
//
// This filter is specialized for polygonal data. This means it runs a bit
// faster and is easier to construct visualization networks that process
// polygonal data.
//
// The behavior of vtkPolyDataConnectivityFilter can be modified by turning
// on the boolean ivar ScalarConnectivity. If this flag is on, the
// connectivity algorithm is modified so that cells are considered connected
// only if 1) they are geometrically connected (share a point) and 2) the
// scalar values of the cell's points falls in the scalar range specified.
// If ScalarConnectivity and FullScalarConnectivity is ON, all the cell's
// points must lie in the scalar range specified for the cell to qualify as
// being connected. If FullScalarConnectivity is OFF, any one of the cell's
// points may lie in the user specified scalar range for the cell to qualify
// as being connected.
//
// This use of ScalarConnectivity is particularly useful for selecting cells
// for later processing.
//
// .SECTION See Also
// vtkConnectivityFilter
#ifndef __vtkPolyDataConnectivityFilter_h
#define __vtkPolyDataConnectivityFilter_h
#include "vtkFiltersCoreModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
#define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
#define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
#define VTK_EXTRACT_SPECIFIED_REGIONS 3
#define VTK_EXTRACT_LARGEST_REGION 4
#define VTK_EXTRACT_ALL_REGIONS 5
#define VTK_EXTRACT_CLOSEST_POINT_REGION 6
class vtkDataArray;
class vtkIdList;
class vtkIdTypeArray;
class VTKFILTERSCORE_EXPORT vtkPolyDataConnectivityFilter : public vtkPolyDataAlgorithm
{
public:
vtkTypeMacro(vtkPolyDataConnectivityFilter,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Obtain the array containing the region sizes of the extracted
// regions
vtkGetObjectMacro(RegionSizes,vtkIdTypeArray);
// Description:
// Construct with default extraction mode to extract largest regions.
static vtkPolyDataConnectivityFilter *New();
// Description:
// Turn on/off connectivity based on scalar value. If on, cells are connected
// only if they share points AND one of the cells scalar values falls in the
// scalar range specified.
vtkSetMacro(ScalarConnectivity,int);
vtkGetMacro(ScalarConnectivity,int);
vtkBooleanMacro(ScalarConnectivity,int);
// Description:
// Turn on/off the use of Fully connected scalar connectivity. This is off
// by default. The flag is used only if ScalarConnectivity is on. If
// FullScalarConnectivity is ON, all the cell's points must lie in the
// scalar range specified for the cell to qualify as being connected. If
// FullScalarConnectivity is OFF, any one of the cell's points may lie in
// the user specified scalar range for the cell to qualify as being
// connected.
vtkSetMacro(FullScalarConnectivity,int);
vtkGetMacro(FullScalarConnectivity,int);
vtkBooleanMacro(FullScalarConnectivity,int);
// Description:
// Set the scalar range to use to extract cells based on scalar connectivity.
vtkSetVector2Macro(ScalarRange,double);
vtkGetVector2Macro(ScalarRange,double);
// Description:
// Control the extraction of connected surfaces.
vtkSetClampMacro(ExtractionMode,int,
VTK_EXTRACT_POINT_SEEDED_REGIONS,
VTK_EXTRACT_CLOSEST_POINT_REGION);
vtkGetMacro(ExtractionMode,int);
void SetExtractionModeToPointSeededRegions()
{this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
void SetExtractionModeToCellSeededRegions()
{this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
void SetExtractionModeToLargestRegion()
{this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
void SetExtractionModeToSpecifiedRegions()
{this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
void SetExtractionModeToClosestPointRegion()
{this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
void SetExtractionModeToAllRegions()
{this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
const char *GetExtractionModeAsString();
// Description:
// Initialize list of point ids/cell ids used to seed regions.
void InitializeSeedList();
// Description:
// Add a seed id (point or cell id). Note: ids are 0-offset.
void AddSeed(int id);
// Description:
// Delete a seed id (point or cell id). Note: ids are 0-offset.
void DeleteSeed(int id);
// Description:
// Initialize list of region ids to extract.
void InitializeSpecifiedRegionList();
// Description:
// Add a region id to extract. Note: ids are 0-offset.
void AddSpecifiedRegion(int id);
// Description:
// Delete a region id to extract. Note: ids are 0-offset.
void DeleteSpecifiedRegion(int id);
// Description:
// Use to specify x-y-z point coordinates when extracting the region
// closest to a specified point.
vtkSetVector3Macro(ClosestPoint,double);
vtkGetVectorMacro(ClosestPoint,double,3);
// Description:
// Obtain the number of connected regions.
int GetNumberOfExtractedRegions();
// Description:
// Turn on/off the coloring of connected regions.
vtkSetMacro(ColorRegions,int);
vtkGetMacro(ColorRegions,int);
vtkBooleanMacro(ColorRegions,int);
// Description:
// Mark visited point ids ? It may be useful to extract the visited point
// ids for use by a downstream filter. Default is OFF.
vtkSetMacro( MarkVisitedPointIds, int );
vtkGetMacro( MarkVisitedPointIds, int );
vtkBooleanMacro( MarkVisitedPointIds, int );
// Description:
// Get the visited point ids. This is valid only if MarkVisitedPointIds
// has been set.
vtkGetObjectMacro( VisitedPointIds, vtkIdList );
// Description:
// Set/get the desired precision for the output types. See the documentation
// for the vtkAlgorithm::DesiredOutputPrecision enum for an explanation of
// the available precision settings.
vtkSetMacro(OutputPointsPrecision,int);
vtkGetMacro(OutputPointsPrecision,int);
protected:
vtkPolyDataConnectivityFilter();
~vtkPolyDataConnectivityFilter();
// Usual data generation method
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
int ColorRegions; //boolean turns on/off scalar gen for separate regions
int ExtractionMode; //how to extract regions
vtkIdList *Seeds; //id's of points or cells used to seed regions
vtkIdList *SpecifiedRegionIds; //regions specified for extraction
vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
double ClosestPoint[3];
int ScalarConnectivity;
int FullScalarConnectivity;
// Does this cell qualify as being scalar connected ?
int IsScalarConnected( vtkIdType cellId );
double ScalarRange[2];
void TraverseAndMark();
// used to support algorithm execution
vtkDataArray *CellScalars;
vtkIdList *NeighborCellPointIds;
vtkIdType *Visited;
vtkIdType *PointMap;
vtkDataArray *NewScalars;
vtkIdType RegionNumber;
vtkIdType PointNumber;
vtkIdType NumCellsInRegion;
vtkDataArray *InScalars;
vtkPolyData *Mesh;
vtkIdList *Wave;
vtkIdList *Wave2;
vtkIdList *PointIds;
vtkIdList *CellIds;
vtkIdList *VisitedPointIds;
int MarkVisitedPointIds;
int OutputPointsPrecision;
private:
vtkPolyDataConnectivityFilter(const vtkPolyDataConnectivityFilter&); // Not implemented.
void operator=(const vtkPolyDataConnectivityFilter&); // Not implemented.
};
// Description:
// Return the method of extraction as a string.
inline const char *vtkPolyDataConnectivityFilter::GetExtractionModeAsString(void)
{
if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS )
{
return "ExtractPointSeededRegions";
}
else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS )
{
return "ExtractCellSeededRegions";
}
else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
{
return "ExtractSpecifiedRegions";
}
else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
{
return "ExtractAllRegions";
}
else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION )
{
return "ExtractClosestPointRegion";
}
else
{
return "ExtractLargestRegion";
}
}
#endif