VTK  9.3.0
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
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 VTK_ABI_NAMESPACE_BEGIN
64 class vtkDataArray;
65 class vtkFloatArray;
66 class vtkIdList;
67 class vtkIdTypeArray;
69 
70 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
71 {
72 public:
74  void PrintSelf(ostream& os, vtkIndent indent) 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(
115  vtkGetMacro(ExtractionMode, int);
117  {
118  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
119  }
122  {
123  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
124  }
126  {
127  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
128  }
129  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
130  const char* GetExtractionModeAsString();
132 
137 
141  void AddSeed(vtkIdType id);
142 
147 
152 
156  void AddSpecifiedCluster(int id);
157 
162 
164 
168  vtkSetVector3Macro(ClosestPoint, double);
169  vtkGetVectorMacro(ClosestPoint, double, 3);
171 
176 
178 
181  vtkSetMacro(ColorClusters, bool);
182  vtkGetMacro(ColorClusters, bool);
183  vtkBooleanMacro(ColorClusters, bool);
185 
187 
193  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
195 
196 protected:
199 
200  double Radius; // connection radius
201  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
202  int ExtractionMode; // how to extract clusters
203  vtkIdList* Seeds; // id's of points or cells used to seed clusters
204  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
205  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
206 
207  double ClosestPoint[3];
208 
210  double ScalarRange[2];
211 
213 
214  // Configure the pipeline
217 
218  // Internal method for propagating connected waves.
219  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
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 
245 {
247  {
248  return "ExtractPointSeededClusters";
249  }
251  {
252  return "ExtractSpecifiedClusters";
253  }
254  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
255  {
256  return "ExtractAllClusters";
257  }
259  {
260  return "ExtractClosestPointCluster";
261  }
262  else
263  {
264  return "ExtractLargestCluster";
265  }
266 }
267 
268 VTK_ABI_NAMESPACE_END
269 #endif
abstract class to quickly locate points in 3-space
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
perform segmentation based on geometric proximity and optional scalar threshold
void AddSpecifiedCluster(int id)
Add a cluster id to extract.
void SetExtractionModeToClosestPointCluster()
Control the extraction of connected surfaces.
~vtkEuclideanClusterExtraction() override
void InsertIntoWave(vtkIdList *wave, vtkIdType ptId)
void DeleteSpecifiedCluster(int id)
Delete a cluster id to extract.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void SetExtractionModeToLargestCluster()
Control the extraction of connected surfaces.
void TraverseAndMark(vtkPoints *pts)
void SetExtractionModeToSpecifiedClusters()
Control the extraction of connected surfaces.
void SetLocator(vtkAbstractPointLocator *locator)
Specify a point locator.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetExtractionModeToAllClusters()
Control the extraction of connected surfaces.
static vtkEuclideanClusterExtraction * New()
Construct with default extraction mode to extract largest clusters.
void InitializeSeedList()
Initialize the list of point ids used to seed clusters.
int GetNumberOfExtractedClusters()
Obtain the number of connected clusters.
void AddSeed(vtkIdType id)
Add a seed id (point id).
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
void DeleteSeed(vtkIdType id)
Delete a seed id.a.
void InitializeSpecifiedClusterList()
Initialize the list of cluster ids to extract.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
list of point or cell ids
Definition: vtkIdList.h:32
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:38
Superclass for algorithms that produce only polydata as output.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
#define VTK_EXTRACT_LARGEST_CLUSTER
#define VTK_EXTRACT_POINT_SEEDED_CLUSTERS
#define VTK_EXTRACT_ALL_CLUSTERS
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
int vtkIdType
Definition: vtkType.h:315
#define VTK_FLOAT_MAX
Definition: vtkType.h:152