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 =========================================================================*/
54 #ifndef vtkEuclideanClusterExtraction_h
55 #define vtkEuclideanClusterExtraction_h
56 
57 #include "vtkFiltersPointsModule.h" // For export macro
58 #include "vtkPolyDataAlgorithm.h"
59 
60 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
61 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
62 #define VTK_EXTRACT_LARGEST_CLUSTER 3
63 #define VTK_EXTRACT_ALL_CLUSTERS 4
64 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
65 
66 class vtkDataArray;
67 class vtkFloatArray;
68 class vtkIdList;
69 class vtkIdTypeArray;
71 
72 
73 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
74 {
75 public:
77  void PrintSelf(ostream& os, vtkIndent indent) override;
78 
83 
85 
88  vtkSetClampMacro(Radius,double,0.0,VTK_FLOAT_MAX);
89  vtkGetMacro(Radius,double);
91 
93 
99  vtkSetMacro(ScalarConnectivity,bool);
100  vtkGetMacro(ScalarConnectivity,bool);
101  vtkBooleanMacro(ScalarConnectivity,bool);
103 
105 
108  vtkSetVector2Macro(ScalarRange,double);
109  vtkGetVector2Macro(ScalarRange,double);
111 
113 
116  vtkSetClampMacro(ExtractionMode,int,
118  vtkGetMacro(ExtractionMode,int);
120  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);};
122  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_CLUSTER);};
124  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);};
126  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);};
128  {this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS);};
129  const char *GetExtractionModeAsString();
131 
135  void InitializeSeedList();
136 
140  void AddSeed(vtkIdType id);
141 
145  void DeleteSeed(vtkIdType id);
146 
150  void InitializeSpecifiedClusterList();
151 
155  void AddSpecifiedCluster(int id);
156 
160  void DeleteSpecifiedCluster(int id);
161 
163 
167  vtkSetVector3Macro(ClosestPoint,double);
168  vtkGetVectorMacro(ClosestPoint,double,3);
170 
174  int GetNumberOfExtractedClusters();
175 
177 
180  vtkSetMacro(ColorClusters,bool);
181  vtkGetMacro(ColorClusters,bool);
182  vtkBooleanMacro(ColorClusters,bool);
184 
186 
191  void SetLocator(vtkAbstractPointLocator *locator);
192  vtkGetObjectMacro(Locator,vtkAbstractPointLocator);
194 
195 protected:
197  ~vtkEuclideanClusterExtraction() override;
198 
199  double Radius; //connection radius
200  bool ColorClusters; //boolean turns on/off scalar gen for separate clusters
201  int ExtractionMode; //how to extract clusters
202  vtkIdList *Seeds; //id's of points or cells used to seed clusters
203  vtkIdList *SpecifiedClusterIds; //clusters specified for extraction
204  vtkIdTypeArray *ClusterSizes; //size (in cells) of each cluster extracted
205 
206  double ClosestPoint[3];
207 
209  double ScalarRange[2];
210 
212 
213  // Configure the pipeline
215  vtkInformationVector *) override;
216  int FillInputPortInformation(int port, vtkInformation *info) override;
217 
218  // Internal method for propagating connected waves.
219  void InsertIntoWave(vtkIdList *wave, vtkIdType ptId);
220  void TraverseAndMark(vtkPoints *pts);
221 
222 private:
224  void operator=(const vtkEuclideanClusterExtraction&) = delete;
225 
226  // used to support algorithm execution
227  vtkFloatArray *NeighborScalars;
228  vtkIdList *NeighborPointIds;
229  char *Visited;
230  vtkIdType *PointMap;
231  vtkIdTypeArray *NewScalars;
232  vtkIdType ClusterNumber;
233  vtkIdType PointNumber;
234  vtkIdType NumPointsInCluster;
235  vtkDataArray *InScalars;
236  vtkIdList *Wave;
237  vtkIdList *Wave2;
238  vtkIdList *PointIds;
239 
240 };
241 
243 
247 {
248  if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_CLUSTERS )
249  {
250  return "ExtractPointSeededClusters";
251  }
252  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_CLUSTERS )
253  {
254  return "ExtractSpecifiedClusters";
255  }
256  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS )
257  {
258  return "ExtractAllClusters";
259  }
260  else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_CLUSTER )
261  {
262  return "ExtractClosestPointCluster";
263  }
264  else
265  {
266  return "ExtractLargestCluster";
267  }
268 }
270 
271 #endif
void SetExtractionModeToAllClusters()
Control the extraction of connected surfaces.
Store vtkAlgorithm input/output information.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
void SetExtractionModeToSpecifiedClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:347
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:167
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract class to quickly locate points in 3-space
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
list of point or cell ids
Definition: vtkIdList.h:36
#define VTK_EXTRACT_LARGEST_CLUSTER
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
void SetExtractionModeToClosestPointCluster()
Control the extraction of connected surfaces.
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
void SetExtractionModeToLargestCluster()
Control the extraction of connected surfaces.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
represent and manipulate 3D points
Definition: vtkPoints.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_EXTRACT_ALL_CLUSTERS