VTK  9.4.20251203
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
48#ifndef vtkConnectivityFilter_h
49#define vtkConnectivityFilter_h
50
51#include "vtkFiltersCoreModule.h" // For export macro
53
54#include "vtkNew.h" // for member
55
56#define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
57#define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
58#define VTK_EXTRACT_SPECIFIED_REGIONS 3
59#define VTK_EXTRACT_LARGEST_REGION 4
60#define VTK_EXTRACT_ALL_REGIONS 5
61#define VTK_EXTRACT_CLOSEST_POINT_REGION 6
62
63VTK_ABI_NAMESPACE_BEGIN
64class vtkDataArray;
65class vtkDataSet;
66class vtkFloatArray;
67class vtkIdList;
68class vtkIdTypeArray;
69class vtkIntArray;
70class vtkPolyData;
71
72class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
73{
74public:
76 void PrintSelf(ostream& os, vtkIndent indent) override;
77
82
84
89 vtkSetMacro(ScalarConnectivity, vtkTypeBool);
90 vtkGetMacro(ScalarConnectivity, vtkTypeBool);
91 vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
93
95
98 vtkSetVector2Macro(ScalarRange, double);
99 vtkGetVector2Macro(ScalarRange, double);
101
103
106 vtkSetClampMacro(
108 vtkGetMacro(ExtractionMode, int);
110 {
111 this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
112 }
114 {
115 this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
116 }
119 {
120 this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
121 }
123 {
124 this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
125 }
126 void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
127 const char* GetExtractionModeAsString();
129
134
139
144
149
153 void AddSpecifiedRegion(int id);
154
159
161
165 vtkSetVector3Macro(ClosestPoint, double);
166 vtkGetVectorMacro(ClosestPoint, double, 3);
168
173
175
178 vtkSetMacro(ColorRegions, vtkTypeBool);
179 vtkGetMacro(ColorRegions, vtkTypeBool);
180 vtkBooleanMacro(ColorRegions, vtkTypeBool);
182
188 {
191 CELL_COUNT_ASCENDING
192 };
193
195
199 vtkSetMacro(RegionIdAssignmentMode, int);
200 vtkGetMacro(RegionIdAssignmentMode, int);
201
203
208 vtkSetMacro(OutputPointsPrecision, int);
209 vtkGetMacro(OutputPointsPrecision, int);
211
213
219 vtkSetMacro(CompressArrays, bool);
220 vtkGetMacro(CompressArrays, bool);
221 vtkBooleanMacro(CompressArrays, bool);
223
224protected:
227
229
235 vtkInformationVector* outputVector) override;
237 // Requires a vtkDataSet
238 int FillInputPortInformation(int port, vtkInformation* info) override;
239 // Outputs a vtkDataSet
240 int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
242
247 void AddRegionsIds(vtkDataSet* output, vtkDataArray* pointArray, vtkDataArray* cellArray);
248
249 // boolean turns on/off scalar gen for separate regions
250 vtkTypeBool ColorRegions = 0;
251 // how to extract regions
252 int ExtractionMode = VTK_EXTRACT_LARGEST_REGION;
253 int OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION;
254 // id's of points or cells used to seed regions
255 vtkIdList* Seeds = nullptr;
256 // regions specified for extraction
257 vtkIdList* SpecifiedRegionIds = nullptr;
258 // size (in cells) of each region extracted
259 vtkIdTypeArray* RegionSizes = nullptr;
260
261 double ClosestPoint[3] = { 0, 0, 0 };
262
263 vtkTypeBool ScalarConnectivity = 0;
264 double ScalarRange[2] = { 0, 1 };
265
266 int RegionIdAssignmentMode = UNSPECIFIED;
267
273
274 void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
275
284
285private:
286 // used to support algorithm execution
287 vtkNew<vtkFloatArray> CellScalars;
288 vtkNew<vtkIdList> NeighborCellPointIds;
289 vtkIdType* Visited = nullptr;
290 vtkIdType* PointMap = nullptr;
291 vtkNew<vtkIdTypeArray> NewScalars;
292 vtkNew<vtkIdTypeArray> NewCellScalars;
293 vtkIdType RegionNumber = 0;
294 vtkIdType PointNumber = 0;
295 vtkIdType NumCellsInRegion = 0;
296 vtkDataArray* InScalars = nullptr;
297 vtkIdList* Wave = nullptr;
298 vtkIdList* Wave2 = nullptr;
299 vtkIdList* PointIds = nullptr;
300 vtkIdList* CellIds = nullptr;
301 bool CompressArrays = true;
302
304 void operator=(const vtkConnectivityFilter&) = delete;
305};
306
311{
313 {
314 return "ExtractPointSeededRegions";
315 }
317 {
318 return "ExtractCellSeededRegions";
319 }
321 {
322 return "ExtractSpecifiedRegions";
323 }
324 else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
325 {
326 return "ExtractAllRegions";
327 }
329 {
330 return "ExtractClosestPointRegion";
331 }
332 else
333 {
334 return "ExtractLargestRegion";
335 }
336}
337
338VTK_ABI_NAMESPACE_END
339#endif
extract data based on geometric connectivity
~vtkConnectivityFilter() override
void TraverseAndMark(vtkDataSet *input)
Mark current cell as visited and assign region number.
vtkSmartPointer< vtkDataArray > CompressWithImplicit(vtkDataArray *array)
Compress the given array, returning a vtkImplicitArray.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
void OrderRegionIds(vtkIdTypeArray *pointRegionIds, vtkIdTypeArray *cellRegionIds)
void AddSpecifiedRegion(int id)
Add a region id to extract.
static vtkConnectivityFilter * New()
Construct with default extraction mode to extract largest regions.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DeleteSeed(vtkIdType id)
Delete a seed id (point or cell id).
int FillInputPortInformation(int port, vtkInformation *info) override
Usual vtkAlgorithm method implementations.
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
void AddRegionsIds(vtkDataSet *output, vtkDataArray *pointArray, vtkDataArray *cellArray)
Add regions ids array to output dataset.
void AddSeed(vtkIdType id)
Add a seed id (point or cell id).
RegionIdAssignment
Enumeration of the various ways to assign RegionIds when the ColorRegions option is on.
vtkTypeBool ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Usual vtkAlgorithm method implementations.
int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation *info) override
Usual vtkAlgorithm method implementations.
void InitializeSeedList()
Initialize list of point ids/cell ids used to seed regions.
void DeleteSpecifiedRegion(int id)
Delete a region id to extract.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
Usual vtkAlgorithm method implementations.
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
void InitializeSpecifiedRegionList()
Initialize list of region ids to extract.
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Usual vtkAlgorithm method implementations.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
abstract superclass for arrays of numeric data
abstract class to specify dataset behavior
Definition vtkDataSet.h:57
dynamic, self-adjusting array of float
list of point or cell ids
Definition vtkIdList.h:24
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition vtkIntArray.h:35
Allocate and hold a VTK object.
Definition vtkNew.h:58
Superclass for algorithms that produce output of the same type as input.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
Hold a reference to a vtkObjectBase instance.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_LARGEST_REGION
int vtkIdType
Definition vtkType.h:315