VTK  9.5.20250904
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#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
113
114#include "vtkNew.h" // for member
115
116#define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
117#define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
118#define VTK_EXTRACT_SPECIFIED_REGIONS 3
119#define VTK_EXTRACT_LARGEST_REGION 4
120#define VTK_EXTRACT_ALL_REGIONS 5
121#define VTK_EXTRACT_CLOSEST_POINT_REGION 6
122
123VTK_ABI_NAMESPACE_BEGIN
124class vtkDataArray;
125class vtkDataSet;
126class vtkFloatArray;
127class vtkIdList;
128class vtkIdTypeArray;
129class vtkIntArray;
130class vtkPolyData;
131
133{
134public:
136 void PrintSelf(ostream& os, vtkIndent indent) override;
137
142
144
149 vtkSetMacro(ScalarConnectivity, vtkTypeBool);
150 vtkGetMacro(ScalarConnectivity, vtkTypeBool);
151 vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
153
155
158 vtkSetVector2Macro(ScalarRange, double);
159 vtkGetVector2Macro(ScalarRange, double);
161
163
166 vtkSetClampMacro(
168 vtkGetMacro(ExtractionMode, int);
170 {
171 this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
172 }
174 {
175 this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
176 }
179 {
180 this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
181 }
183 {
184 this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
185 }
186 void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
187 const char* GetExtractionModeAsString();
189
194
199
204
209
213 void AddSpecifiedRegion(int id);
214
219
221
225 vtkSetVector3Macro(ClosestPoint, double);
226 vtkGetVectorMacro(ClosestPoint, double, 3);
228
233
235
238 vtkSetMacro(ColorRegions, vtkTypeBool);
239 vtkGetMacro(ColorRegions, vtkTypeBool);
240 vtkBooleanMacro(ColorRegions, vtkTypeBool);
242
248 {
251 CELL_COUNT_ASCENDING
252 };
253
255
259 vtkSetMacro(RegionIdAssignmentMode, int);
260 vtkGetMacro(RegionIdAssignmentMode, int);
261
263
268 vtkSetMacro(OutputPointsPrecision, int);
269 vtkGetMacro(OutputPointsPrecision, int);
271
273
279 vtkSetMacro(CompressArrays, bool);
280 vtkGetMacro(CompressArrays, bool);
281 vtkBooleanMacro(CompressArrays, bool);
283
284protected:
287
289
295 vtkInformationVector* outputVector) override;
297 // Requires a vtkDataSet
298 int FillInputPortInformation(int port, vtkInformation* info) override;
299 // Outputs a vtkDataSet
300 int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
302
307 void AddRegionsIds(vtkDataSet* output, vtkDataArray* pointArray, vtkDataArray* cellArray);
308
309 // boolean turns on/off scalar gen for separate regions
310 vtkTypeBool ColorRegions = 0;
311 // how to extract regions
312 int ExtractionMode = VTK_EXTRACT_LARGEST_REGION;
313 int OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION;
314 // id's of points or cells used to seed regions
315 vtkIdList* Seeds = nullptr;
316 // regions specified for extraction
317 vtkIdList* SpecifiedRegionIds = nullptr;
318 // size (in cells) of each region extracted
319 vtkIdTypeArray* RegionSizes = nullptr;
320
321 double ClosestPoint[3] = { 0, 0, 0 };
322
323 vtkTypeBool ScalarConnectivity = 0;
324 double ScalarRange[2] = { 0, 1 };
325
326 int RegionIdAssignmentMode = UNSPECIFIED;
327
333
334 void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
335
344
345private:
346 // used to support algorithm execution
347 vtkNew<vtkFloatArray> CellScalars;
348 vtkNew<vtkIdList> NeighborCellPointIds;
349 vtkIdType* Visited = nullptr;
350 vtkIdType* PointMap = nullptr;
351 vtkNew<vtkIdTypeArray> NewScalars;
352 vtkNew<vtkIdTypeArray> NewCellScalars;
353 vtkIdType RegionNumber = 0;
354 vtkIdType PointNumber = 0;
355 vtkIdType NumCellsInRegion = 0;
356 vtkDataArray* InScalars = nullptr;
357 vtkIdList* Wave = nullptr;
358 vtkIdList* Wave2 = nullptr;
359 vtkIdList* PointIds = nullptr;
360 vtkIdList* CellIds = nullptr;
361 bool CompressArrays = true;
362
364 void operator=(const vtkConnectivityFilter&) = delete;
365};
366
371{
373 {
374 return "ExtractPointSeededRegions";
375 }
377 {
378 return "ExtractCellSeededRegions";
379 }
381 {
382 return "ExtractSpecifiedRegions";
383 }
384 else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
385 {
386 return "ExtractAllRegions";
387 }
389 {
390 return "ExtractClosestPointRegion";
391 }
392 else
393 {
394 return "ExtractLargestRegion";
395 }
396}
397
398VTK_ABI_NAMESPACE_END
399#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.
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 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:332
#define VTK_MARSHALAUTO