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 =========================================================================*/
63 #ifndef vtkEuclideanClusterExtraction_h
64 #define vtkEuclideanClusterExtraction_h
65 
66 #include "vtkFiltersPointsModule.h" // For export macro
67 #include "vtkPolyDataAlgorithm.h"
68 
69 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
70 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
71 #define VTK_EXTRACT_LARGEST_CLUSTER 3
72 #define VTK_EXTRACT_ALL_CLUSTERS 4
73 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
74 
75 class vtkDataArray;
76 class vtkFloatArray;
77 class vtkIdList;
78 class vtkIdTypeArray;
80 
81 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
82 {
83 public:
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
91 
93 
96  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
97  vtkGetMacro(Radius, double);
99 
101 
107  vtkSetMacro(ScalarConnectivity, bool);
108  vtkGetMacro(ScalarConnectivity, bool);
109  vtkBooleanMacro(ScalarConnectivity, bool);
111 
113 
116  vtkSetVector2Macro(ScalarRange, double);
117  vtkGetVector2Macro(ScalarRange, double);
119 
121 
124  vtkSetClampMacro(
126  vtkGetMacro(ExtractionMode, int);
128  {
129  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
130  }
133  {
134  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
135  }
137  {
138  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
139  }
140  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
141  const char* GetExtractionModeAsString();
143 
148 
152  void AddSeed(vtkIdType id);
153 
158 
163 
167  void AddSpecifiedCluster(int id);
168 
173 
175 
179  vtkSetVector3Macro(ClosestPoint, double);
180  vtkGetVectorMacro(ClosestPoint, double, 3);
182 
187 
189 
192  vtkSetMacro(ColorClusters, bool);
193  vtkGetMacro(ColorClusters, bool);
194  vtkBooleanMacro(ColorClusters, bool);
196 
198 
204  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
206 
207 protected:
210 
211  double Radius; // connection radius
212  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
213  int ExtractionMode; // how to extract clusters
214  vtkIdList* Seeds; // id's of points or cells used to seed clusters
215  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
216  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
217 
218  double ClosestPoint[3];
219 
221  double ScalarRange[2];
222 
224 
225  // Configure the pipeline
228 
229  // Internal method for propagating connected waves.
230  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
232 
233 private:
235  void operator=(const vtkEuclideanClusterExtraction&) = delete;
236 
237  // used to support algorithm execution
238  vtkFloatArray* NeighborScalars;
239  vtkIdList* NeighborPointIds;
240  char* Visited;
241  vtkIdType* PointMap;
242  vtkIdTypeArray* NewScalars;
243  vtkIdType ClusterNumber;
244  vtkIdType PointNumber;
245  vtkIdType NumPointsInCluster;
246  vtkDataArray* InScalars;
247  vtkIdList* Wave;
248  vtkIdList* Wave2;
249  vtkIdList* PointIds;
250 };
251 
256 {
258  {
259  return "ExtractPointSeededClusters";
260  }
262  {
263  return "ExtractSpecifiedClusters";
264  }
265  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
266  {
267  return "ExtractAllClusters";
268  }
270  {
271  return "ExtractClosestPointCluster";
272  }
273  else
274  {
275  return "ExtractLargestCluster";
276  }
277 }
278 
279 #endif
abstract class to quickly locate points in 3-space
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:65
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:51
list of point or cell ids
Definition: vtkIdList.h:43
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:49
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:49
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