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 =========================================================================*/
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(ExtractionMode,int,
100  vtkGetMacro(ExtractionMode,int);
102  {this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);};
104  {this->SetExtractionMode(VTK_EXTRACT_LARGEST_REGION);};
106  {this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);};
108  {this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);};
110  {this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS);};
111  const char *GetExtractionModeAsString();
113 
115 
119  vtkSetVector3Macro(ClosestPoint,double);
120  vtkGetVectorMacro(ClosestPoint,double,3);
122 
126  void InitializeSeedList();
127 
131  void AddSeed(vtkIdType id);
132 
136  void DeleteSeed(vtkIdType id);
137 
141  void InitializeSpecifiedRegionList();
142 
146  void AddSpecifiedRegion(vtkIdType id);
147 
151  void DeleteSpecifiedRegion(vtkIdType id);
152 
154 
160  vtkSetMacro(AlignedNormals,int);
161  vtkGetMacro(AlignedNormals,int);
162  vtkBooleanMacro(AlignedNormals,int);
164 
166 
171  vtkSetClampMacro(NormalAngle,double,0.0001, 90.0);
172  vtkGetMacro(NormalAngle,double);
174 
176 
181  vtkSetMacro(ScalarConnectivity,int);
182  vtkGetMacro(ScalarConnectivity,int);
183  vtkBooleanMacro(ScalarConnectivity,int);
185 
187 
190  vtkSetVector2Macro(ScalarRange,double);
191  vtkGetVector2Macro(ScalarRange,double);
193 
198  int GetNumberOfExtractedRegions();
199 
201 
206  void SetLocator(vtkAbstractPointLocator *locator);
207  vtkGetObjectMacro(Locator,vtkAbstractPointLocator);
209 
210 protected:
212  ~vtkConnectedPointsFilter() override;
213 
214  // Usual data generation method
216  int FillInputPortInformation(int port, vtkInformation *info) override;
217 
218  // The radius defines the proximal neighborhood of points
219  double Radius;
220 
221  // indicate how to extract regions
223 
224  // id's of points used to seed regions
226 
227  //regions specified for extraction
229 
230  // Seed with a closest point
231  double ClosestPoint[3];
232 
233  // Segment based on nearly aligned normals
235  double NormalAngle;
237 
238  // Support segmentation based on scalar connectivity
240  double ScalarRange[2];
241 
242  // accelerate searching
244 
245  // Wave propagation used to segment points
246  void TraverseAndMark (vtkPoints *inPts, vtkDataArray *inScalars,
247  float *normals, vtkIdType *labels);
248 
249 private:
250  // used to support algorithm execution
251  vtkIdType CurrentRegionNumber;
252  vtkIdTypeArray *RegionLabels;
253  vtkIdType NumPointsInRegion;
254  vtkIdTypeArray *RegionSizes;
255  vtkIdList *NeighborPointIds; //avoid repetitive new/delete
256  vtkIdList *Wave;
257  vtkIdList *Wave2;
258 
259 private:
261  void operator=(const vtkConnectedPointsFilter&) = delete;
262 };
263 
265 
269 {
270  if ( this->ExtractionMode == VTK_EXTRACT_POINT_SEEDED_REGIONS )
271  {
272  return "ExtractPointSeededRegions";
273  }
274  else if ( this->ExtractionMode == VTK_EXTRACT_SPECIFIED_REGIONS )
275  {
276  return "ExtractSpecifiedRegions";
277  }
278  else if ( this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS )
279  {
280  return "ExtractAllRegions";
281  }
282  else if ( this->ExtractionMode == VTK_EXTRACT_CLOSEST_POINT_REGION )
283  {
284  return "ExtractClosestPointRegion";
285  }
286  else
287  {
288  return "ExtractLargestRegion";
289  }
290 }
292 
293 #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:169
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:347
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:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#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.