VTK  9.2.6
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 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
73 {
74 public:
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
82 
84 
87  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
88  vtkGetMacro(Radius, double);
90 
92 
98  vtkSetMacro(ScalarConnectivity, bool);
99  vtkGetMacro(ScalarConnectivity, bool);
100  vtkBooleanMacro(ScalarConnectivity, bool);
102 
104 
107  vtkSetVector2Macro(ScalarRange, double);
108  vtkGetVector2Macro(ScalarRange, double);
110 
112 
115  vtkSetClampMacro(
117  vtkGetMacro(ExtractionMode, int);
119  {
120  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
121  }
124  {
125  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
126  }
128  {
129  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
130  }
131  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
132  const char* GetExtractionModeAsString();
134 
138  void InitializeSeedList();
139 
143  void AddSeed(vtkIdType id);
144 
148  void DeleteSeed(vtkIdType id);
149 
153  void InitializeSpecifiedClusterList();
154 
158  void AddSpecifiedCluster(int id);
159 
163  void DeleteSpecifiedCluster(int id);
164 
166 
170  vtkSetVector3Macro(ClosestPoint, double);
171  vtkGetVectorMacro(ClosestPoint, double, 3);
173 
177  int GetNumberOfExtractedClusters();
178 
180 
183  vtkSetMacro(ColorClusters, bool);
184  vtkGetMacro(ColorClusters, bool);
185  vtkBooleanMacro(ColorClusters, bool);
187 
189 
194  void SetLocator(vtkAbstractPointLocator* locator);
195  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
197 
198 protected:
200  ~vtkEuclideanClusterExtraction() override;
201 
202  double Radius; // connection radius
203  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
204  int ExtractionMode; // how to extract clusters
205  vtkIdList* Seeds; // id's of points or cells used to seed clusters
206  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
207  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
208 
209  double ClosestPoint[3];
210 
212  double ScalarRange[2];
213 
215 
216  // Configure the pipeline
218  int FillInputPortInformation(int port, vtkInformation* info) override;
219 
220  // Internal method for propagating connected waves.
221  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
222  void TraverseAndMark(vtkPoints* pts);
223 
224 private:
226  void operator=(const vtkEuclideanClusterExtraction&) = delete;
227 
228  // used to support algorithm execution
229  vtkFloatArray* NeighborScalars;
230  vtkIdList* NeighborPointIds;
231  char* Visited;
232  vtkIdType* PointMap;
233  vtkIdTypeArray* NewScalars;
234  vtkIdType ClusterNumber;
235  vtkIdType PointNumber;
236  vtkIdType NumPointsInCluster;
237  vtkDataArray* InScalars;
238  vtkIdList* Wave;
239  vtkIdList* Wave2;
240  vtkIdList* PointIds;
241 };
242 
247 {
249  {
250  return "ExtractPointSeededClusters";
251  }
253  {
254  return "ExtractSpecifiedClusters";
255  }
256  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
257  {
258  return "ExtractAllClusters";
259  }
261  {
262  return "ExtractClosestPointCluster";
263  }
264  else
265  {
266  return "ExtractLargestCluster";
267  }
268 }
269 
270 #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:332
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:163
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:33
#define VTK_EXTRACT_LARGEST_CLUSTER
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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