VTK
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 
80  static vtkConnectedPointsFilter *New();
81 
83 
87  vtkSetClampMacro(Radius,double,0.0,VTK_DOUBLE_MAX);
88  vtkGetMacro(Radius,double);
90 
92 
95  vtkSetClampMacro(ExtractionMode,int,
97  vtkGetMacro(ExtractionMode,int);
99  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
101  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
103  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
105  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
107  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
108  const char *GetExtractionModeAsString();
110 
112 
116  vtkSetVector3Macro(ClosestPoint,double);
117  vtkGetVectorMacro(ClosestPoint,double,3);
119 
123  void InitializeSeedList();
124 
128  void AddSeed(vtkIdType id);
129 
133  void DeleteSeed(vtkIdType id);
134 
138  void InitializeSpecifiedRegionList();
139 
143  void AddSpecifiedRegion(vtkIdType id);
144 
148  void DeleteSpecifiedRegion(vtkIdType id);
149 
151 
157  vtkSetMacro(AlignedNormals,int);
158  vtkGetMacro(AlignedNormals,int);
159  vtkBooleanMacro(AlignedNormals,int);
161 
163 
168  vtkSetClampMacro(NormalAngle,double,0.0001, 90.0);
169  vtkGetMacro(NormalAngle,double);
171 
173 
178  vtkSetMacro(ScalarConnectivity,int);
179  vtkGetMacro(ScalarConnectivity,int);
180  vtkBooleanMacro(ScalarConnectivity,int);
182 
184 
187  vtkSetVector2Macro(ScalarRange,double);
188  vtkGetVector2Macro(ScalarRange,double);
190 
195  int GetNumberOfExtractedRegions();
196 
198 
203  void SetLocator(vtkAbstractPointLocator *locator);
204  vtkGetObjectMacro(Locator,vtkAbstractPointLocator);
206 
207 protected:
209  ~vtkConnectedPointsFilter() override;
210 
211  // Usual data generation method
213  int FillInputPortInformation(int port, vtkInformation *info) override;
214 
215  // The radius defines the proximal neighborhood of points
216  double Radius;
217 
218  // indicate how to extract regions
220 
221  // id's of points used to seed regions
223 
224  //regions specified for extraction
226 
227  // Seed with a closest point
228  double ClosestPoint[3];
229 
230  // Segment based on nearly aligned normals
232  double NormalAngle;
234 
235  // Support segmentation based on scalar connectivity
237  double ScalarRange[2];
238 
239  // accelerate searching
241 
242  // Wave propagation used to segment points
243  void TraverseAndMark (vtkPoints *inPts, vtkDataArray *inScalars,
244  float *normals, vtkIdType *labels);
245 
246 private:
247  // used to support algorithm execution
248  vtkIdType CurrentRegionNumber;
249  vtkIdTypeArray *RegionLabels;
250  vtkIdType NumPointsInRegion;
251  vtkIdTypeArray *RegionSizes;
252  vtkIdList *NeighborPointIds; //avoid repetitive new/delete
253  vtkIdList *Wave;
254  vtkIdList *Wave2;
255 
256 private:
258  void operator=(const vtkConnectedPointsFilter&) = delete;
259 };
260 
262 
266 {
268  {
269  return "ExtractPointSeededRegions";
270  }
271  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
272  {
273  return "ExtractSpecifiedRegions";
274  }
275  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
276  {
277  return "ExtractAllRegions";
278  }
280  {
281  return "ExtractClosestPointRegion";
282  }
283  else
284  {
285  return "ExtractLargestRegion";
286  }
287 }
289 
290 #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:167
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:35
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:345
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected regions.
static vtkPolyDataAlgorithm * New()
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:33
abstract class to quickly locate points in 3-space
list of point or cell ids
Definition: vtkIdList.h:30
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
#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:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.