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 =========================================================================*/
56 #ifndef vtkConnectivityFilter_h
57 #define vtkConnectivityFilter_h
58 
59 #include "vtkFiltersCoreModule.h" // For export macro
61 
62 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
63 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
64 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
65 #define VTK_EXTRACT_LARGEST_REGION 4
66 #define VTK_EXTRACT_ALL_REGIONS 5
67 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
68 
69 class vtkDataArray;
70 class vtkFloatArray;
71 class vtkIdList;
72 class vtkIdTypeArray;
73 class vtkIntArray;
74 
75 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkUnstructuredGridAlgorithm
76 {
77 public:
79  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
80 
84  static vtkConnectivityFilter *New();
85 
87 
92  vtkSetMacro(ScalarConnectivity,int);
93  vtkGetMacro(ScalarConnectivity,int);
94  vtkBooleanMacro(ScalarConnectivity,int);
96 
98 
101  vtkSetVector2Macro(ScalarRange,double);
102  vtkGetVector2Macro(ScalarRange,double);
104 
106 
109  vtkSetClampMacro(ExtractionMode,int,
111  vtkGetMacro(ExtractionMode,int);
113  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
115  {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
117  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
119  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
121  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
123  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
124  const char *GetExtractionModeAsString();
126 
130  void InitializeSeedList();
131 
135  void AddSeed(vtkIdType id);
136 
140  void DeleteSeed(vtkIdType id);
141 
145  void InitializeSpecifiedRegionList();
146 
150  void AddSpecifiedRegion(int id);
151 
155  void DeleteSpecifiedRegion(int id);
156 
158 
162  vtkSetVector3Macro(ClosestPoint,double);
163  vtkGetVectorMacro(ClosestPoint,double,3);
165 
169  int GetNumberOfExtractedRegions();
170 
172 
175  vtkSetMacro(ColorRegions,int);
176  vtkGetMacro(ColorRegions,int);
177  vtkBooleanMacro(ColorRegions,int);
179 
181 
186  vtkSetMacro(OutputPointsPrecision,int);
187  vtkGetMacro(OutputPointsPrecision,int);
189 
190 protected:
192  ~vtkConnectivityFilter() VTK_OVERRIDE;
193 
194  // Usual data generation method
195  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
196  int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
197 
198  int ColorRegions; //boolean turns on/off scalar gen for separate regions
199  int ExtractionMode; //how to extract regions
200  int OutputPointsPrecision;
201  vtkIdList *Seeds; //id's of points or cells used to seed regions
202  vtkIdList *SpecifiedRegionIds; //regions specified for extraction
203  vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
204 
205  double ClosestPoint[3];
206 
207  int ScalarConnectivity;
208  double ScalarRange[2];
209 
210  void TraverseAndMark(vtkDataSet *input);
211 
212 private:
213  // used to support algorithm execution
214  vtkFloatArray *CellScalars;
215  vtkIdList *NeighborCellPointIds;
216  vtkIdType *Visited;
217  vtkIdType *PointMap;
218  vtkIdTypeArray *NewScalars;
219  vtkIdTypeArray *NewCellScalars;
220  vtkIdType RegionNumber;
221  vtkIdType PointNumber;
222  vtkIdType NumCellsInRegion;
223  vtkDataArray *InScalars;
224  vtkIdList *Wave;
225  vtkIdList *Wave2;
226  vtkIdList *PointIds;
227  vtkIdList *CellIds;
228 private:
229  vtkConnectivityFilter(const vtkConnectivityFilter&) VTK_DELETE_FUNCTION;
230  void operator=(const vtkConnectivityFilter&) VTK_DELETE_FUNCTION;
231 };
232 
234 
237 inline const char *vtkConnectivityFilter::GetExtractionModeAsString(void)
238 {
239  if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS )
240  {
241  return "ExtractPointSeededRegions";
242  }
243  else if ( this->ExtractionMode == VTK_EXTRACT_CELL_SEEDED_REGIONS )
244  {
245  return "ExtractCellSeededRegions";
246  }
247  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
248  {
249  return "ExtractSpecifiedRegions";
250  }
251  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
252  {
253  return "ExtractAllRegions";
254  }
255  else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION )
256  {
257  return "ExtractClosestPointRegion";
258  }
259  else
260  {
261  return "ExtractLargestRegion";
262  }
263 }
265 
266 #endif
267 
268 
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
Store vtkAlgorithm input/output information.
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
extract data based on geometric connectivity
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
static vtkUnstructuredGridAlgorithm * New()
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
#define VTK_EXTRACT_LARGEST_REGION
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:287
#define VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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 only unstructured grid as output.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
#define VTK_EXTRACT_ALL_REGIONS
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.