VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 =========================================================================*/
55 #ifndef __vtkConnectivityFilter_h
56 #define __vtkConnectivityFilter_h
57 
58 #include "vtkFiltersCoreModule.h" // For export macro
59 #include "vtkUnstructuredGridAlgorithm.h"
60 
61 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
62 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
63 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
64 #define VTK_EXTRACT_LARGEST_REGION 4
65 #define VTK_EXTRACT_ALL_REGIONS 5
66 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
67 
68 class vtkDataArray;
69 class vtkFloatArray;
70 class vtkIdList;
71 class vtkIdTypeArray;
72 class vtkIntArray;
73 
74 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkUnstructuredGridAlgorithm
75 {
76 public:
77  vtkTypeMacro(vtkConnectivityFilter,vtkUnstructuredGridAlgorithm);
78  void PrintSelf(ostream& os, vtkIndent indent);
79 
81  static vtkConnectivityFilter *New();
82 
84 
87  vtkSetMacro(ScalarConnectivity,int);
88  vtkGetMacro(ScalarConnectivity,int);
89  vtkBooleanMacro(ScalarConnectivity,int);
91 
93 
95  vtkSetVector2Macro(ScalarRange,double);
96  vtkGetVector2Macro(ScalarRange,double);
98 
100 
101  vtkSetClampMacro(ExtractionMode,int,
103  vtkGetMacro(ExtractionMode,int);
105  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
107  {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
109  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
111  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
113  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
115  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
116  const char *GetExtractionModeAsString();
118 
120  void InitializeSeedList();
121 
123  void AddSeed(vtkIdType id);
124 
126  void DeleteSeed(vtkIdType id);
127 
129  void InitializeSpecifiedRegionList();
130 
132  void AddSpecifiedRegion(int id);
133 
135  void DeleteSpecifiedRegion(int id);
136 
138 
140  vtkSetVector3Macro(ClosestPoint,double);
141  vtkGetVectorMacro(ClosestPoint,double,3);
143 
145  int GetNumberOfExtractedRegions();
146 
148 
149  vtkSetMacro(ColorRegions,int);
150  vtkGetMacro(ColorRegions,int);
151  vtkBooleanMacro(ColorRegions,int);
153 
154 protected:
157 
158  // Usual data generation method
159  virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
160  virtual int FillInputPortInformation(int port, vtkInformation *info);
161 
162  int ColorRegions; //boolean turns on/off scalar gen for separate regions
163  int ExtractionMode; //how to extract regions
164  vtkIdList *Seeds; //id's of points or cells used to seed regions
165  vtkIdList *SpecifiedRegionIds; //regions specified for extraction
166  vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
167 
168  double ClosestPoint[3];
169 
171  double ScalarRange[2];
172 
173  void TraverseAndMark(vtkDataSet *input);
174 
175 private:
176  // used to support algorithm execution
177  vtkFloatArray *CellScalars;
178  vtkIdList *NeighborCellPointIds;
179  vtkIdType *Visited;
180  vtkIdType *PointMap;
181  vtkIdTypeArray *NewScalars;
182  vtkIdTypeArray *NewCellScalars;
183  vtkIdType RegionNumber;
184  vtkIdType PointNumber;
185  vtkIdType NumCellsInRegion;
186  vtkDataArray *InScalars;
187  vtkIdList *Wave;
188  vtkIdList *Wave2;
189  vtkIdList *PointIds;
190  vtkIdList *CellIds;
191 private:
192  vtkConnectivityFilter(const vtkConnectivityFilter&); // Not implemented.
193  void operator=(const vtkConnectivityFilter&); // Not implemented.
194 };
195 
197 
199 {
201  {
202  return "ExtractPointSeededRegions";
203  }
205  {
206  return "ExtractCellSeededRegions";
207  }
208  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
209  {
210  return "ExtractSpecifiedRegions";
211  }
212  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
213  {
214  return "ExtractAllRegions";
215  }
217  {
218  return "ExtractClosestPointRegion";
219  }
220  else
221  {
222  return "ExtractLargestRegion";
223  }
224 }
226 
227 #endif
228 
229 
extract data based on geometric connectivity
const char * GetExtractionModeAsString()
#define VTK_EXTRACT_LARGEST_REGION
#define VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_ALL_REGIONS