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 =========================================================================*/
70 #ifndef vtkEuclideanClusterExtraction_h
71 #define vtkEuclideanClusterExtraction_h
72 
73 #include "vtkFiltersPointsModule.h" // For export macro
74 #include "vtkPolyDataAlgorithm.h"
75 
76 #define VTK_EXTRACT_POINT_SEEDED_CLUSTERS 1
77 #define VTK_EXTRACT_SPECIFIED_CLUSTERS 2
78 #define VTK_EXTRACT_LARGEST_CLUSTER 3
79 #define VTK_EXTRACT_ALL_CLUSTERS 4
80 #define VTK_EXTRACT_CLOSEST_POINT_CLUSTER 5
81 
82 class vtkDataArray;
83 class vtkFloatArray;
84 class vtkIdList;
85 class vtkIdTypeArray;
87 
88 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
89 {
90 public:
92  void PrintSelf(ostream& os, vtkIndent indent) override;
93 
98 
100 
103  vtkSetClampMacro(Radius, double, 0.0, VTK_FLOAT_MAX);
104  vtkGetMacro(Radius, double);
106 
108 
114  vtkSetMacro(ScalarConnectivity, bool);
115  vtkGetMacro(ScalarConnectivity, bool);
116  vtkBooleanMacro(ScalarConnectivity, bool);
118 
120 
123  vtkSetVector2Macro(ScalarRange, double);
124  vtkGetVector2Macro(ScalarRange, double);
126 
128 
131  vtkSetClampMacro(
133  vtkGetMacro(ExtractionMode, int);
135  {
136  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
137  }
140  {
141  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
142  }
144  {
145  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
146  }
147  void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
148  const char* GetExtractionModeAsString();
150 
155 
159  void AddSeed(vtkIdType id);
160 
165 
170 
174  void AddSpecifiedCluster(int id);
175 
180 
182 
186  vtkSetVector3Macro(ClosestPoint, double);
187  vtkGetVectorMacro(ClosestPoint, double, 3);
189 
194 
196 
199  vtkSetMacro(ColorClusters, bool);
200  vtkGetMacro(ColorClusters, bool);
201  vtkBooleanMacro(ColorClusters, bool);
203 
205 
211  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
213 
214 protected:
217 
218  double Radius; // connection radius
219  bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
220  int ExtractionMode; // how to extract clusters
221  vtkIdList* Seeds; // id's of points or cells used to seed clusters
222  vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
223  vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
224 
225  double ClosestPoint[3];
226 
228  double ScalarRange[2];
229 
231 
232  // Configure the pipeline
235 
236  // Internal method for propagating connected waves.
237  void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
239 
240 private:
242  void operator=(const vtkEuclideanClusterExtraction&) = delete;
243 
244  // used to support algorithm execution
245  vtkFloatArray* NeighborScalars;
246  vtkIdList* NeighborPointIds;
247  char* Visited;
248  vtkIdType* PointMap;
249  vtkIdTypeArray* NewScalars;
250  vtkIdType ClusterNumber;
251  vtkIdType PointNumber;
252  vtkIdType NumPointsInCluster;
253  vtkDataArray* InScalars;
254  vtkIdList* Wave;
255  vtkIdList* Wave2;
256  vtkIdList* PointIds;
257 };
258 
263 {
265  {
266  return "ExtractPointSeededClusters";
267  }
269  {
270  return "ExtractSpecifiedClusters";
271  }
272  else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
273  {
274  return "ExtractAllClusters";
275  }
277  {
278  return "ExtractClosestPointCluster";
279  }
280  else
281  {
282  return "ExtractLargestCluster";
283  }
284 }
285 
286 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkEuclideanClusterExtraction
perform segmentation based on geometric proximity and optional scalar threshold
Definition: vtkEuclideanClusterExtraction.h:89
vtkEuclideanClusterExtraction::TraverseAndMark
void TraverseAndMark(vtkPoints *pts)
vtkEuclideanClusterExtraction::New
static vtkEuclideanClusterExtraction * New()
Construct with default extraction mode to extract largest clusters.
vtkEuclideanClusterExtraction::SetExtractionModeToAllClusters
void SetExtractionModeToAllClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:147
VTK_EXTRACT_ALL_CLUSTERS
#define VTK_EXTRACT_ALL_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:79
vtkEuclideanClusterExtraction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkEuclideanClusterExtraction::AddSeed
void AddSeed(vtkIdType id)
Add a seed id (point id).
vtkEuclideanClusterExtraction::Locator
vtkAbstractPointLocator * Locator
Definition: vtkEuclideanClusterExtraction.h:230
vtkEuclideanClusterExtraction::ColorClusters
bool ColorClusters
Definition: vtkEuclideanClusterExtraction.h:219
vtkEuclideanClusterExtraction::DeleteSeed
void DeleteSeed(vtkIdType id)
Delete a seed id.a.
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:145
vtkEuclideanClusterExtraction::SetExtractionModeToSpecifiedClusters
void SetExtractionModeToSpecifiedClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:139
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
VTK_EXTRACT_POINT_SEEDED_CLUSTERS
#define VTK_EXTRACT_POINT_SEEDED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:76
vtkEuclideanClusterExtraction::ExtractionMode
int ExtractionMode
Definition: vtkEuclideanClusterExtraction.h:220
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkEuclideanClusterExtraction::SetExtractionModeToPointSeededClusters
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:134
VTK_EXTRACT_CLOSEST_POINT_CLUSTER
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:80
vtkEuclideanClusterExtraction::~vtkEuclideanClusterExtraction
~vtkEuclideanClusterExtraction() override
vtkEuclideanClusterExtraction::ScalarConnectivity
bool ScalarConnectivity
Definition: vtkEuclideanClusterExtraction.h:227
vtkEuclideanClusterExtraction::InitializeSpecifiedClusterList
void InitializeSpecifiedClusterList()
Initialize the list of cluster ids to extract.
vtkPolyDataAlgorithm.h
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkEuclideanClusterExtraction::Radius
double Radius
Definition: vtkEuclideanClusterExtraction.h:218
vtkEuclideanClusterExtraction::InsertIntoWave
void InsertIntoWave(vtkIdList *wave, vtkIdType ptId)
VTK_EXTRACT_SPECIFIED_CLUSTERS
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:77
vtkEuclideanClusterExtraction::Seeds
vtkIdList * Seeds
Definition: vtkEuclideanClusterExtraction.h:221
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkEuclideanClusterExtraction::InitializeSeedList
void InitializeSeedList()
Initialize the list of point ids used to seed clusters.
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:163
VTK_EXTRACT_LARGEST_CLUSTER
#define VTK_EXTRACT_LARGEST_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:78
vtkEuclideanClusterExtraction::DeleteSpecifiedCluster
void DeleteSpecifiedCluster(int id)
Delete a cluster id to extract.
vtkEuclideanClusterExtraction::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkEuclideanClusterExtraction::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkEuclideanClusterExtraction::SetExtractionModeToClosestPointCluster
void SetExtractionModeToClosestPointCluster()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:143
vtkEuclideanClusterExtraction::SetExtractionModeToLargestCluster
void SetExtractionModeToLargestCluster()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:138
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:145
vtkEuclideanClusterExtraction::GetNumberOfExtractedClusters
int GetNumberOfExtractedClusters()
Obtain the number of connected clusters.
vtkEuclideanClusterExtraction::vtkEuclideanClusterExtraction
vtkEuclideanClusterExtraction()
vtkAbstractPointLocator
abstract class to quickly locate points in 3-space
Definition: vtkAbstractPointLocator.h:39
vtkEuclideanClusterExtraction::AddSpecifiedCluster
void AddSpecifiedCluster(int id)
Add a cluster id to extract.
vtkEuclideanClusterExtraction::GetExtractionModeAsString
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
Definition: vtkEuclideanClusterExtraction.h:262
vtkEuclideanClusterExtraction::ClusterSizes
vtkIdTypeArray * ClusterSizes
Definition: vtkEuclideanClusterExtraction.h:223
vtkEuclideanClusterExtraction::SetLocator
void SetLocator(vtkAbstractPointLocator *locator)
Specify a point locator.
vtkEuclideanClusterExtraction::SpecifiedClusterIds
vtkIdList * SpecifiedClusterIds
Definition: vtkEuclideanClusterExtraction.h:222
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:151