VTK: Filters/Points/vtkEuclideanClusterExtraction.h Source File

| VTK 9.3.1

vtkEuclideanClusterExtraction.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-CLAUSE
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 VTK_ABI_NAMESPACE_BEGIN
64 class vtkDataArray;
65 class vtkFloatArray;
66 class vtkIdList;
67 class vtkIdTypeArray;
68 class vtkAbstractPointLocator;
69
70 class VTKFILTERSPOINTS_EXPORT vtkEuclideanClusterExtraction : public vtkPolyDataAlgorithm
71 {
72 public:
73 vtkTypeMacro(vtkEuclideanClusterExtraction, vtkPolyDataAlgorithm);
74 void PrintSelf(ostream& os, vtkIndent indent) override;
75
79 static vtkEuclideanClusterExtraction* New();
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(
114 ExtractionMode, int, VTK_EXTRACT_POINT_SEEDED_CLUSTERS, VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
115 vtkGetMacro(ExtractionMode, int);
116 void SetExtractionModeToPointSeededClusters()
117 {
118 this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_CLUSTERS);
119 }
120 void SetExtractionModeToLargestCluster() { this->SetExtractionMode(VTK_EXTRACT_LARGEST_CLUSTER); }
121 void SetExtractionModeToSpecifiedClusters()
122 {
123 this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_CLUSTERS);
124 }
125 void SetExtractionModeToClosestPointCluster()
126 {
127 this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_CLUSTER);
128 }
129 void SetExtractionModeToAllClusters() { this->SetExtractionMode(VTK_EXTRACT_ALL_CLUSTERS); }
130 const char* GetExtractionModeAsString();
132
136 void InitializeSeedList();
137
141 void AddSeed(vtkIdType id);
142
146 void DeleteSeed(vtkIdType id);
147
151 void InitializeSpecifiedClusterList();
152
156 void AddSpecifiedCluster(int id);
157
161 void DeleteSpecifiedCluster(int id);
162
164
168 vtkSetVector3Macro(ClosestPoint, double);
169 vtkGetVectorMacro(ClosestPoint, double, 3);
171
175 int GetNumberOfExtractedClusters();
176
178
181 vtkSetMacro(ColorClusters, bool);
182 vtkGetMacro(ColorClusters, bool);
183 vtkBooleanMacro(ColorClusters, bool);
185
187
192 void SetLocator(vtkAbstractPointLocator* locator);
193 vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
195
196 protected:
197 vtkEuclideanClusterExtraction();
198 ~vtkEuclideanClusterExtraction() override;
199
200 double Radius; // connection radius
201 bool ColorClusters; // boolean turns on/off scalar gen for separate clusters
202 int ExtractionMode; // how to extract clusters
203 vtkIdList* Seeds; // id's of points or cells used to seed clusters
204 vtkIdList* SpecifiedClusterIds; // clusters specified for extraction
205 vtkIdTypeArray* ClusterSizes; // size (in cells) of each cluster extracted
206
207 double ClosestPoint[3];
208
209 bool ScalarConnectivity;
210 double ScalarRange[2];
211
212 vtkAbstractPointLocator* Locator;
213
214 // Configure the pipeline
215 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
216 int FillInputPortInformation(int port, vtkInformation* info) override;
217
218 // Internal method for propagating connected waves.
219 void InsertIntoWave(vtkIdList* wave, vtkIdType ptId);
220 void TraverseAndMark(vtkPoints* pts);
221
222 private:
223 vtkEuclideanClusterExtraction(const vtkEuclideanClusterExtraction&) = delete;
224 void operator=(const vtkEuclideanClusterExtraction&) = delete;
225
226 // used to support algorithm execution
227 vtkFloatArray* NeighborScalars;
228 vtkIdList* NeighborPointIds;
229 char* Visited;
230 vtkIdType* PointMap;
231 vtkIdTypeArray* NewScalars;
232 vtkIdType ClusterNumber;
233 vtkIdType PointNumber;
234 vtkIdType NumPointsInCluster;
235 vtkDataArray* InScalars;
236 vtkIdList* Wave;
237 vtkIdList* Wave2;
238 vtkIdList* PointIds;
239 };
240
244 inline const char* vtkEuclideanClusterExtraction::GetExtractionModeAsString()
245 {
246 if (this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_CLUSTERS)
247 {
248 return "ExtractPointSeededClusters";
249 }
250 else if (this->ExtractionMode == VTK_EXTRACT_SPECIFIED_CLUSTERS)
251 {
252 return "ExtractSpecifiedClusters";
253 }
254 else if (this->ExtractionMode == VTK_EXTRACT_ALL_CLUSTERS)
255 {
256 return "ExtractAllClusters";
257 }
258 else if (this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_CLUSTER)
259 {
260 return "ExtractClosestPointCluster";
261 }
262 else
263 {
264 return "ExtractLargestCluster";
265 }
266 }
267
268 VTK_ABI_NAMESPACE_END
269 #endif
vtkAbstractPointLocator
abstract class to quickly locate points in 3-space
Definition: vtkAbstractPointLocator.h:31
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkEuclideanClusterExtraction
perform segmentation based on geometric proximity and optional scalar threshold
Definition: vtkEuclideanClusterExtraction.h:71
vtkEuclideanClusterExtraction::AddSpecifiedCluster
void AddSpecifiedCluster(int id)
Add a cluster id to extract.
vtkEuclideanClusterExtraction::SetExtractionModeToClosestPointCluster
void SetExtractionModeToClosestPointCluster()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:125
vtkEuclideanClusterExtraction::ColorClusters
bool ColorClusters
Definition: vtkEuclideanClusterExtraction.h:201
vtkEuclideanClusterExtraction::~vtkEuclideanClusterExtraction
~vtkEuclideanClusterExtraction() override
vtkEuclideanClusterExtraction::Seeds
vtkIdList * Seeds
Definition: vtkEuclideanClusterExtraction.h:203
vtkEuclideanClusterExtraction::InsertIntoWave
void InsertIntoWave(vtkIdList *wave, vtkIdType ptId)
vtkEuclideanClusterExtraction::SpecifiedClusterIds
vtkIdList * SpecifiedClusterIds
Definition: vtkEuclideanClusterExtraction.h:204
vtkEuclideanClusterExtraction::DeleteSpecifiedCluster
void DeleteSpecifiedCluster(int id)
Delete a cluster id to extract.
vtkEuclideanClusterExtraction::vtkEuclideanClusterExtraction
vtkEuclideanClusterExtraction()
vtkEuclideanClusterExtraction::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkEuclideanClusterExtraction::SetExtractionModeToLargestCluster
void SetExtractionModeToLargestCluster()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:120
vtkEuclideanClusterExtraction::TraverseAndMark
void TraverseAndMark(vtkPoints *pts)
vtkEuclideanClusterExtraction::Radius
double Radius
Definition: vtkEuclideanClusterExtraction.h:200
vtkEuclideanClusterExtraction::SetExtractionModeToSpecifiedClusters
void SetExtractionModeToSpecifiedClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:121
vtkEuclideanClusterExtraction::SetLocator
void SetLocator(vtkAbstractPointLocator *locator)
Specify a point locator.
vtkEuclideanClusterExtraction::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkEuclideanClusterExtraction::SetExtractionModeToAllClusters
void SetExtractionModeToAllClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:129
vtkEuclideanClusterExtraction::New
static vtkEuclideanClusterExtraction * New()
Construct with default extraction mode to extract largest clusters.
vtkEuclideanClusterExtraction::InitializeSeedList
void InitializeSeedList()
Initialize the list of point ids used to seed clusters.
vtkEuclideanClusterExtraction::GetNumberOfExtractedClusters
int GetNumberOfExtractedClusters()
Obtain the number of connected clusters.
vtkEuclideanClusterExtraction::AddSeed
void AddSeed(vtkIdType id)
Add a seed id (point id).
vtkEuclideanClusterExtraction::Locator
vtkAbstractPointLocator * Locator
Definition: vtkEuclideanClusterExtraction.h:212
vtkEuclideanClusterExtraction::ScalarConnectivity
bool ScalarConnectivity
Definition: vtkEuclideanClusterExtraction.h:209
vtkEuclideanClusterExtraction::GetExtractionModeAsString
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
Definition: vtkEuclideanClusterExtraction.h:244
vtkEuclideanClusterExtraction::DeleteSeed
void DeleteSeed(vtkIdType id)
Delete a seed id.a.
vtkEuclideanClusterExtraction::InitializeSpecifiedClusterList
void InitializeSpecifiedClusterList()
Initialize the list of cluster ids to extract.
vtkEuclideanClusterExtraction::ExtractionMode
int ExtractionMode
Definition: vtkEuclideanClusterExtraction.h:202
vtkEuclideanClusterExtraction::ClusterSizes
vtkIdTypeArray * ClusterSizes
Definition: vtkEuclideanClusterExtraction.h:205
vtkEuclideanClusterExtraction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkEuclideanClusterExtraction::SetExtractionModeToPointSeededClusters
void SetExtractionModeToPointSeededClusters()
Control the extraction of connected surfaces.
Definition: vtkEuclideanClusterExtraction.h:116
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:40
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:32
vtkIdTypeArray
dynamic, self-adjusting array of vtkIdType
Definition: vtkIdTypeArray.h:37
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPolyDataAlgorithm
Superclass for algorithms that produce only polydata as output.
Definition: vtkPolyDataAlgorithm.h:43
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkX3D::port
@ port
Definition: vtkX3D.h:447
VTK_EXTRACT_SPECIFIED_CLUSTERS
#define VTK_EXTRACT_SPECIFIED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:58
VTK_EXTRACT_LARGEST_CLUSTER
#define VTK_EXTRACT_LARGEST_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:59
VTK_EXTRACT_POINT_SEEDED_CLUSTERS
#define VTK_EXTRACT_POINT_SEEDED_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:57
VTK_EXTRACT_ALL_CLUSTERS
#define VTK_EXTRACT_ALL_CLUSTERS
Definition: vtkEuclideanClusterExtraction.h:60
VTK_EXTRACT_CLOSEST_POINT_CLUSTER
#define VTK_EXTRACT_CLOSEST_POINT_CLUSTER
Definition: vtkEuclideanClusterExtraction.h:61
vtkPolyDataAlgorithm.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
VTK_FLOAT_MAX
#define VTK_FLOAT_MAX
Definition: vtkType.h:152