VTK  9.3.1
vtkConnectedPointsFilter.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
42 #ifndef vtkConnectedPointsFilter_h
43 #define vtkConnectedPointsFilter_h
44 
45 #include "vtkFiltersPointsModule.h" // For export macro
46 #include "vtkPolyDataAlgorithm.h"
47 
48 // Make these consistent with the other connectivity filters
49 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
50 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
51 #define VTK_EXTRACT_LARGEST_REGION 4
52 #define VTK_EXTRACT_ALL_REGIONS 5
53 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
54 
55 VTK_ABI_NAMESPACE_BEGIN
57 class vtkDataArray;
58 class vtkFloatArray;
59 class vtkIdList;
60 class vtkIdTypeArray;
61 class vtkIntArray;
62 
63 class VTKFILTERSPOINTS_EXPORT vtkConnectedPointsFilter : public vtkPolyDataAlgorithm
64 {
65 public:
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
72  static vtkConnectedPointsFilter* New();
73 
75 
79  vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX);
80  vtkGetMacro(Radius, double);
82 
84 
87  vtkSetClampMacro(
89  vtkGetMacro(ExtractionMode, int);
91  {
92  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
93  }
94  void SetExtractionModeToLargestRegion() { this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION); }
96  {
97  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
98  }
100  {
101  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
102  }
103  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
104  const char* GetExtractionModeAsString();
106 
108 
112  vtkSetVector3Macro(ClosestPoint, double);
113  vtkGetVectorMacro(ClosestPoint, double, 3);
115 
119  void InitializeSeedList();
120 
124  void AddSeed(vtkIdType id);
125 
129  void DeleteSeed(vtkIdType id);
130 
134  void InitializeSpecifiedRegionList();
135 
139  void AddSpecifiedRegion(vtkIdType id);
140 
144  void DeleteSpecifiedRegion(vtkIdType id);
145 
147 
153  vtkSetMacro(AlignedNormals, int);
154  vtkGetMacro(AlignedNormals, int);
155  vtkBooleanMacro(AlignedNormals, int);
157 
159 
164  vtkSetClampMacro(NormalAngle, double, 0.0001, 90.0);
165  vtkGetMacro(NormalAngle, double);
167 
169 
174  vtkSetMacro(ScalarConnectivity, int);
175  vtkGetMacro(ScalarConnectivity, int);
176  vtkBooleanMacro(ScalarConnectivity, int);
178 
180 
183  vtkSetVector2Macro(ScalarRange, double);
184  vtkGetVector2Macro(ScalarRange, double);
186 
191  int GetNumberOfExtractedRegions();
192 
194 
199  void SetLocator(vtkAbstractPointLocator* locator);
200  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
202 
203 protected:
205  ~vtkConnectedPointsFilter() override;
206 
207  // Usual data generation method
209  int FillInputPortInformation(int port, vtkInformation* info) override;
210 
211  // The radius defines the proximal neighborhood of points
212  double Radius;
213 
214  // indicate how to extract regions
216 
217  // id's of points used to seed regions
219 
220  // regions specified for extraction
222 
223  // Seed with a closest point
224  double ClosestPoint[3];
225 
226  // Segment based on nearly aligned normals
228  double NormalAngle;
230 
231  // Support segmentation based on scalar connectivity
233  double ScalarRange[2];
234 
235  // accelerate searching
237 
238  // Wave propagation used to segment points
239  void TraverseAndMark(
240  vtkPoints* inPts, vtkDataArray* inScalars, float* normals, vtkIdType* labels);
241 
242 private:
243  // used to support algorithm execution
244  vtkIdType CurrentRegionNumber;
245  vtkIdTypeArray* RegionLabels;
246  vtkIdType NumPointsInRegion;
247  vtkIdTypeArray* RegionSizes;
248  vtkIdList* NeighborPointIds; // avoid repetitive new/delete
249  vtkIdList* Wave;
250  vtkIdList* Wave2;
251 
253  void operator=(const vtkConnectedPointsFilter&) = delete;
254 };
255 
260 {
262  {
263  return "ExtractPointSeededRegions";
264  }
266  {
267  return "ExtractSpecifiedRegions";
268  }
269  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
270  {
271  return "ExtractAllRegions";
272  }
274  {
275  return "ExtractClosestPointRegion";
276  }
277  else
278  {
279  return "ExtractLargestRegion";
280  }
281 }
282 
283 VTK_ABI_NAMESPACE_END
284 #endif
vtkAbstractPointLocator * Locator
void SetExtractionModeToLargestRegion()
Control the extraction of connected regions.
#define VTK_EXTRACT_ALL_REGIONS
extract / segment points based on geometric connectivity
#define VTK_EXTRACT_LARGEST_REGION
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154
Store vtkAlgorithm input/output information.
#define VTK_EXTRACT_SPECIFIED_REGIONS
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:30
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected regions.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected regions.
dynamic, self-adjusting array of vtkIdType
void SetExtractionModeToAllRegions()
Control the extraction of connected regions.
int vtkIdType
Definition: vtkType.h:315
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected regions.
static vtkPolyDataAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:22
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
#define VTK_EXTRACT_CLOSEST_POINT_REGION
represent and manipulate 3D points
Definition: vtkPoints.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.