VTK  9.0.1
vtkConnectivityFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkConnectivityFilter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
57 #ifndef vtkConnectivityFilter_h
58 #define vtkConnectivityFilter_h
59 
60 #include "vtkFiltersCoreModule.h" // For export macro
61 #include "vtkPointSetAlgorithm.h"
62 
63 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
64 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
65 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
66 #define VTK_EXTRACT_LARGEST_REGION 4
67 #define VTK_EXTRACT_ALL_REGIONS 5
68 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
69 
70 class vtkDataArray;
71 class vtkDataSet;
72 class vtkFloatArray;
73 class vtkIdList;
74 class vtkIdTypeArray;
75 class vtkIntArray;
76 class vtkPolyData;
77 
78 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
79 {
80 public:
82  void PrintSelf(ostream& os, vtkIndent indent) override;
83 
88 
90 
95  vtkSetMacro(ScalarConnectivity, vtkTypeBool);
96  vtkGetMacro(ScalarConnectivity, vtkTypeBool);
97  vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
99 
101 
104  vtkSetVector2Macro(ScalarRange, double);
105  vtkGetVector2Macro(ScalarRange, double);
107 
109 
112  vtkSetClampMacro(
114  vtkGetMacro(ExtractionMode, int);
116  {
117  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
118  }
120  {
121  this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
122  }
125  {
126  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
127  }
129  {
130  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
131  }
132  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
133  const char* GetExtractionModeAsString();
135 
140 
144  void AddSeed(vtkIdType id);
145 
150 
155 
159  void AddSpecifiedRegion(int id);
160 
164  void DeleteSpecifiedRegion(int id);
165 
167 
171  vtkSetVector3Macro(ClosestPoint, double);
172  vtkGetVectorMacro(ClosestPoint, double, 3);
174 
179 
181 
184  vtkSetMacro(ColorRegions, vtkTypeBool);
185  vtkGetMacro(ColorRegions, vtkTypeBool);
186  vtkBooleanMacro(ColorRegions, vtkTypeBool);
188 
194  {
197  CELL_COUNT_ASCENDING
198  };
199 
201 
205  vtkSetMacro(RegionIdAssignmentMode, int);
206  vtkGetMacro(RegionIdAssignmentMode, int);
207 
209 
214  vtkSetMacro(OutputPointsPrecision, int);
215  vtkGetMacro(OutputPointsPrecision, int);
217 
218 protected:
221 
224 
225  // Usual data generation method
227  vtkInformationVector* outputVector) override;
230  int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
231 
232  vtkTypeBool ColorRegions; // boolean turns on/off scalar gen for separate regions
233  int ExtractionMode; // how to extract regions
235  vtkIdList* Seeds; // id's of points or cells used to seed regions
236  vtkIdList* SpecifiedRegionIds; // regions specified for extraction
237  vtkIdTypeArray* RegionSizes; // size (in cells) of each region extracted
238 
239  double ClosestPoint[3];
240 
242  double ScalarRange[2];
243 
245 
247 
248  void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
249 
250 private:
251  // used to support algorithm execution
252  vtkFloatArray* CellScalars;
253  vtkIdList* NeighborCellPointIds;
254  vtkIdType* Visited;
255  vtkIdType* PointMap;
256  vtkIdTypeArray* NewScalars;
257  vtkIdTypeArray* NewCellScalars;
258  vtkIdType RegionNumber;
259  vtkIdType PointNumber;
260  vtkIdType NumCellsInRegion;
261  vtkDataArray* InScalars;
262  vtkIdList* Wave;
263  vtkIdList* Wave2;
264  vtkIdList* PointIds;
265  vtkIdList* CellIds;
266 
267 private:
269  void operator=(const vtkConnectivityFilter&) = delete;
270 };
271 
273 
277 {
279  {
280  return "ExtractPointSeededRegions";
281  }
283  {
284  return "ExtractCellSeededRegions";
285  }
287  {
288  return "ExtractSpecifiedRegions";
289  }
290  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
291  {
292  return "ExtractAllRegions";
293  }
295  {
296  return "ExtractClosestPointRegion";
297  }
298  else
299  {
300  return "ExtractLargestRegion";
301  }
302 }
304 
305 #endif
extract data based on geometric connectivity
~vtkConnectivityFilter() override
void TraverseAndMark(vtkDataSet *input)
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 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 InitializeSpecifiedRegionList()
Initialize list of region ids to extract.
int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
This is called by the superclass.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
abstract class to specify dataset behavior
Definition: vtkDataSet.h:57
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
list of point or cell ids
Definition: vtkIdList.h:31
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
Superclass for algorithms that produce output of the same type as input.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
int vtkTypeBool
Definition: vtkABI.h:69
#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:338