VTK  9.7.1
vtkPolyDataEdgeConnectivityFilter.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
73 #ifndef vtkPolyDataEdgeConnectivityFilter_h
74 #define vtkPolyDataEdgeConnectivityFilter_h
75 
76 #include "vtkFiltersCoreModule.h" // For export macro
77 #include "vtkIdTypeArray.h" //
78 #include "vtkPolyDataAlgorithm.h"
79 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
80 
81 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
82 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
83 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
84 #define VTK_EXTRACT_LARGEST_REGION 4
85 #define VTK_EXTRACT_ALL_REGIONS 5
86 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
87 #define VTK_EXTRACT_LARGE_REGIONS 7
88 
89 VTK_ABI_NAMESPACE_BEGIN
90 class vtkDataArray;
91 class vtkCharArray;
92 class vtkIdList;
93 class vtkIdTypeArray;
94 class vtkEdgeTable;
95 
97  : public vtkPolyDataAlgorithm
98 {
99 public:
101 
106  void PrintSelf(ostream& os, vtkIndent indent) override;
108 
110 
113  vtkSetClampMacro(
115  vtkGetMacro(ExtractionMode, int);
117  {
118  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
119  }
121  {
122  this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
123  }
126  {
127  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
128  }
130  {
131  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
132  }
133  void SetExtractionModeToLargeRegions() { this->SetExtractionMode(VTK_EXTRACT_LARGE_REGIONS); }
134  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
135  const char* GetExtractionModeAsString();
137 
139 
144  vtkSetMacro(BarrierEdges, vtkTypeBool);
145  vtkGetMacro(BarrierEdges, vtkTypeBool);
146  vtkBooleanMacro(BarrierEdges, vtkTypeBool);
148 
150 
157  void SetSourceData(vtkPolyData*);
158  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
159  vtkPolyData* GetSource();
161 
163 
171  vtkSetVector2Macro(BarrierEdgeLength, double);
172  vtkGetVector2Macro(BarrierEdgeLength, double);
174 
176 
181  vtkSetMacro(ScalarConnectivity, vtkTypeBool);
182  vtkGetMacro(ScalarConnectivity, vtkTypeBool);
183  vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
185 
187 
190  vtkSetVector2Macro(ScalarRange, double);
191  vtkGetVector2Macro(ScalarRange, double);
193 
195 
199  vtkGetObjectMacro(RegionSizes, vtkIdTypeArray);
201 
205  void InitializeSeedList();
206 
210  void AddSeed(int id);
211 
215  void DeleteSeed(int id);
216 
220  void InitializeSpecifiedRegionList();
221 
225  void AddSpecifiedRegion(int id);
226 
230  void DeleteSpecifiedRegion(int id);
231 
235  int GetNumberOfSpecifiedRegions();
236 
238 
242  vtkSetVector3Macro(ClosestPoint, double);
243  vtkGetVectorMacro(ClosestPoint, double, 3);
245 
246  // Control the region growing process.
248  {
249  RegionGrowingOff = 0,
250  LargeRegions = 1,
251  SmallRegions = 2
252  };
253 
255 
265  vtkSetClampMacro(RegionGrowing, int, RegionGrowingOff, SmallRegions);
266  vtkGetMacro(RegionGrowing, int);
267  void SetRegionGrowingOff() { this->SetRegionGrowing(RegionGrowingOff); }
268  void GrowLargeRegionsOff() { this->SetRegionGrowing(RegionGrowingOff); }
269  void GrowSmallRegionsOff() { this->SetRegionGrowing(RegionGrowingOff); }
270  void SetRegionGrowingToLargeRegions() { this->SetRegionGrowing(LargeRegions); }
271  void GrowLargeRegionsOn() { this->SetRegionGrowing(LargeRegions); }
272  void SetRegionGrowingToSmallRegions() { this->SetRegionGrowing(SmallRegions); }
273  void GrowSmallRegionsOn() { this->SetRegionGrowing(SmallRegions); }
275 
277 
285  vtkSetClampMacro(LargeRegionThreshold, double, 0.0, 1.0);
286  vtkGetMacro(LargeRegionThreshold, double);
288 
293  int GetNumberOfExtractedRegions() { return this->NumberOfExtractedRegions; }
294 
298  double GetTotalArea() { return this->TotalArea; }
299 
301 
306  vtkSetMacro(ColorRegions, vtkTypeBool);
307  vtkGetMacro(ColorRegions, vtkTypeBool);
308  vtkBooleanMacro(ColorRegions, vtkTypeBool);
310 
312 
317  vtkSetMacro(CellRegionAreas, vtkTypeBool);
318  vtkGetMacro(CellRegionAreas, vtkTypeBool);
319  vtkBooleanMacro(CellRegionAreas, vtkTypeBool);
321 
323 
328  vtkSetMacro(OutputPointsPrecision, int);
329  vtkGetMacro(OutputPointsPrecision, int);
331 
332 protected:
335 
336  // Usual data generation method
338 
339  // Optional second input
340  int FillInputPortInformation(int, vtkInformation*) override;
341 
342  // Filter data members
343  vtkTypeBool ColorRegions; // boolean turns on/off scalar generation for separate regions
344  vtkTypeBool CellRegionAreas; // for each cell, the area of the region the cell is associated with
345 
346  int ExtractionMode; // how to extract regions
347  vtkTypeBool BarrierEdges; // enable barrier edges
348  double BarrierEdgeLength[2]; // edges of length within this range are barrier edges
350  double ScalarRange[2];
351  std::vector<vtkIdType> Seeds; // id's of points or cells used to seed regions
352  std::vector<vtkIdType> SpecifiedRegionIds; // regions specified for extraction
353  vtkSmartPointer<vtkIdTypeArray> RegionSizes; // size (in cells) of each region extracted
354  double ClosestPoint[3];
356 
357  // Methods for iterative traversal and marking cells
358  void TraverseAndMark();
359  void GetConnectedNeighbors(
360  vtkIdType cellId, vtkIdType npts, const vtkIdType* pts, vtkIdList* neis);
361  int IsScalarConnected(vtkIdType cellId, vtkIdType neiId);
362  bool IsBarrierEdge(vtkIdType p0, vtkIdType p1);
363 
364  // Methods implementing iterative region growing
367  int CurrentGrowPass; // region growing is a multiple-pass process
368  double ComputeRegionAreas();
369  void ExchangeRegions(vtkIdType currentRegionId, vtkIdType neiId, vtkIdType neiRegId);
370  void GrowLargeRegions();
371  void GrowSmallRegions();
372  int AssimilateCell(vtkIdType cellId, vtkIdType npts, const vtkIdType* pts);
373  void SortRegionsByArea();
374  vtkIdType FindNumberOfExtractedRegions();
375 
376  double TotalArea; // the total area of the input mesh
377  std::vector<double> CellAreas; // the area of each polygonal cell
378  std::vector<double> RegionAreas; // the total area of each region
379  std::vector<char> RegionClassification; // indicate whether the region is large or small
380 
381  // used to support algorithm execution
382  std::vector<vtkIdType> RegionIds;
383  std::vector<vtkIdType> PointMap;
391  std::vector<vtkIdType> Wave;
392  std::vector<vtkIdType> Wave2;
397  double BRange2[2]; // BarrierEdgeLength[0,1]**2 of edge lengths defining barriers
398 
399 private:
401  void operator=(const vtkPolyDataEdgeConnectivityFilter&) = delete;
402 };
403 
408 {
410  {
411  return "ExtractPointSeededRegions";
412  }
414  {
415  return "ExtractCellSeededRegions";
416  }
418  {
419  return "ExtractSpecifiedRegions";
420  }
421  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
422  {
423  return "ExtractAllRegions";
424  }
426  {
427  return "ExtractClosestPointRegion";
428  }
429  else if (this->ExtractionMode == VTK_EXTRACT_LARGE_REGIONS)
430  {
431  return "ExtractLargeRegions";
432  }
433  else
434  {
435  return "ExtractLargestRegion";
436  }
437 }
438 
439 VTK_ABI_NAMESPACE_END
440 #endif
void GrowSmallRegionsOff()
Specify a strategy for region growing.
#define VTK_EXTRACT_SPECIFIED_REGIONS
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
Store vtkAlgorithm input/output information.
void SetRegionGrowingToSmallRegions()
Specify a strategy for region growing.
double GetTotalArea()
Obtain the total area of all regions combined.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
int GetNumberOfExtractedRegions()
Obtain the number of connected regions found.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
segment polygonal mesh based on shared edge connectivity
dynamic, self-adjusting array of vtkIdType
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
vtkSmartPointer< vtkIdTypeArray > RegionSizes
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:30
Proxy object to connect input/output ports.
#define VTK_EXTRACT_ALL_REGIONS
void GrowSmallRegionsOn()
Specify a strategy for region growing.
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:44
Superclass for algorithms that produce only polydata as output.
#define VTK_EXTRACT_LARGEST_REGION
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
list of point or cell ids
Definition: vtkIdList.h:25
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
void SetExtractionModeToLargeRegions()
Control the extraction of connected surfaces.
void GrowLargeRegionsOn()
Specify a strategy for region growing.
void SetRegionGrowingOff()
Specify a strategy for region growing.
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
void GrowLargeRegionsOff()
Specify a strategy for region growing.
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_LARGE_REGIONS
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
Store zero or more vtkInformation instances.
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
#define VTK_MARSHALAUTO
void SetRegionGrowingToLargeRegions()
Specify a strategy for region growing.
#define VTK_EXTRACT_CLOSEST_POINT_REGION
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.