VTK: Filters/Core/vtkConnectivityFilter.h Source File

| VTK 9.3.1

vtkConnectivityFilter.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
57 #ifndef vtkConnectivityFilter_h
58 #define vtkConnectivityFilter_h
59
60 #include "vtkFiltersCoreModule.h" // For export macro
61 #include "vtkPointSetAlgorithm.h"
62
63 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
64 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
65 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
66 #define VTK_EXTRACT_LARGEST_REGION 4
67 #define VTK_EXTRACT_ALL_REGIONS 5
68 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
69
70 VTK_ABI_NAMESPACE_BEGIN
71 class vtkDataArray;
72 class vtkDataSet;
73 class vtkFloatArray;
74 class vtkIdList;
75 class vtkIdTypeArray;
76 class vtkIntArray;
77 class vtkPolyData;
78
79 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
80 {
81 public:
82 vtkTypeMacro(vtkConnectivityFilter, vtkPointSetAlgorithm);
83 void PrintSelf(ostream& os, vtkIndent indent) override;
84
88 static vtkConnectivityFilter* New();
89
91
96 vtkSetMacro(ScalarConnectivity, vtkTypeBool);
97 vtkGetMacro(ScalarConnectivity, vtkTypeBool);
98 vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
100
102
105 vtkSetVector2Macro(ScalarRange, double);
106 vtkGetVector2Macro(ScalarRange, double);
108
110
113 vtkSetClampMacro(
114 ExtractionMode, int, VTK_EXTRACT_POINT_SEEDED_REGIONS, VTK_EXTRACT_CLOSEST_POINT_REGION);
115 vtkGetMacro(ExtractionMode, int);
116 void SetExtractionModeToPointSeededRegions()
117 {
118 this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
119 }
120 void SetExtractionModeToCellSeededRegions()
121 {
122 this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
123 }
124 void SetExtractionModeToLargestRegion() { this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION); }
125 void SetExtractionModeToSpecifiedRegions()
126 {
127 this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
128 }
129 void SetExtractionModeToClosestPointRegion()
130 {
131 this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
132 }
133 void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
134 const char* GetExtractionModeAsString();
136
140 void InitializeSeedList();
141
145 void AddSeed(vtkIdType id);
146
150 void DeleteSeed(vtkIdType id);
151
155 void InitializeSpecifiedRegionList();
156
160 void AddSpecifiedRegion(int id);
161
165 void DeleteSpecifiedRegion(int id);
166
168
172 vtkSetVector3Macro(ClosestPoint, double);
173 vtkGetVectorMacro(ClosestPoint, double, 3);
175
179 int GetNumberOfExtractedRegions();
180
182
185 vtkSetMacro(ColorRegions, vtkTypeBool);
186 vtkGetMacro(ColorRegions, vtkTypeBool);
187 vtkBooleanMacro(ColorRegions, vtkTypeBool);
189
194 enum RegionIdAssignment
195 {
196 UNSPECIFIED,
197 CELL_COUNT_DESCENDING,
198 CELL_COUNT_ASCENDING
199 };
200
202
206 vtkSetMacro(RegionIdAssignmentMode, int);
207 vtkGetMacro(RegionIdAssignmentMode, int);
208
210
215 vtkSetMacro(OutputPointsPrecision, int);
216 vtkGetMacro(OutputPointsPrecision, int);
218
219 protected:
220 vtkConnectivityFilter();
221 ~vtkConnectivityFilter() override;
222
223 vtkTypeBool ProcessRequest(
224 vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
225
226 // Usual data generation method
227 int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
228 vtkInformationVector* outputVector) override;
229 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
230 int FillInputPortInformation(int port, vtkInformation* info) override;
231 int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
232
233 vtkTypeBool ColorRegions; // boolean turns on/off scalar gen for separate regions
234 int ExtractionMode; // how to extract regions
235 int OutputPointsPrecision;
236 vtkIdList* Seeds; // id's of points or cells used to seed regions
237 vtkIdList* SpecifiedRegionIds; // regions specified for extraction
238 vtkIdTypeArray* RegionSizes; // size (in cells) of each region extracted
239
240 double ClosestPoint[3];
241
242 vtkTypeBool ScalarConnectivity;
243 double ScalarRange[2];
244
245 int RegionIdAssignmentMode;
246
247 void TraverseAndMark(vtkDataSet* input);
248
249 void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
250
251 private:
252 // used to support algorithm execution
253 vtkFloatArray* CellScalars;
254 vtkIdList* NeighborCellPointIds;
255 vtkIdType* Visited;
256 vtkIdType* PointMap;
257 vtkIdTypeArray* NewScalars;
258 vtkIdTypeArray* NewCellScalars;
259 vtkIdType RegionNumber;
260 vtkIdType PointNumber;
261 vtkIdType NumCellsInRegion;
262 vtkDataArray* InScalars;
263 vtkIdList* Wave;
264 vtkIdList* Wave2;
265 vtkIdList* PointIds;
266 vtkIdList* CellIds;
267
268 vtkConnectivityFilter(const vtkConnectivityFilter&) = delete;
269 void operator=(const vtkConnectivityFilter&) = delete;
270 };
271
275 inline const char* vtkConnectivityFilter::GetExtractionModeAsString()
276 {
277 if (this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS)
278 {
279 return "ExtractPointSeededRegions";
280 }
281 else if (this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS)
282 {
283 return "ExtractCellSeededRegions";
284 }
285 else if (this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS)
286 {
287 return "ExtractSpecifiedRegions";
288 }
289 else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
290 {
291 return "ExtractAllRegions";
292 }
293 else if (this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION)
294 {
295 return "ExtractClosestPointRegion";
296 }
297 else
298 {
299 return "ExtractLargestRegion";
300 }
301 }
302
303 VTK_ABI_NAMESPACE_END
304 #endif
vtkConnectivityFilter
extract data based on geometric connectivity
Definition: vtkConnectivityFilter.h:80
vtkConnectivityFilter::~vtkConnectivityFilter
~vtkConnectivityFilter() override
vtkConnectivityFilter::TraverseAndMark
void TraverseAndMark(vtkDataSet *input)
vtkConnectivityFilter::SetExtractionModeToClosestPointRegion
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:129
vtkConnectivityFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:124
vtkConnectivityFilter::SpecifiedRegionIds
vtkIdList * SpecifiedRegionIds
Definition: vtkConnectivityFilter.h:237
vtkConnectivityFilter::OrderRegionIds
void OrderRegionIds(vtkIdTypeArray *pointRegionIds, vtkIdTypeArray *cellRegionIds)
vtkConnectivityFilter::RegionIdAssignmentMode
int RegionIdAssignmentMode
Definition: vtkConnectivityFilter.h:245
vtkConnectivityFilter::AddSpecifiedRegion
void AddSpecifiedRegion(int id)
Add a region id to extract.
vtkConnectivityFilter::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkConnectivityFilter::DeleteSeed
void DeleteSeed(vtkIdType id)
Delete a seed id (point or cell id).
vtkConnectivityFilter::ColorRegions
vtkTypeBool ColorRegions
Definition: vtkConnectivityFilter.h:233
vtkConnectivityFilter::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkConnectivityFilter::GetExtractionModeAsString
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
Definition: vtkConnectivityFilter.h:275
vtkConnectivityFilter::SetExtractionModeToCellSeededRegions
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:120
vtkConnectivityFilter::vtkConnectivityFilter
vtkConnectivityFilter()
vtkConnectivityFilter::AddSeed
void AddSeed(vtkIdType id)
Add a seed id (point or cell id).
vtkConnectivityFilter::RegionIdAssignment
RegionIdAssignment
Enumeration of the various ways to assign RegionIds when the ColorRegions option is on.
Definition: vtkConnectivityFilter.h:195
vtkConnectivityFilter::UNSPECIFIED
@ UNSPECIFIED
Definition: vtkConnectivityFilter.h:196
vtkConnectivityFilter::CELL_COUNT_DESCENDING
@ CELL_COUNT_DESCENDING
Definition: vtkConnectivityFilter.h:197
vtkConnectivityFilter::ProcessRequest
vtkTypeBool ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
see vtkAlgorithm for details
vtkConnectivityFilter::ExtractionMode
int ExtractionMode
Definition: vtkConnectivityFilter.h:234
vtkConnectivityFilter::FillOutputPortInformation
int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation *info) override
vtkConnectivityFilter::RegionSizes
vtkIdTypeArray * RegionSizes
Definition: vtkConnectivityFilter.h:238
vtkConnectivityFilter::InitializeSeedList
void InitializeSeedList()
Initialize list of point ids/cell ids used to seed regions.
vtkConnectivityFilter::New
static vtkConnectivityFilter * New()
Construct with default extraction mode to extract largest regions.
vtkConnectivityFilter::DeleteSpecifiedRegion
void DeleteSpecifiedRegion(int id)
Delete a region id to extract.
vtkConnectivityFilter::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkConnectivityFilter::SetExtractionModeToPointSeededRegions
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:116
vtkConnectivityFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:133
vtkConnectivityFilter::InitializeSpecifiedRegionList
void InitializeSpecifiedRegionList()
Initialize list of region ids to extract.
vtkConnectivityFilter::Seeds
vtkIdList * Seeds
Definition: vtkConnectivityFilter.h:236
vtkConnectivityFilter::RequestDataObject
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
vtkConnectivityFilter::ScalarConnectivity
vtkTypeBool ScalarConnectivity
Definition: vtkConnectivityFilter.h:242
vtkConnectivityFilter::OutputPointsPrecision
int OutputPointsPrecision
Definition: vtkConnectivityFilter.h:235
vtkConnectivityFilter::SetExtractionModeToSpecifiedRegions
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
Definition: vtkConnectivityFilter.h:125
vtkConnectivityFilter::GetNumberOfExtractedRegions
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:32
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:37
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
vtkPointSetAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkPointSetAlgorithm.h:33
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::port
@ port
Definition: vtkX3D.h:447
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_CLOSEST_POINT_REGION
Definition: vtkConnectivityFilter.h:68
VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:63
VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
Definition: vtkConnectivityFilter.h:67
VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:64
VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
Definition: vtkConnectivityFilter.h:65
VTK_EXTRACT_LARGEST_REGION
#define VTK_EXTRACT_LARGEST_REGION
Definition: vtkConnectivityFilter.h:66
vtkPointSetAlgorithm.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315