VTK  9.6.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
47
48#ifndef vtkConnectivityFilter_h
49#define vtkConnectivityFilter_h
50
51#include "vtkFiltersCoreModule.h" // For export macro
53#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55#include "vtkNew.h" // for member
56
57#define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
58#define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
59#define VTK_EXTRACT_SPECIFIED_REGIONS 3
60#define VTK_EXTRACT_LARGEST_REGION 4
61#define VTK_EXTRACT_ALL_REGIONS 5
62#define VTK_EXTRACT_CLOSEST_POINT_REGION 6
63
64VTK_ABI_NAMESPACE_BEGIN
65class vtkDataArray;
66class vtkDataSet;
67class vtkFloatArray;
68class vtkIdList;
69class vtkIdTypeArray;
70class vtkIntArray;
71class vtkPolyData;
72
74{
75public:
77 void PrintSelf(ostream& os, vtkIndent indent) override;
78
83
85
94
96
99 vtkSetVector2Macro(ScalarRange, double);
100 vtkGetVector2Macro(ScalarRange, double);
102
104
107 vtkSetClampMacro(
109 vtkGetMacro(ExtractionMode, int);
128 const char* GetExtractionModeAsString();
130
135
140
145
150
154 void AddSpecifiedRegion(int id);
155
160
162
166 vtkSetVector3Macro(ClosestPoint, double);
167 vtkGetVectorMacro(ClosestPoint, double, 3);
169
174
176
181 vtkBooleanMacro(ColorRegions, vtkTypeBool);
183
194
196
200 vtkSetMacro(RegionIdAssignmentMode, int);
201 vtkGetMacro(RegionIdAssignmentMode, int);
202
204
209 vtkSetMacro(OutputPointsPrecision, int);
210 vtkGetMacro(OutputPointsPrecision, int);
212
214
220 vtkSetMacro(CompressArrays, bool);
221 vtkGetMacro(CompressArrays, bool);
222 vtkBooleanMacro(CompressArrays, bool);
224
225protected:
228
230
236 vtkInformationVector* outputVector) override;
238 // Requires a vtkDataSet
239 int FillInputPortInformation(int port, vtkInformation* info) override;
240 // Outputs a vtkDataSet
241 int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
243
248 void AddRegionsIds(vtkDataSet* output, vtkDataArray* pointArray, vtkDataArray* cellArray);
249
250 // boolean turns on/off scalar gen for separate regions
252 // how to extract regions
255 // id's of points or cells used to seed regions
256 vtkIdList* Seeds = nullptr;
257 // regions specified for extraction
259 // size (in cells) of each region extracted
261
262 double ClosestPoint[3] = { 0, 0, 0 };
263
265 double ScalarRange[2] = { 0, 1 };
266
268
274
275 void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
276
285
286private:
287 // used to support algorithm execution
288 vtkNew<vtkFloatArray> CellScalars;
289 vtkNew<vtkIdList> NeighborCellPointIds;
290 vtkIdType* Visited = nullptr;
291 vtkIdType* PointMap = nullptr;
292 vtkNew<vtkIdTypeArray> NewScalars;
293 vtkNew<vtkIdTypeArray> NewCellScalars;
294 vtkIdType RegionNumber = 0;
295 vtkIdType PointNumber = 0;
296 vtkIdType NumCellsInRegion = 0;
297 vtkDataArray* InScalars = nullptr;
298 vtkIdList* Wave = nullptr;
299 vtkIdList* Wave2 = nullptr;
300 vtkIdList* PointIds = nullptr;
301 vtkIdList* CellIds = nullptr;
302 bool CompressArrays = true;
303
305 void operator=(const vtkConnectivityFilter&) = delete;
306};
307
312{
314 {
315 return "ExtractPointSeededRegions";
316 }
318 {
319 return "ExtractCellSeededRegions";
320 }
322 {
323 return "ExtractSpecifiedRegions";
324 }
325 else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
326 {
327 return "ExtractAllRegions";
328 }
330 {
331 return "ExtractClosestPointRegion";
332 }
333 else
334 {
335 return "ExtractLargestRegion";
336 }
337}
338
339VTK_ABI_NAMESPACE_END
340#endif
~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.
virtual void SetExtractionMode(int)
Control the extraction of connected surfaces.
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.
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.
int FillOutputPortInformation(int port, vtkInformation *info) override
Usual vtkAlgorithm method implementations.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
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
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 vtkDataArray
#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:368
#define VTK_MARSHALAUTO