VTK  9.1.0
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 =========================================================================*/
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 class vtkDataArray;
64 class vtkFloatArray;
65 class vtkIdList;
66 class vtkIdTypeArray;
68 
69 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
70 {
71 public:
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
79 
81 
84  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
85  vtkGetMacro(Radius, double);
87 
89 
95  vtkSetMacro(ScalarConnectivity, bool);
96  vtkGetMacro(ScalarConnectivity, bool);
97  vtkBooleanMacro(ScalarConnectivity, bool);
99 
101 
104  vtkSetVector2Macro(ScalarRange, double);
105  vtkGetVector2Macro(ScalarRange, double);
107 
109 
112  vtkSetClampMacro(
114  vtkGetMacro(ExtractionMode, int);
116  {
117  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
118  }
121  {
122  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
123  }
125  {
126  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
127  }
128  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
129  const char* GetExtractionModeAsString();
131 
136 
140  void AddSeed(vtkIdType id);
141 
146 
151 
155  void AddSpecifiedCluster(int id);
156 
161 
163 
167  vtkSetVector3Macro(ClosestPoint, double);
168  vtkGetVectorMacro(ClosestPoint, double, 3);
170 
175 
177 
180  vtkSetMacro(ColorClusters, bool);
181  vtkGetMacro(ColorClusters, bool);
182  vtkBooleanMacro(ColorClusters, bool);
184 
186 
192  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
194 
195 protected:
198 
199  double Radius; // connection radius
200  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
201  int ExtractionMode; // how to extract clusters
202  vtkIdList* Seeds; // id's of points or cells used to seed clusters
203  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
204  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
205 
206  double ClosestPoint[3];
207 
209  double ScalarRange[2];
210 
212 
213  // Configure the pipeline
216 
217  // Internal method for propagating connected waves.
218  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
220 
221 private:
223  void operator=(const vtkEuclideanClusterExtraction&) = delete;
224 
225  // used to support algorithm execution
226  vtkFloatArray* NeighborScalars;
227  vtkIdList* NeighborPointIds;
228  char* Visited;
229  vtkIdType* PointMap;
230  vtkIdTypeArray* NewScalars;
231  vtkIdType ClusterNumber;
232  vtkIdType PointNumber;
233  vtkIdType NumPointsInCluster;
234  vtkDataArray* InScalars;
235  vtkIdList* Wave;
236  vtkIdList* Wave2;
237  vtkIdList* PointIds;
238 };
239 
244 {
246  {
247  return "ExtractPointSeededClusters";
248  }
250  {
251  return "ExtractSpecifiedClusters";
252  }
253  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
254  {
255  return "ExtractAllClusters";
256  }
258  {
259  return "ExtractClosestPointCluster";
260  }
261  else
262  {
263  return "ExtractLargestCluster";
264  }
265 }
266 
267 #endif
abstract class to quickly locate points in 3-space
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
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:36
list of point or cell ids
Definition: vtkIdList.h:31
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 3D points
Definition: vtkPoints.h:34
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