VTK  9.4.20241218
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
107#ifndef vtkConnectivityFilter_h
108#define vtkConnectivityFilter_h
109
110#include "vtkFiltersCoreModule.h" // For export macro
111#include "vtkPointSetAlgorithm.h"
112
113#include "vtkNew.h" // for member
114
115#define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
116#define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
117#define VTK_EXTRACT_SPECIFIED_REGIONS 3
118#define VTK_EXTRACT_LARGEST_REGION 4
119#define VTK_EXTRACT_ALL_REGIONS 5
120#define VTK_EXTRACT_CLOSEST_POINT_REGION 6
121
122VTK_ABI_NAMESPACE_BEGIN
123class vtkDataArray;
124class vtkDataSet;
125class vtkFloatArray;
126class vtkIdList;
127class vtkIdTypeArray;
128class vtkIntArray;
129class vtkPolyData;
130
131class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
132{
133public:
135 void PrintSelf(ostream& os, vtkIndent indent) override;
136
141
143
148 vtkSetMacro(ScalarConnectivity, vtkTypeBool);
149 vtkGetMacro(ScalarConnectivity, vtkTypeBool);
150 vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
152
154
157 vtkSetVector2Macro(ScalarRange, double);
158 vtkGetVector2Macro(ScalarRange, double);
160
162
165 vtkSetClampMacro(
167 vtkGetMacro(ExtractionMode, int);
169 {
170 this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
171 }
173 {
174 this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
175 }
178 {
179 this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
180 }
182 {
183 this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
184 }
185 void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
186 const char* GetExtractionModeAsString();
188
193
198
203
208
212 void AddSpecifiedRegion(int id);
213
218
220
224 vtkSetVector3Macro(ClosestPoint, double);
225 vtkGetVectorMacro(ClosestPoint, double, 3);
227
232
234
237 vtkSetMacro(ColorRegions, vtkTypeBool);
238 vtkGetMacro(ColorRegions, vtkTypeBool);
239 vtkBooleanMacro(ColorRegions, vtkTypeBool);
241
247 {
250 CELL_COUNT_ASCENDING
251 };
252
254
258 vtkSetMacro(RegionIdAssignmentMode, int);
259 vtkGetMacro(RegionIdAssignmentMode, int);
260
262
267 vtkSetMacro(OutputPointsPrecision, int);
268 vtkGetMacro(OutputPointsPrecision, int);
270
272
278 vtkSetMacro(CompressArrays, bool);
279 vtkGetMacro(CompressArrays, bool);
280 vtkBooleanMacro(CompressArrays, bool);
282
283protected:
286
288
294 vtkInformationVector* outputVector) override;
296 // Requires a vtkDataSet
297 int FillInputPortInformation(int port, vtkInformation* info) override;
298 // Outputs a vtkDataSet
299 int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
301
306 void AddRegionsIds(vtkDataSet* output, vtkDataArray* pointArray, vtkDataArray* cellArray);
307
308 // boolean turns on/off scalar gen for separate regions
309 vtkTypeBool ColorRegions = 0;
310 // how to extract regions
311 int ExtractionMode = VTK_EXTRACT_LARGEST_REGION;
312 int OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION;
313 // id's of points or cells used to seed regions
314 vtkIdList* Seeds = nullptr;
315 // regions specified for extraction
316 vtkIdList* SpecifiedRegionIds = nullptr;
317 // size (in cells) of each region extracted
318 vtkIdTypeArray* RegionSizes = nullptr;
319
320 double ClosestPoint[3] = { 0, 0, 0 };
321
322 vtkTypeBool ScalarConnectivity = 0;
323 double ScalarRange[2] = { 0, 1 };
324
325 int RegionIdAssignmentMode = UNSPECIFIED;
326
332
333 void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
334
343
344private:
345 // used to support algorithm execution
346 vtkNew<vtkFloatArray> CellScalars;
347 vtkNew<vtkIdList> NeighborCellPointIds;
348 vtkIdType* Visited = nullptr;
349 vtkIdType* PointMap = nullptr;
350 vtkNew<vtkIdTypeArray> NewScalars;
351 vtkNew<vtkIdTypeArray> NewCellScalars;
352 vtkIdType RegionNumber = 0;
353 vtkIdType PointNumber = 0;
354 vtkIdType NumCellsInRegion = 0;
355 vtkDataArray* InScalars = nullptr;
356 vtkIdList* Wave = nullptr;
357 vtkIdList* Wave2 = nullptr;
358 vtkIdList* PointIds = nullptr;
359 vtkIdList* CellIds = nullptr;
360 bool CompressArrays = true;
361
363 void operator=(const vtkConnectivityFilter&) = delete;
364};
365
370{
372 {
373 return "ExtractPointSeededRegions";
374 }
376 {
377 return "ExtractCellSeededRegions";
378 }
380 {
381 return "ExtractSpecifiedRegions";
382 }
383 else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
384 {
385 return "ExtractAllRegions";
386 }
388 {
389 return "ExtractClosestPointRegion";
390 }
391 else
392 {
393 return "ExtractLargestRegion";
394 }
395}
396
397VTK_ABI_NAMESPACE_END
398#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:165
dynamic, self-adjusting array of float
list of point or cell ids
Definition vtkIdList.h:133
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Allocate and hold a VTK object.
Definition vtkNew.h:167
Superclass for algorithms that produce output of the same type as input.
concrete dataset represents vertices, lines, polygons, and triangle strips
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