VTK  9.3.0
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
52 #include "vtkPointSetAlgorithm.h"
53 
54 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
55 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
56 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
57 #define VTK_EXTRACT_LARGEST_REGION 4
58 #define VTK_EXTRACT_ALL_REGIONS 5
59 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
60 
61 VTK_ABI_NAMESPACE_BEGIN
62 class vtkDataArray;
63 class vtkDataSet;
64 class vtkFloatArray;
65 class vtkIdList;
66 class vtkIdTypeArray;
67 class vtkIntArray;
68 class vtkPolyData;
69 
70 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
71 {
72 public:
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
80 
82 
87  vtkSetMacro(ScalarConnectivity, vtkTypeBool);
88  vtkGetMacro(ScalarConnectivity, vtkTypeBool);
89  vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
91 
93 
96  vtkSetVector2Macro(ScalarRange, double);
97  vtkGetVector2Macro(ScalarRange, double);
99 
101 
104  vtkSetClampMacro(
106  vtkGetMacro(ExtractionMode, int);
108  {
109  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
110  }
112  {
113  this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
114  }
117  {
118  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
119  }
121  {
122  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
123  }
124  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
125  const char* GetExtractionModeAsString();
127 
132 
136  void AddSeed(vtkIdType id);
137 
142 
147 
151  void AddSpecifiedRegion(int id);
152 
156  void DeleteSpecifiedRegion(int id);
157 
159 
163  vtkSetVector3Macro(ClosestPoint, double);
164  vtkGetVectorMacro(ClosestPoint, double, 3);
166 
171 
173 
176  vtkSetMacro(ColorRegions, vtkTypeBool);
177  vtkGetMacro(ColorRegions, vtkTypeBool);
178  vtkBooleanMacro(ColorRegions, vtkTypeBool);
180 
186  {
189  CELL_COUNT_ASCENDING
190  };
191 
193 
197  vtkSetMacro(RegionIdAssignmentMode, int);
198  vtkGetMacro(RegionIdAssignmentMode, int);
199 
201 
206  vtkSetMacro(OutputPointsPrecision, int);
207  vtkGetMacro(OutputPointsPrecision, int);
209 
210 protected:
213 
216 
217  // Usual data generation method
219  vtkInformationVector* outputVector) override;
222  int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
223 
224  vtkTypeBool ColorRegions; // boolean turns on/off scalar gen for separate regions
225  int ExtractionMode; // how to extract regions
227  vtkIdList* Seeds; // id's of points or cells used to seed regions
228  vtkIdList* SpecifiedRegionIds; // regions specified for extraction
229  vtkIdTypeArray* RegionSizes; // size (in cells) of each region extracted
230 
231  double ClosestPoint[3];
232 
234  double ScalarRange[2];
235 
237 
239 
240  void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
241 
242 private:
243  // used to support algorithm execution
244  vtkFloatArray* CellScalars;
245  vtkIdList* NeighborCellPointIds;
246  vtkIdType* Visited;
247  vtkIdType* PointMap;
248  vtkIdTypeArray* NewScalars;
249  vtkIdTypeArray* NewCellScalars;
250  vtkIdType RegionNumber;
251  vtkIdType PointNumber;
252  vtkIdType NumCellsInRegion;
253  vtkDataArray* InScalars;
254  vtkIdList* Wave;
255  vtkIdList* Wave2;
256  vtkIdList* PointIds;
257  vtkIdList* CellIds;
258 
260  void operator=(const vtkConnectivityFilter&) = delete;
261 };
262 
267 {
269  {
270  return "ExtractPointSeededRegions";
271  }
273  {
274  return "ExtractCellSeededRegions";
275  }
277  {
278  return "ExtractSpecifiedRegions";
279  }
280  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
281  {
282  return "ExtractAllRegions";
283  }
285  {
286  return "ExtractClosestPointRegion";
287  }
288  else
289  {
290  return "ExtractLargestRegion";
291  }
292 }
293 
294 VTK_ABI_NAMESPACE_END
295 #endif
extract data based on geometric connectivity
~vtkConnectivityFilter() override
void TraverseAndMark(vtkDataSet *input)
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.
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
Fill the input port information objects for this algorithm.
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
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
see vtkAlgorithm for details
int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation *info) override
void InitializeSeedList()
Initialize list of point ids/cell ids used to seed regions.
static vtkConnectivityFilter * New()
Construct with default extraction mode to extract largest regions.
void DeleteSpecifiedRegion(int id)
Delete a region id to extract.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
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
This is called by the superclass.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
abstract class to specify dataset behavior
Definition: vtkDataSet.h:53
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
list of point or cell ids
Definition: vtkIdList.h:23
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
Superclass for algorithms that produce output of the same type as input.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
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