VTK
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 =========================================================================*/
63 #ifndef vtkConnectivityFilter_h
64 #define vtkConnectivityFilter_h
65 
66 #include "vtkFiltersCoreModule.h" // For export macro
67 #include "vtkPointSetAlgorithm.h"
68 
69 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
70 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
71 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
72 #define VTK_EXTRACT_LARGEST_REGION 4
73 #define VTK_EXTRACT_ALL_REGIONS 5
74 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
75 
76 class vtkDataArray;
77 class vtkDataSet;
78 class vtkFloatArray;
79 class vtkIdList;
80 class vtkIdTypeArray;
81 class vtkIntArray;
82 class vtkPolyData;
83 
84 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
85 {
86 public:
88  void PrintSelf(ostream& os, vtkIndent indent) override;
89 
93  static vtkConnectivityFilter *New();
94 
96 
101  vtkSetMacro(ScalarConnectivity,vtkTypeBool);
102  vtkGetMacro(ScalarConnectivity,vtkTypeBool);
103  vtkBooleanMacro(ScalarConnectivity,vtkTypeBool);
105 
107 
110  vtkSetVector2Macro(ScalarRange,double);
111  vtkGetVector2Macro(ScalarRange,double);
113 
115 
118  vtkSetClampMacro(ExtractionMode,int,
120  vtkGetMacro(ExtractionMode,int);
122  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
124  {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
126  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
128  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
130  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
132  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
133  const char *GetExtractionModeAsString();
135 
139  void InitializeSeedList();
140 
144  void AddSeed(vtkIdType id);
145 
149  void DeleteSeed(vtkIdType id);
150 
154  void InitializeSpecifiedRegionList();
155 
159  void AddSpecifiedRegion(int id);
160 
164  void DeleteSpecifiedRegion(int id);
165 
167 
171  vtkSetVector3Macro(ClosestPoint,double);
172  vtkGetVectorMacro(ClosestPoint,double,3);
174 
178  int GetNumberOfExtractedRegions();
179 
181 
184  vtkSetMacro(ColorRegions,vtkTypeBool);
185  vtkGetMacro(ColorRegions,vtkTypeBool);
186  vtkBooleanMacro(ColorRegions,vtkTypeBool);
188 
196  CELL_COUNT_ASCENDING
197  };
198 
200 
204  vtkSetMacro(RegionIdAssignmentMode, int);
205  vtkGetMacro(RegionIdAssignmentMode, int);
206 
208 
213  vtkSetMacro(OutputPointsPrecision,int);
214  vtkGetMacro(OutputPointsPrecision,int);
216 
218 
219 protected:
221  ~vtkConnectivityFilter() override;
222 
223  // Usual data generation method
224  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
225  vtkInformationVector* outputVector) override;
227  int FillInputPortInformation(int port, vtkInformation *info) override;
228  int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
229 
230  vtkTypeBool ColorRegions; //boolean turns on/off scalar gen for separate regions
231  int ExtractionMode; //how to extract regions
233  vtkIdList *Seeds; //id's of points or cells used to seed regions
234  vtkIdList *SpecifiedRegionIds; //regions specified for extraction
235  vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
236 
237  double ClosestPoint[3];
238 
240  double ScalarRange[2];
241 
243 
244  void TraverseAndMark(vtkDataSet *input);
245 
246  void OrderRegionIds(vtkIdTypeArray* pointRegionIds, vtkIdTypeArray* cellRegionIds);
247 
248 private:
249  // used to support algorithm execution
250  vtkFloatArray *CellScalars;
251  vtkIdList *NeighborCellPointIds;
252  vtkIdType *Visited;
253  vtkIdType *PointMap;
254  vtkIdTypeArray *NewScalars;
255  vtkIdTypeArray *NewCellScalars;
256  vtkIdType RegionNumber;
257  vtkIdType PointNumber;
258  vtkIdType NumCellsInRegion;
259  vtkDataArray *InScalars;
260  vtkIdList *Wave;
261  vtkIdList *Wave2;
262  vtkIdList *PointIds;
263  vtkIdList *CellIds;
264 private:
266  void operator=(const vtkConnectivityFilter&) = delete;
267 };
268 
270 
274 {
275  if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS )
276  {
277  return "ExtractPointSeededRegions";
278  }
279  else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS )
280  {
281  return "ExtractCellSeededRegions";
282  }
283  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
284  {
285  return "ExtractSpecifiedRegions";
286  }
287  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
288  {
289  return "ExtractAllRegions";
290  }
291  else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION )
292  {
293  return "ExtractClosestPointRegion";
294  }
295  else
296  {
297  return "ExtractLargestRegion";
298  }
299 }
301 
302 #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.
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:62
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
see vtkAlgorithm for details
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:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_EXTRACT_LARGEST_REGION
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
#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:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
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:39
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_CLOSEST_POINT_REGION
list of point or cell ids
Definition: vtkIdList.h:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
Superclass for algorithms that produce output of the same type as input.
RegionIdAssignment
Enumeration of the various ways to assign RegionIds when the ColorRegions option is on...
#define VTK_EXTRACT_ALL_REGIONS
static vtkPointSetAlgorithm * New()
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
Store zero or more vtkInformation instances.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.