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 =========================================================================*/
58 #ifndef vtkConnectivityFilter_h
59 #define vtkConnectivityFilter_h
60 
61 #include "vtkFiltersCoreModule.h" // For export macro
62 #include "vtkPointSetAlgorithm.h"
63 
64 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
65 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
66 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
67 #define VTK_EXTRACT_LARGEST_REGION 4
68 #define VTK_EXTRACT_ALL_REGIONS 5
69 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
70 
71 class vtkDataArray;
72 class vtkDataSet;
73 class vtkFloatArray;
74 class vtkIdList;
75 class vtkIdTypeArray;
76 class vtkIntArray;
77 class vtkPolyData;
78 
79 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
80 {
81 public:
83  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
88  static vtkConnectivityFilter *New();
89 
91 
96  vtkSetMacro(ScalarConnectivity,vtkTypeBool);
97  vtkGetMacro(ScalarConnectivity,vtkTypeBool);
98  vtkBooleanMacro(ScalarConnectivity,vtkTypeBool);
100 
102 
105  vtkSetVector2Macro(ScalarRange,double);
106  vtkGetVector2Macro(ScalarRange,double);
108 
110 
113  vtkSetClampMacro(ExtractionMode,int,
115  vtkGetMacro(ExtractionMode,int);
117  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
119  {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
121  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
123  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
125  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
127  {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 
185 
190  vtkSetMacro(OutputPointsPrecision,int);
191  vtkGetMacro(OutputPointsPrecision,int);
193 
195 
196 protected:
198  ~vtkConnectivityFilter() override;
199 
200  // Usual data generation method
201  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
202  vtkInformationVector* outputVector) override;
204  int FillInputPortInformation(int port, vtkInformation *info) override;
205  int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
206 
207  vtkTypeBool ColorRegions; //boolean turns on/off scalar gen for separate regions
208  int ExtractionMode; //how to extract regions
210  vtkIdList *Seeds; //id's of points or cells used to seed regions
211  vtkIdList *SpecifiedRegionIds; //regions specified for extraction
212  vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
213 
214  double ClosestPoint[3];
215 
217  double ScalarRange[2];
218 
219  void TraverseAndMark(vtkDataSet *input);
220 
221 private:
222  // used to support algorithm execution
223  vtkFloatArray *CellScalars;
224  vtkIdList *NeighborCellPointIds;
225  vtkIdType *Visited;
226  vtkIdType *PointMap;
227  vtkIdTypeArray *NewScalars;
228  vtkIdTypeArray *NewCellScalars;
229  vtkIdType RegionNumber;
230  vtkIdType PointNumber;
231  vtkIdType NumCellsInRegion;
232  vtkDataArray *InScalars;
233  vtkIdList *Wave;
234  vtkIdList *Wave2;
235  vtkIdList *PointIds;
236  vtkIdList *CellIds;
237 private:
239  void operator=(const vtkConnectivityFilter&) = delete;
240 };
241 
243 
247 {
249  {
250  return "ExtractPointSeededRegions";
251  }
253  {
254  return "ExtractCellSeededRegions";
255  }
256  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
257  {
258  return "ExtractSpecifiedRegions";
259  }
260  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
261  {
262  return "ExtractAllRegions";
263  }
265  {
266  return "ExtractClosestPointRegion";
267  }
268  else
269  {
270  return "ExtractLargestRegion";
271  }
272 }
274 
275 #endif
276 
277 
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:345
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.
#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.