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 =========================================================================*/
52 #ifndef vtkConnectivityFilter_h
53 #define vtkConnectivityFilter_h
54 
55 #include "vtkFiltersCoreModule.h" // For export macro
56 #include "vtkPointSetAlgorithm.h"
57 
58 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
59 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
60 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
61 #define VTK_EXTRACT_LARGEST_REGION 4
62 #define VTK_EXTRACT_ALL_REGIONS 5
63 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
64 
65 class vtkDataArray;
66 class vtkDataSet;
67 class vtkFloatArray;
68 class vtkIdList;
69 class vtkIdTypeArray;
70 class vtkIntArray;
71 class vtkPolyData;
72 
73 class VTKFILTERSCORE_EXPORT vtkConnectivityFilter : public vtkPointSetAlgorithm
74 {
75 public:
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
82  static vtkConnectivityFilter *New();
83 
85 
90  vtkSetMacro(ScalarConnectivity,vtkTypeBool);
91  vtkGetMacro(ScalarConnectivity,vtkTypeBool);
92  vtkBooleanMacro(ScalarConnectivity,vtkTypeBool);
94 
96 
99  vtkSetVector2Macro(ScalarRange,double);
100  vtkGetVector2Macro(ScalarRange,double);
102 
104 
107  vtkSetClampMacro(ExtractionMode,int,
109  vtkGetMacro(ExtractionMode,int);
111  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
113  {this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);};
115  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
117  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
119  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
121  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
122  const char *GetExtractionModeAsString();
124 
128  void InitializeSeedList();
129 
133  void AddSeed(vtkIdType id);
134 
138  void DeleteSeed(vtkIdType id);
139 
143  void InitializeSpecifiedRegionList();
144 
148  void AddSpecifiedRegion(int id);
149 
153  void DeleteSpecifiedRegion(int id);
154 
156 
160  vtkSetVector3Macro(ClosestPoint,double);
161  vtkGetVectorMacro(ClosestPoint,double,3);
163 
167  int GetNumberOfExtractedRegions();
168 
170 
173  vtkSetMacro(ColorRegions,vtkTypeBool);
174  vtkGetMacro(ColorRegions,vtkTypeBool);
175  vtkBooleanMacro(ColorRegions,vtkTypeBool);
177 
179 
184  vtkSetMacro(OutputPointsPrecision,int);
185  vtkGetMacro(OutputPointsPrecision,int);
187 
189 
190 protected:
192  ~vtkConnectivityFilter() override;
193 
194  // Usual data generation method
195  int RequestDataObject(vtkInformation* request, vtkInformationVector** inputVector,
196  vtkInformationVector* outputVector) override;
198  int FillInputPortInformation(int port, vtkInformation *info) override;
199  int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) override;
200 
201  vtkTypeBool ColorRegions; //boolean turns on/off scalar gen for separate regions
202  int ExtractionMode; //how to extract regions
204  vtkIdList *Seeds; //id's of points or cells used to seed regions
205  vtkIdList *SpecifiedRegionIds; //regions specified for extraction
206  vtkIdTypeArray *RegionSizes; //size (in cells) of each region extracted
207 
208  double ClosestPoint[3];
209 
211  double ScalarRange[2];
212 
213  void TraverseAndMark(vtkDataSet *input);
214 
215 private:
216  // used to support algorithm execution
217  vtkFloatArray *CellScalars;
218  vtkIdList *NeighborCellPointIds;
219  vtkIdType *Visited;
220  vtkIdType *PointMap;
221  vtkIdTypeArray *NewScalars;
222  vtkIdTypeArray *NewCellScalars;
223  vtkIdType RegionNumber;
224  vtkIdType PointNumber;
225  vtkIdType NumCellsInRegion;
226  vtkDataArray *InScalars;
227  vtkIdList *Wave;
228  vtkIdList *Wave2;
229  vtkIdList *PointIds;
230  vtkIdList *CellIds;
231 private:
233  void operator=(const vtkConnectivityFilter&) = delete;
234 };
235 
237 
241 {
243  {
244  return "ExtractPointSeededRegions";
245  }
247  {
248  return "ExtractCellSeededRegions";
249  }
250  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
251  {
252  return "ExtractSpecifiedRegions";
253  }
254  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
255  {
256  return "ExtractAllRegions";
257  }
259  {
260  return "ExtractClosestPointRegion";
261  }
262  else
263  {
264  return "ExtractLargestRegion";
265  }
266 }
268 
269 #endif
270 
271 
vtkConnectivityFilter::GetExtractionModeAsString
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
Definition: vtkConnectivityFilter.h:240
vtkConnectivityFilter::RegionSizes
vtkIdTypeArray * RegionSizes
Definition: vtkConnectivityFilter.h:206
vtkConnectivityFilter::SpecifiedRegionIds
vtkIdList * SpecifiedRegionIds
Definition: vtkConnectivityFilter.h:205
vtkPointSetAlgorithm
Superclass for algorithms that produce output of the same type as input.
Definition: vtkPointSetAlgorithm.h:43
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkConnectivityFilter
extract data based on geometric connectivity
Definition: vtkConnectivityFilter.h:73
VTK_EXTRACT_LARGEST_REGION
#define VTK_EXTRACT_LARGEST_REGION
Definition: vtkConnectivityFilter.h:61
vtkPointSetAlgorithm.h
vtkConnectivityFilter::SetExtractionModeToCellSeededRegions
void SetExtractionModeToCellSeededRegions()
Definition: vtkConnectivityFilter.h:112
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
Definition: vtkConnectivityFilter.h:60
vtkConnectivityFilter::ScalarConnectivity
vtkTypeBool ScalarConnectivity
Definition: vtkConnectivityFilter.h:210
vtkConnectivityFilter::ColorRegions
vtkTypeBool ColorRegions
Definition: vtkConnectivityFilter.h:201
vtkConnectivityFilter::ExtractionMode
int ExtractionMode
Definition: vtkConnectivityFilter.h:202
vtkX3D::port
Definition: vtkX3D.h:447
vtkConnectivityFilter::OutputPointsPrecision
int OutputPointsPrecision
Definition: vtkConnectivityFilter.h:203
vtkPointSetAlgorithm::RequestData
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Definition: vtkPointSetAlgorithm.h:132
VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_CLOSEST_POINT_REGION
Definition: vtkConnectivityFilter.h:63
vtkPointSetAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPointSetAlgorithm::FillOutputPortInformation
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:59
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkConnectivityFilter::SetExtractionModeToSpecifiedRegions
void SetExtractionModeToSpecifiedRegions()
Definition: vtkConnectivityFilter.h:116
VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
Definition: vtkConnectivityFilter.h:58
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkConnectivityFilter::Seeds
vtkIdList * Seeds
Definition: vtkConnectivityFilter.h:204
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkPointSetAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkX3D::info
Definition: vtkX3D.h:376
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:35
vtkConnectivityFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Definition: vtkConnectivityFilter.h:120
vtkConnectivityFilter::SetExtractionModeToClosestPointRegion
void SetExtractionModeToClosestPointRegion()
Definition: vtkConnectivityFilter.h:118
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
Definition: vtkConnectivityFilter.h:62
vtkConnectivityFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Definition: vtkConnectivityFilter.h:114
vtkPointSetAlgorithm::New
static vtkPointSetAlgorithm * New()
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkConnectivityFilter::SetExtractionModeToPointSeededRegions
void SetExtractionModeToPointSeededRegions()
Definition: vtkConnectivityFilter.h:110
vtkPointSetAlgorithm::ProcessRequest
int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
see vtkAlgorithm for details
vtkPointSetAlgorithm::RequestDataObject
virtual int RequestDataObject(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.