VTK  9.3.1
vtkEuclideanClusterExtraction.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-CLAUSE
42 #ifndef vtkEuclideanClusterExtraction_h
43 #define vtkEuclideanClusterExtraction_h
44 
45 #include "vtkFiltersPointsModule.h" // For export macro
46 #include "vtkPolyDataAlgorithm.h"
47 
48 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
49 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
50 #define VTK_EXTRACT_LARGEST_CLUSTER 3
51 #define VTK_EXTRACT_ALL_CLUSTERS 4
52 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
53 
54 VTK_ABI_NAMESPACE_BEGIN
55 class vtkDataArray;
56 class vtkFloatArray;
57 class vtkIdList;
58 class vtkIdTypeArray;
60 
61 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
62 {
63 public:
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
71 
73 
76  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
77  vtkGetMacro(Radius, double);
79 
81 
87  vtkSetMacro(ScalarConnectivity, bool);
88  vtkGetMacro(ScalarConnectivity, bool);
89  vtkBooleanMacro(ScalarConnectivity, bool);
91 
93 
96  vtkSetVector2Macro(ScalarRange, double);
97  vtkGetVector2Macro(ScalarRange, double);
99 
101 
104  vtkSetClampMacro(
106  vtkGetMacro(ExtractionMode, int);
108  {
109  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
110  }
113  {
114  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
115  }
117  {
118  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
119  }
120  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
121  const char* GetExtractionModeAsString();
123 
127  void InitializeSeedList();
128 
132  void AddSeed(vtkIdType id);
133 
137  void DeleteSeed(vtkIdType id);
138 
142  void InitializeSpecifiedClusterList();
143 
147  void AddSpecifiedCluster(int id);
148 
152  void DeleteSpecifiedCluster(int id);
153 
155 
159  vtkSetVector3Macro(ClosestPoint, double);
160  vtkGetVectorMacro(ClosestPoint, double, 3);
162 
166  int GetNumberOfExtractedClusters();
167 
169 
172  vtkSetMacro(ColorClusters, bool);
173  vtkGetMacro(ColorClusters, bool);
174  vtkBooleanMacro(ColorClusters, bool);
176 
178 
183  void SetLocator(vtkAbstractPointLocator* locator);
184  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
186 
187 protected:
189  ~vtkEuclideanClusterExtraction() override;
190 
191  double Radius; // connection radius
192  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
193  int ExtractionMode; // how to extract clusters
194  vtkIdList* Seeds; // id's of points or cells used to seed clusters
195  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
196  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
197 
198  double ClosestPoint[3];
199 
201  double ScalarRange[2];
202 
204 
205  // Configure the pipeline
207  int FillInputPortInformation(int port, vtkInformation* info) override;
208 
209  // Internal method for propagating connected waves.
210  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
211  void TraverseAndMark(vtkPoints* pts);
212 
213 private:
215  void operator=(const vtkEuclideanClusterExtraction&) = delete;
216 
217  // used to support algorithm execution
218  vtkFloatArray* NeighborScalars;
219  vtkIdList* NeighborPointIds;
220  char* Visited;
221  vtkIdType* PointMap;
222  vtkIdTypeArray* NewScalars;
223  vtkIdType ClusterNumber;
224  vtkIdType PointNumber;
225  vtkIdType NumPointsInCluster;
226  vtkDataArray* InScalars;
227  vtkIdList* Wave;
228  vtkIdList* Wave2;
229  vtkIdList* PointIds;
230 };
231 
236 {
238  {
239  return "ExtractPointSeededClusters";
240  }
242  {
243  return "ExtractSpecifiedClusters";
244  }
245  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
246  {
247  return "ExtractAllClusters";
248  }
250  {
251  return "ExtractClosestPointCluster";
252  }
253  else
254  {
255  return "ExtractLargestCluster";
256  }
257 }
258 
259 VTK_ABI_NAMESPACE_END
260 #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:30
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:315
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:152
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract class to quickly locate points in 3-space
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
list of point or cell ids
Definition: vtkIdList.h:22
#define VTK_EXTRACT_LARGEST_CLUSTER
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
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:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_EXTRACT_ALL_CLUSTERS