VTK  9.7.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
48 #ifndef vtkConnectivityFilter_h
49 #define vtkConnectivityFilter_h
50 
51 #include "vtkFiltersCoreModule.h" // For export macro
52 #include "vtkPointSetAlgorithm.h"
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 
64 VTK_ABI_NAMESPACE_BEGIN
65 class vtkDataArray;
66 class vtkDataSet;
67 class vtkFloatArray;
68 class vtkIdList;
69 class vtkIdTypeArray;
70 class vtkIntArray;
71 class vtkPolyData;
72 
73 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkConnectivityFilter : public vtkPointSetAlgorithm
74 {
75 public:
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
82  static vtkConnectivityFilter* New();
83 
85 
90  vtkSetMacro(ScalarConnectivity, vtkTypeBool);
91  vtkGetMacro(ScalarConnectivity, vtkTypeBool);
92  vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
94 
96 
99  vtkSetVector2Macro(ScalarRange, double);
100  vtkGetVector2Macro(ScalarRange, double);
102 
104 
107  vtkSetClampMacro(
109  vtkGetMacro(ExtractionMode, int);
111  {
112  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
113  }
115  {
116  this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
117  }
120  {
121  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
122  }
124  {
125  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
126  }
127  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
128  const char* GetExtractionModeAsString();
130 
134  void InitializeSeedList();
135 
139  void AddSeed(vtkIdType id);
140 
144  void DeleteSeed(vtkIdType id);
145 
149  void InitializeSpecifiedRegionList();
150 
154  void AddSpecifiedRegion(int id);
155 
159  void DeleteSpecifiedRegion(int id);
160 
162 
166  vtkSetVector3Macro(ClosestPoint, double);
167  vtkGetVectorMacro(ClosestPoint, double, 3);
169 
173  int GetNumberOfExtractedRegions();
174 
176 
179  vtkSetMacro(ColorRegions, vtkTypeBool);
180  vtkGetMacro(ColorRegions, vtkTypeBool);
181  vtkBooleanMacro(ColorRegions, vtkTypeBool);
183 
189  {
192  CELL_COUNT_ASCENDING
193  };
194 
196 
199  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 
225 protected:
227  ~vtkConnectivityFilter() override;
228 
230 
235  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
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
251  vtkTypeBool ColorRegions = 0;
252  // how to extract regions
253  int ExtractionMode = VTK_EXTRACT_LARGEST_REGION;
254  int OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION;
255  // id's of points or cells used to seed regions
256  vtkIdList* Seeds = nullptr;
257  // regions specified for extraction
258  vtkIdList* SpecifiedRegionIds = nullptr;
259  // size (in cells) of each region extracted
260  vtkIdTypeArray* RegionSizes = nullptr;
261 
262  double ClosestPoint[3] = { 0, 0, 0 };
263 
264  vtkTypeBool ScalarConnectivity = 0;
265  double ScalarRange[2] = { 0, 1 };
266 
267  int RegionIdAssignmentMode = UNSPECIFIED;
268 
273  void TraverseAndMark(vtkDataSet* input);
274 
275  void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
276 
284  vtkSmartPointer<vtkDataArray> CompressWithImplicit(vtkDataArray* array);
285 
286 private:
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 
339 VTK_ABI_NAMESPACE_END
340 #endif
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Store vtkAlgorithm input/output information.
vtkTypeBool ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
See vtkAlgorithm for details.
virtual int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
extract data based on geometric connectivity
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, obtaining type information, and printing instances of the class...
#define VTK_EXTRACT_LARGEST_REGION
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
#define VTK_EXTRACT_SPECIFIED_REGIONS
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
int vtkTypeBool
Definition: vtkABI.h:64
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_CLOSEST_POINT_REGION
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
Superclass for algorithms that process vtkPointSet input.
RegionIdAssignment
Enumeration of the various ways to assign RegionIds when the ColorRegions option is on...
#define VTK_EXTRACT_ALL_REGIONS
static vtkPointSetAlgorithm * New()
Standard methods for instantiation, obtaining type information, and printing instances of the class...
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
Store zero or more vtkInformation instances.
#define VTK_MARSHALAUTO
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.