VTK
vtkEuclideanClusterExtraction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkEuclideanClusterExtraction.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See LICENSE file 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 =========================================================================*/
51 #ifndef vtkEuclideanClusterExtraction_h
52 #define vtkEuclideanClusterExtraction_h
53 
54 #include "vtkFiltersPointsModule.h" // For export macro
55 #include "vtkPolyDataAlgorithm.h"
56 
57 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
58 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
59 #define VTK_EXTRACT_LARGEST_CLUSTER 3
60 #define VTK_EXTRACT_ALL_CLUSTERS 4
61 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
62 
63 class vtkDataArray;
64 class vtkFloatArray;
65 class vtkIdList;
66 class vtkIdTypeArray;
68 
69 
70 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
71 {
72 public:
74  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
75 
80 
82 
85  vtkSetClampMacro(Radius,double,0.0,VTK_FLOAT_MAX);
86  vtkGetMacro(Radius,double);
88 
90 
96  vtkSetMacro(ScalarConnectivity,bool);
97  vtkGetMacro(ScalarConnectivity,bool);
98  vtkBooleanMacro(ScalarConnectivity,bool);
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_CLUSTERS);};
119  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_CLUSTER);};
121  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);};
123  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);};
125  {this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS);};
126  const char *GetExtractionModeAsString();
128 
132  void InitializeSeedList();
133 
137  void AddSeed(vtkIdType id);
138 
142  void DeleteSeed(vtkIdType id);
143 
147  void InitializeSpecifiedClusterList();
148 
152  void AddSpecifiedCluster(int id);
153 
157  void DeleteSpecifiedCluster(int id);
158 
160 
164  vtkSetVector3Macro(ClosestPoint,double);
165  vtkGetVectorMacro(ClosestPoint,double,3);
167 
171  int GetNumberOfExtractedClusters();
172 
174 
177  vtkSetMacro(ColorClusters,bool);
178  vtkGetMacro(ColorClusters,bool);
179  vtkBooleanMacro(ColorClusters,bool);
181 
183 
188  void SetLocator(vtkAbstractPointLocator *locator);
189  vtkGetObjectMacro(Locator,vtkAbstractPointLocator);
191 
192 protected:
194  ~vtkEuclideanClusterExtraction() VTK_OVERRIDE;
195 
196  double Radius; //connection radius
197  bool ColorClusters; //boolean turns on/off scalar gen for separate clusters
198  int ExtractionMode; //how to extract clusters
199  vtkIdList *Seeds; //id's of points or cells used to seed clusters
200  vtkIdList *SpecifiedClusterIds; //clusters specified for extraction
201  vtkIdTypeArray *ClusterSizes; //size (in cells) of each cluster extracted
202 
203  double ClosestPoint[3];
204 
205  bool ScalarConnectivity;
206  double ScalarRange[2];
207 
209 
210  // Configure the pipeline
211  int RequestData(vtkInformation *, vtkInformationVector **,
212  vtkInformationVector *) VTK_OVERRIDE;
213  int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
214 
215  // Internal method for propagating connected waves.
216  void InsertIntoWave(vtkIdList *wave, vtkIdType ptId);
217  void TraverseAndMark(vtkPoints *pts);
218 
219 private:
221  void operator=(const vtkEuclideanClusterExtraction&) VTK_DELETE_FUNCTION;
222 
223  // used to support algorithm execution
224  vtkFloatArray *NeighborScalars;
225  vtkIdList *NeighborPointIds;
226  char *Visited;
227  vtkIdType *PointMap;
228  vtkIdTypeArray *NewScalars;
229  vtkIdType ClusterNumber;
230  vtkIdType PointNumber;
231  vtkIdType NumPointsInCluster;
232  vtkDataArray *InScalars;
233  vtkIdList *Wave;
234  vtkIdList *Wave2;
235  vtkIdList *PointIds;
236 
237 };
238 
240 
243 inline const char *vtkEuclideanClusterExtraction::GetExtractionModeAsString(void)
244 {
245  if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_CLUSTERS )
246  {
247  return "ExtractPointSeededClusters";
248  }
249  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_CLUSTERS )
250  {
251  return "ExtractSpecifiedClusters";
252  }
253  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS )
254  {
255  return "ExtractAllClusters";
256  }
257  else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_CLUSTER )
258  {
259  return "ExtractClosestPointCluster";
260  }
261  else
262  {
263  return "ExtractLargestCluster";
264  }
265 }
267 
268 #endif
void SetExtractionModeToAllClusters()
Control the extraction of connected surfaces.
Store vtkAlgorithm input/output information.
void SetExtractionModeToSpecifiedClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:345
perform segmentation based on geometric proximity and optional scalar threshold
#define VTK_EXTRACT_POINT_SEEDED_CLUSTERS
static vtkPolyDataAlgorithm * New()
#define VTK_FLOAT_MAX
Definition: vtkType.h:165
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
abstract class to quickly locate points in 3-space
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
list of point or cell ids
Definition: vtkIdList.h:30
#define VTK_EXTRACT_LARGEST_CLUSTER
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
void SetExtractionModeToClosestPointCluster()
Control the extraction of connected surfaces.
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetExtractionModeToLargestCluster()
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.
represent and manipulate 3D points
Definition: vtkPoints.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_EXTRACT_ALL_CLUSTERS