VTK  9.3.0
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 
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 
120 
124  void AddSeed(vtkIdType id);
125 
130 
135 
140 
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 
192 
194 
200  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
202 
203 protected:
206 
207  // Usual data generation method
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
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
abstract class to quickly locate points in 3-space
extract / segment points based on geometric connectivity
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected regions.
void TraverseAndMark(vtkPoints *inPts, vtkDataArray *inScalars, float *normals, vtkIdType *labels)
vtkAbstractPointLocator * Locator
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected regions.
void SetLocator(vtkAbstractPointLocator *locator)
Specify a point locator.
void InitializeSpecifiedRegionList()
Initialize list of region ids to extract.
void DeleteSeed(vtkIdType id)
Delete a point seed id.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void DeleteSpecifiedRegion(vtkIdType id)
Delete a region id to extract.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected regions.
~vtkConnectedPointsFilter() override
void AddSpecifiedRegion(vtkIdType id)
Add a non-negative region id to extract.
static vtkConnectedPointsFilter * New()
Construct with default extraction mode to extract the largest region.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void SetExtractionModeToAllRegions()
Control the extraction of connected regions.
void AddSeed(vtkIdType id)
Add a non-negative point seed id.
void SetExtractionModeToLargestRegion()
Control the extraction of connected 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.
void InitializeSeedList()
Initialize list of point ids ids used to seed regions.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:31
list of point or cell ids
Definition: vtkIdList.h:23
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
represent and manipulate 3D points
Definition: vtkPoints.h:29
Superclass for algorithms that produce only polydata as output.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
#define VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_LARGEST_REGION
int vtkIdType
Definition: vtkType.h:315
#define VTK_DOUBLE_MAX
Definition: vtkType.h:154