VTK  9.2.6
vtkPolyDataEdgeConnectivityFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPolyDataEdgeConnectivityFilter.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 =========================================================================*/
85 #ifndef vtkPolyDataEdgeConnectivityFilter_h
86 #define vtkPolyDataEdgeConnectivityFilter_h
87 
88 #include "vtkFiltersCoreModule.h" // For export macro
89 #include "vtkIdTypeArray.h" //
90 #include "vtkPolyDataAlgorithm.h"
91 
92 #define VTK_EXTRACT_POINT_SEEDED_REGIONS 1
93 #define VTK_EXTRACT_CELL_SEEDED_REGIONS 2
94 #define VTK_EXTRACT_SPECIFIED_REGIONS 3
95 #define VTK_EXTRACT_LARGEST_REGION 4
96 #define VTK_EXTRACT_ALL_REGIONS 5
97 #define VTK_EXTRACT_CLOSEST_POINT_REGION 6
98 #define VTK_EXTRACT_LARGE_REGIONS 7
99 
100 class vtkDataArray;
101 class vtkCharArray;
102 class vtkIdList;
103 class vtkIdTypeArray;
104 class vtkEdgeTable;
105 
106 class VTKFILTERSCORE_EXPORT vtkPolyDataEdgeConnectivityFilter : public vtkPolyDataAlgorithm
107 {
108 public:
110 
115  void PrintSelf(ostream& os, vtkIndent indent) override;
117 
119 
122  vtkSetClampMacro(
124  vtkGetMacro(ExtractionMode, int);
126  {
127  this->SetExtractionMode(VTK_EXTRACT_POINT_SEEDED_REGIONS);
128  }
130  {
131  this->SetExtractionMode(VTK_EXTRACT_CELL_SEEDED_REGIONS);
132  }
135  {
136  this->SetExtractionMode(VTK_EXTRACT_SPECIFIED_REGIONS);
137  }
139  {
140  this->SetExtractionMode(VTK_EXTRACT_CLOSEST_POINT_REGION);
141  }
142  void SetExtractionModeToLargeRegions() { this->SetExtractionMode(VTK_EXTRACT_LARGE_REGIONS); }
143  void SetExtractionModeToAllRegions() { this->SetExtractionMode(VTK_EXTRACT_ALL_REGIONS); }
144  const char* GetExtractionModeAsString();
146 
148 
153  vtkSetMacro(BarrierEdges, vtkTypeBool);
154  vtkGetMacro(BarrierEdges, vtkTypeBool);
155  vtkBooleanMacro(BarrierEdges, vtkTypeBool);
157 
159 
166  void SetSourceData(vtkPolyData*);
167  void SetSourceConnection(vtkAlgorithmOutput* algOutput);
168  vtkPolyData* GetSource();
170 
172 
180  vtkSetVector2Macro(BarrierEdgeLength, double);
181  vtkGetVector2Macro(BarrierEdgeLength, double);
183 
185 
190  vtkSetMacro(ScalarConnectivity, vtkTypeBool);
191  vtkGetMacro(ScalarConnectivity, vtkTypeBool);
192  vtkBooleanMacro(ScalarConnectivity, vtkTypeBool);
194 
196 
199  vtkSetVector2Macro(ScalarRange, double);
200  vtkGetVector2Macro(ScalarRange, double);
202 
204 
208  vtkGetObjectMacro(RegionSizes, vtkIdTypeArray);
210 
214  void InitializeSeedList();
215 
219  void AddSeed(int id);
220 
224  void DeleteSeed(int id);
225 
229  void InitializeSpecifiedRegionList();
230 
234  void AddSpecifiedRegion(int id);
235 
239  void DeleteSpecifiedRegion(int id);
240 
244  int GetNumberOfSpecifiedRegions();
245 
247 
251  vtkSetVector3Macro(ClosestPoint, double);
252  vtkGetVectorMacro(ClosestPoint, double, 3);
254 
255  // Control the region growing process.
257  {
258  RegionGrowingOff = 0,
259  LargeRegions = 1,
260  SmallRegions = 2
261  };
262 
264 
274  vtkSetClampMacro(RegionGrowing, int, RegionGrowingOff, SmallRegions);
275  vtkGetMacro(RegionGrowing, int);
276  void SetRegionGrowingOff() { this->SetRegionGrowing(RegionGrowingOff); }
277  void GrowLargeRegionsOff() { this->SetRegionGrowing(RegionGrowingOff); }
278  void GrowSmallRegionsOff() { this->SetRegionGrowing(RegionGrowingOff); }
279  void SetRegionGrowingToLargeRegions() { this->SetRegionGrowing(LargeRegions); }
280  void GrowLargeRegionsOn() { this->SetRegionGrowing(LargeRegions); }
281  void SetRegionGrowingToSmallRegions() { this->SetRegionGrowing(SmallRegions); }
282  void GrowSmallRegionsOn() { this->SetRegionGrowing(SmallRegions); }
284 
286 
294  vtkSetClampMacro(LargeRegionThreshold, double, 0.0, 1.0);
295  vtkGetMacro(LargeRegionThreshold, double);
297 
302  int GetNumberOfExtractedRegions() { return this->NumberOfExtractedRegions; }
303 
307  double GetTotalArea() { return this->TotalArea; }
308 
310 
315  vtkSetMacro(ColorRegions, vtkTypeBool);
316  vtkGetMacro(ColorRegions, vtkTypeBool);
317  vtkBooleanMacro(ColorRegions, vtkTypeBool);
319 
321 
326  vtkSetMacro(CellRegionAreas, vtkTypeBool);
327  vtkGetMacro(CellRegionAreas, vtkTypeBool);
328  vtkBooleanMacro(CellRegionAreas, vtkTypeBool);
330 
332 
337  vtkSetMacro(OutputPointsPrecision, int);
338  vtkGetMacro(OutputPointsPrecision, int);
340 
341 protected:
344 
345  // Usual data generation method
347 
348  // Optional second input
349  int FillInputPortInformation(int, vtkInformation*) override;
350 
351  // Filter data members
352  vtkTypeBool ColorRegions; // boolean turns on/off scalar generation for separate regions
353  vtkTypeBool CellRegionAreas; // for each cell, the area of the region the cell is associated with
354 
355  int ExtractionMode; // how to extract regions
356  vtkTypeBool BarrierEdges; // enable barrier edges
357  double BarrierEdgeLength[2]; // edges of length within this range are barrier edges
359  double ScalarRange[2];
360  std::vector<vtkIdType> Seeds; // id's of points or cells used to seed regions
361  std::vector<vtkIdType> SpecifiedRegionIds; // regions specified for extraction
362  vtkSmartPointer<vtkIdTypeArray> RegionSizes; // size (in cells) of each region extracted
363  double ClosestPoint[3];
365 
366  // Methods for iterative traversal and marking cells
367  void TraverseAndMark();
368  void GetConnectedNeighbors(
369  vtkIdType cellId, vtkIdType npts, const vtkIdType* pts, vtkIdList* neis);
370  int IsScalarConnected(vtkIdType cellId, vtkIdType neiId);
371  bool IsBarrierEdge(vtkIdType p0, vtkIdType p1);
372 
373  // Methods implementing iterative region growing
376  int CurrentGrowPass; // region growing is a multiple-pass process
377  double ComputeRegionAreas();
378  void ExchangeRegions(vtkIdType currentRegionId, vtkIdType neiId, vtkIdType neiRegId);
379  void GrowLargeRegions();
380  void GrowSmallRegions();
381  int AssimilateCell(vtkIdType cellId, vtkIdType npts, const vtkIdType* pts);
382  void SortRegionsByArea();
383  vtkIdType FindNumberOfExtractedRegions();
384 
385  double TotalArea; // the total area of the input mesh
386  std::vector<double> CellAreas; // the area of each polygonal cell
387  std::vector<double> RegionAreas; // the total area of each region
388  std::vector<char> RegionClassification; // indicate whether the region is large or small
389 
390  // used to support algorithm execution
391  std::vector<vtkIdType> RegionIds;
392  std::vector<vtkIdType> PointMap;
400  std::vector<vtkIdType> Wave;
401  std::vector<vtkIdType> Wave2;
406  double BRange2[2]; // BarrierEdgeLenght[0,1]**2 of edge lengths defining barriers
407 
408 private:
410  void operator=(const vtkPolyDataEdgeConnectivityFilter&) = delete;
411 };
412 
417 {
419  {
420  return "ExtractPointSeededRegions";
421  }
423  {
424  return "ExtractCellSeededRegions";
425  }
427  {
428  return "ExtractSpecifiedRegions";
429  }
430  else if (this->ExtractionMode == VTK_EXTRACT_ALL_REGIONS)
431  {
432  return "ExtractAllRegions";
433  }
435  {
436  return "ExtractClosestPointRegion";
437  }
438  else if (this->ExtractionMode == VTK_EXTRACT_LARGE_REGIONS)
439  {
440  return "ExtractLargeRegions";
441  }
442  else
443  {
444  return "ExtractLargestRegion";
445  }
446 }
447 
448 #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:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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:40
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:69
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:51
Superclass for algorithms that produce only polydata as output.
#define VTK_EXTRACT_LARGEST_REGION
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
list of point or cell ids
Definition: vtkIdList.h:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
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.
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.