VTK  9.2.5
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 =========================================================================*/
73 #ifndef vtkEuclideanClusterExtraction_h
74 #define vtkEuclideanClusterExtraction_h
75 
76 #include "vtkFiltersPointsModule.h" // For export macro
77 #include "vtkPolyDataAlgorithm.h"
78 
79 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
80 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
81 #define VTK_EXTRACT_LARGEST_CLUSTER 3
82 #define VTK_EXTRACT_ALL_CLUSTERS 4
83 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
84 
85 class vtkDataArray;
86 class vtkFloatArray;
87 class vtkIdList;
88 class vtkIdTypeArray;
90 
91 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
92 {
93 public:
95  void PrintSelf(ostream& os, vtkIndent indent) override;
96 
101 
103 
106  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
107  vtkGetMacro(Radius, double);
109 
111 
117  vtkSetMacro(ScalarConnectivity, bool);
118  vtkGetMacro(ScalarConnectivity, bool);
119  vtkBooleanMacro(ScalarConnectivity, bool);
121 
123 
126  vtkSetVector2Macro(ScalarRange, double);
127  vtkGetVector2Macro(ScalarRange, double);
129 
131 
134  vtkSetClampMacro(
136  vtkGetMacro(ExtractionMode, int);
138  {
139  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
140  }
143  {
144  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
145  }
147  {
148  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
149  }
150  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
151  const char* GetExtractionModeAsString();
153 
158 
162  void AddSeed(vtkIdType id);
163 
168 
173 
177  void AddSpecifiedCluster(int id);
178 
183 
185 
189  vtkSetVector3Macro(ClosestPoint, double);
190  vtkGetVectorMacro(ClosestPoint, double, 3);
192 
197 
199 
202  vtkSetMacro(ColorClusters, bool);
203  vtkGetMacro(ColorClusters, bool);
204  vtkBooleanMacro(ColorClusters, bool);
206 
208 
214  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
216 
217 protected:
220 
221  double Radius; // connection radius
222  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
223  int ExtractionMode; // how to extract clusters
224  vtkIdList* Seeds; // id's of points or cells used to seed clusters
225  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
226  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
227 
228  double ClosestPoint[3];
229 
231  double ScalarRange[2];
232 
234 
235  // Configure the pipeline
238 
239  // Internal method for propagating connected waves.
240  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
242 
243 private:
245  void operator=(const vtkEuclideanClusterExtraction&) = delete;
246 
247  // used to support algorithm execution
248  vtkFloatArray* NeighborScalars;
249  vtkIdList* NeighborPointIds;
250  char* Visited;
251  vtkIdType* PointMap;
252  vtkIdTypeArray* NewScalars;
253  vtkIdType ClusterNumber;
254  vtkIdType PointNumber;
255  vtkIdType NumPointsInCluster;
256  vtkDataArray* InScalars;
257  vtkIdList* Wave;
258  vtkIdList* Wave2;
259  vtkIdList* PointIds;
260 };
261 
266 {
268  {
269  return "ExtractPointSeededClusters";
270  }
272  {
273  return "ExtractSpecifiedClusters";
274  }
275  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
276  {
277  return "ExtractAllClusters";
278  }
280  {
281  return "ExtractClosestPointCluster";
282  }
283  else
284  {
285  return "ExtractLargestCluster";
286  }
287 }
288 
289 #endif
abstract class to quickly locate points in 3-space
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
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
list of point or cell ids
Definition: vtkIdList.h:143
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:149
Superclass for algorithms that produce only polydata as output.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
#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:332
#define VTK_FLOAT_MAX
Definition: vtkType.h:163