VTK  9.0.1
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 =========================================================================*/
51 #ifndef vtkConnectedPointsFilter_h
52 #define vtkConnectedPointsFilter_h
53 
54 #include "vtkFiltersPointsModule.h" // For export macro
55 #include "vtkPolyDataAlgorithm.h"
56 
57 // Make these consistent with the other connectivity filters
58 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
59 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
60 #define VTK_EXTRACT_LARGEST_REGION 4
61 #define VTK_EXTRACT_ALL_REGIONS 5
62 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
63 
65 class vtkDataArray;
66 class vtkFloatArray;
67 class vtkIdList;
68 class vtkIdTypeArray;
69 class vtkIntArray;
70 
71 class VTKFILTERSPOINTS_EXPORT vtkConnectedPointsFilter : public vtkPolyDataAlgorithm
72 {
73 public:
75  void PrintSelf(ostream& os, vtkIndent indent) override;
76 
81 
83 
87  vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX);
88  vtkGetMacro(Radius, double);
90 
92 
95  vtkSetClampMacro(
97  vtkGetMacro(ExtractionMode, int);
99  {
100  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
101  }
104  {
105  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
106  }
108  {
109  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
110  }
111  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
112  const char* GetExtractionModeAsString();
114 
116 
120  vtkSetVector3Macro(ClosestPoint, double);
121  vtkGetVectorMacro(ClosestPoint, double, 3);
123 
128 
132  void AddSeed(vtkIdType id);
133 
138 
143 
148 
153 
155 
161  vtkSetMacro(AlignedNormals, int);
162  vtkGetMacro(AlignedNormals, int);
163  vtkBooleanMacro(AlignedNormals, int);
165 
167 
172  vtkSetClampMacro(NormalAngle, double, 0.0001, 90.0);
173  vtkGetMacro(NormalAngle, double);
175 
177 
182  vtkSetMacro(ScalarConnectivity, int);
183  vtkGetMacro(ScalarConnectivity, int);
184  vtkBooleanMacro(ScalarConnectivity, int);
186 
188 
191  vtkSetVector2Macro(ScalarRange, double);
192  vtkGetVector2Macro(ScalarRange, double);
194 
200 
202 
208  vtkGetObjectMacro(Locator, vtkAbstractPointLocator);
210 
211 protected:
214 
215  // Usual data generation method
218 
219  // The radius defines the proximal neighborhood of points
220  double Radius;
221 
222  // indicate how to extract regions
224 
225  // id's of points used to seed regions
227 
228  // regions specified for extraction
230 
231  // Seed with a closest point
232  double ClosestPoint[3];
233 
234  // Segment based on nearly aligned normals
236  double NormalAngle;
238 
239  // Support segmentation based on scalar connectivity
241  double ScalarRange[2];
242 
243  // accelerate searching
245 
246  // Wave propagation used to segment points
248  vtkPoints* inPts, vtkDataArray* inScalars, float* normals, vtkIdType* labels);
249 
250 private:
251  // used to support algorithm execution
252  vtkIdType CurrentRegionNumber;
253  vtkIdTypeArray* RegionLabels;
254  vtkIdType NumPointsInRegion;
255  vtkIdTypeArray* RegionSizes;
256  vtkIdList* NeighborPointIds; // avoid repetitive new/delete
257  vtkIdList* Wave;
258  vtkIdList* Wave2;
259 
260 private:
262  void operator=(const vtkConnectedPointsFilter&) = delete;
263 };
264 
266 
270 {
272  {
273  return "ExtractPointSeededRegions";
274  }
276  {
277  return "ExtractSpecifiedRegions";
278  }
279  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
280  {
281  return "ExtractAllRegions";
282  }
284  {
285  return "ExtractClosestPointRegion";
286  }
287  else
288  {
289  return "ExtractLargestRegion";
290  }
291 }
293 
294 #endif
abstract class to quickly locate points in 3-space
extract / segment points based on geometric connectivity
void TraverseAndMark(vtkPoints *inPts, vtkDataArray *inScalars, float *normals, vtkIdType *labels)
vtkAbstractPointLocator * Locator
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.
~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 AddSeed(vtkIdType id)
Add a non-negative point seed id.
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:50
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
list of point or cell ids
Definition: vtkIdList.h:31
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
represent and manipulate 3D points
Definition: vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
#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:338
#define VTK_DOUBLE_MAX
Definition: vtkType.h:165