VTK  9.1.0
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 
276 {
278  {
279  return "ExtractPointSeededRegions";
280  }
282  {
283  return "ExtractCellSeededRegions";
284  }
286  {
287  return "ExtractSpecifiedRegions";
288  }
289  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
290  {
291  return "ExtractAllRegions";
292  }
294  {
295  return "ExtractClosestPointRegion";
296  }
297  else
298  {
299  return "ExtractLargestRegion";
300  }
301 }
302 
303 #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: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:86
@ 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:332