VTK  9.2.6
vtkConnectedPointsFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkConnectedPointsFilter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
54 #ifndef vtkConnectedPointsFilter_h
55 #define vtkConnectedPointsFilter_h
56 
57 #include "vtkFiltersPointsModule.h" // For export macro
58 #include "vtkPolyDataAlgorithm.h"
59 
60 // Make these consistent with the other connectivity filters
61 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
62 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
63 #define VTK_EXTRACT_LARGEST_REGION 4
64 #define VTK_EXTRACT_ALL_REGIONS 5
65 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
66 
68 class vtkDataArray;
69 class vtkFloatArray;
70 class vtkIdList;
71 class vtkIdTypeArray;
72 class vtkIntArray;
73 
74 class VTKFILTERSPOINTS_EXPORT vtkConnectedPointsFilter : public vtkPolyDataAlgorithm
75 {
76 public:
78  void PrintSelf(ostream& os, vtkIndent indent) override;
79 
83  static vtkConnectedPointsFilter* New();
84 
86 
90  vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX);
91  vtkGetMacro(Radius, double);
93 
95 
98  vtkSetClampMacro(
100  vtkGetMacro(ExtractionMode, int);
102  {
103  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
104  }
107  {
108  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
109  }
111  {
112  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
113  }
114  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
115  const char* GetExtractionModeAsString();
117 
119 
123  vtkSetVector3Macro(ClosestPoint, double);
124  vtkGetVectorMacro(ClosestPoint, double, 3);
126 
130  void InitializeSeedList();
131 
135  void AddSeed(vtkIdType id);
136 
140  void DeleteSeed(vtkIdType id);
141 
145  void InitializeSpecifiedRegionList();
146 
150  void AddSpecifiedRegion(vtkIdType id);
151 
155  void DeleteSpecifiedRegion(vtkIdType id);
156 
158 
164  vtkSetMacro(AlignedNormals, int);
165  vtkGetMacro(AlignedNormals, int);
166  vtkBooleanMacro(AlignedNormals, int);
168 
170 
175  vtkSetClampMacro(NormalAngle, double, 0.0001, 90.0);
176  vtkGetMacro(NormalAngle, double);
178 
180 
185  vtkSetMacro(ScalarConnectivity, int);
186  vtkGetMacro(ScalarConnectivity, int);
187  vtkBooleanMacro(ScalarConnectivity, int);
189 
191 
194  vtkSetVector2Macro(ScalarRange, double);
195  vtkGetVector2Macro(ScalarRange, double);
197 
202  int GetNumberOfExtractedRegions();
203 
205 
210  void SetLocator(vtkAbstractPointLocator* locator);
211  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
213 
214 protected:
216  ~vtkConnectedPointsFilter() override;
217 
218  // Usual data generation method
220  int FillInputPortInformation(int port, vtkInformation* info) override;
221 
222  // The radius defines the proximal neighborhood of points
223  double Radius;
224 
225  // indicate how to extract regions
227 
228  // id's of points used to seed regions
230 
231  // regions specified for extraction
233 
234  // Seed with a closest point
235  double ClosestPoint[3];
236 
237  // Segment based on nearly aligned normals
239  double NormalAngle;
241 
242  // Support segmentation based on scalar connectivity
244  double ScalarRange[2];
245 
246  // accelerate searching
248 
249  // Wave propagation used to segment points
250  void TraverseAndMark(
251  vtkPoints* inPts, vtkDataArray* inScalars, float* normals, vtkIdType* labels);
252 
253 private:
254  // used to support algorithm execution
255  vtkIdType CurrentRegionNumber;
256  vtkIdTypeArray* RegionLabels;
257  vtkIdType NumPointsInRegion;
258  vtkIdTypeArray* RegionSizes;
259  vtkIdList* NeighborPointIds; // avoid repetitive new/delete
260  vtkIdList* Wave;
261  vtkIdList* Wave2;
262 
263 private:
265  void operator=(const vtkConnectedPointsFilter&) = delete;
266 };
267 
272 {
274  {
275  return "ExtractPointSeededRegions";
276  }
278  {
279  return "ExtractSpecifiedRegions";
280  }
281  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
282  {
283  return "ExtractAllRegions";
284  }
286  {
287  return "ExtractClosestPointRegion";
288  }
289  else
290  {
291  return "ExtractLargestRegion";
292  }
293 }
294 
295 #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:165
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:41
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:332
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected regions.
static vtkPolyDataAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
#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:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.