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 
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkConnectivityFilter
extract data based on geometric connectivity
Definition: vtkConnectivityFilter.h:75
VTK_EXTRACT_LARGEST_REGION
#define VTK_EXTRACT_LARGEST_REGION
Definition: vtkConnectivityFilter.h:65
vtkConnectivityFilter::SetExtractionModeToCellSeededRegions
void SetExtractionModeToCellSeededRegions()
Definition: vtkConnectivityFilter.h:114
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
Definition: vtkConnectivityFilter.h:64
vtkX3D::port
Definition: vtkX3D.h:447
VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_CLOSEST_POINT_REGION
Definition: vtkConnectivityFilter.h:67
VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:63
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkConnectivityFilter::SetExtractionModeToSpecifiedRegions
void SetExtractionModeToSpecifiedRegions()
Definition: vtkConnectivityFilter.h:118
VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:62
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:86
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkX3D::info
Definition: vtkX3D.h:376
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:41
vtkConnectivityFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Definition: vtkConnectivityFilter.h:122
vtkUnstructuredGridAlgorithm::New
static vtkUnstructuredGridAlgorithm * New()
vtkConnectivityFilter::SetExtractionModeToClosestPointRegion
void SetExtractionModeToClosestPointRegion()
Definition: vtkConnectivityFilter.h:120
vtkUnstructuredGridAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnstructuredGridAlgorithm.h
VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
Definition: vtkConnectivityFilter.h:66
vtkUnstructuredGridAlgorithm
Superclass for algorithms that produce only unstructured grid as output.
Definition: vtkUnstructuredGridAlgorithm.h:40
vtkConnectivityFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Definition: vtkConnectivityFilter.h:116
vtkConnectivityFilter::SetExtractionModeToPointSeededRegions
void SetExtractionModeToPointSeededRegions()
Definition: vtkConnectivityFilter.h:112