VTK
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 
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(ExtractionMode,int,
115  vtkGetMacro(ExtractionMode,int);
117  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);};
119  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_CLUSTER);};
121  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);};
123  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);};
125  {this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS);};
126  const char *GetExtractionModeAsString();
128 
132  void InitializeSeedList();
133 
137  void AddSeed(vtkIdType id);
138 
142  void DeleteSeed(vtkIdType id);
143 
147  void InitializeSpecifiedClusterList();
148 
152  void AddSpecifiedCluster(int id);
153 
157  void DeleteSpecifiedCluster(int id);
158 
160 
164  vtkSetVector3Macro(ClosestPoint,double);
165  vtkGetVectorMacro(ClosestPoint,double,3);
167 
171  int GetNumberOfExtractedClusters();
172 
174 
177  vtkSetMacro(ColorClusters,bool);
178  vtkGetMacro(ColorClusters,bool);
179  vtkBooleanMacro(ColorClusters,bool);
181 
183 
188  void SetLocator(vtkAbstractPointLocator *locator);
189  vtkGetObjectMacro(Locator,vtkAbstractPointLocator);
191 
192 protected:
194  ~vtkEuclideanClusterExtraction() override;
195 
196  double Radius; //connection radius
197  bool ColorClusters; //boolean turns on/off scalar gen for separate clusters
198  int ExtractionMode; //how to extract clusters
199  vtkIdList *Seeds; //id's of points or cells used to seed clusters
200  vtkIdList *SpecifiedClusterIds; //clusters specified for extraction
201  vtkIdTypeArray *ClusterSizes; //size (in cells) of each cluster extracted
202 
203  double ClosestPoint[3];
204 
206  double ScalarRange[2];
207 
209 
210  // Configure the pipeline
212  vtkInformationVector *) override;
213  int FillInputPortInformation(int port, vtkInformation *info) override;
214 
215  // Internal method for propagating connected waves.
216  void InsertIntoWave(vtkIdList *wave, vtkIdType ptId);
217  void TraverseAndMark(vtkPoints *pts);
218 
219 private:
221  void operator=(const vtkEuclideanClusterExtraction&) = delete;
222 
223  // used to support algorithm execution
224  vtkFloatArray *NeighborScalars;
225  vtkIdList *NeighborPointIds;
226  char *Visited;
227  vtkIdType *PointMap;
228  vtkIdTypeArray *NewScalars;
229  vtkIdType ClusterNumber;
230  vtkIdType PointNumber;
231  vtkIdType NumPointsInCluster;
232  vtkDataArray *InScalars;
233  vtkIdList *Wave;
234  vtkIdList *Wave2;
235  vtkIdList *PointIds;
236 
237 };
238 
240 
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 }
267 
268 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkEuclideanClusterExtraction
perform segmentation based on geometric proximity and optional scalar threshold
Definition: vtkEuclideanClusterExtraction.h:70
vtkEuclideanClusterExtraction::SetExtractionModeToAllClusters
void SetExtractionModeToAllClusters()
Definition: vtkEuclideanClusterExtraction.h:124
VTK_EXTRACT_ALL_CLUSTERS
#define VTK_EXTRACT_ALL_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:60
vtkEuclideanClusterExtraction::Locator
vtkAbstractPointLocator * Locator
Definition: vtkEuclideanClusterExtraction.h:208
vtkEuclideanClusterExtraction::ColorClusters
bool ColorClusters
Definition: vtkEuclideanClusterExtraction.h:197
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
vtkEuclideanClusterExtraction::SetExtractionModeToSpecifiedClusters
void SetExtractionModeToSpecifiedClusters()
Definition: vtkEuclideanClusterExtraction.h:120
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
VTK_EXTRACT_POINT_SEEDED_CLUSTERS
#define VTK_EXTRACT_POINT_SEEDED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:57
vtkEuclideanClusterExtraction::ExtractionMode
int ExtractionMode
Definition: vtkEuclideanClusterExtraction.h:198
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkPolyDataAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkEuclideanClusterExtraction::SetExtractionModeToPointSeededClusters
void SetExtractionModeToPointSeededClusters()
Definition: vtkEuclideanClusterExtraction.h:116
VTK_EXTRACT_CLOSEST_POINT_CLUSTER
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:61
vtkEuclideanClusterExtraction::ScalarConnectivity
bool ScalarConnectivity
Definition: vtkEuclideanClusterExtraction.h:205
vtkPolyDataAlgorithm.h
vtkX3D::port
Definition: vtkX3D.h:447
vtkEuclideanClusterExtraction::Radius
double Radius
Definition: vtkEuclideanClusterExtraction.h:196
vtkPolyDataAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
VTK_EXTRACT_SPECIFIED_CLUSTERS
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:58
vtkEuclideanClusterExtraction::Seeds
vtkIdList * Seeds
Definition: vtkEuclideanClusterExtraction.h:199
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:167
vtkPolyDataAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
VTK_EXTRACT_LARGEST_CLUSTER
#define VTK_EXTRACT_LARGEST_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:59
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkEuclideanClusterExtraction::SetExtractionModeToClosestPointCluster
void SetExtractionModeToClosestPointCluster()
Definition: vtkEuclideanClusterExtraction.h:122
vtkEuclideanClusterExtraction::SetExtractionModeToLargestCluster
void SetExtractionModeToLargestCluster()
Definition: vtkEuclideanClusterExtraction.h:118
vtkX3D::info
Definition: vtkX3D.h:376
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:35
vtkAbstractPointLocator
abstract class to quickly locate points in 3-space
Definition: vtkAbstractPointLocator.h:38
vtkEuclideanClusterExtraction::GetExtractionModeAsString
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
Definition: vtkEuclideanClusterExtraction.h:243
vtkEuclideanClusterExtraction::ClusterSizes
vtkIdTypeArray * ClusterSizes
Definition: vtkEuclideanClusterExtraction.h:201
vtkPolyDataAlgorithm::New
static vtkPolyDataAlgorithm * New()
vtkEuclideanClusterExtraction::SpecifiedClusterIds
vtkIdList * SpecifiedClusterIds
Definition: vtkEuclideanClusterExtraction.h:200
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:41