VTK  9.2.5
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 
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 
215 
219  void AddSeed(int id);
220 
224  void DeleteSeed(int id);
225 
230 
234  void AddSpecifiedRegion(int id);
235 
239  void DeleteSpecifiedRegion(int id);
240 
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
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
369  vtkIdType cellId, vtkIdType npts, const vtkIdType* pts, vtkIdList* neis);
372 
373  // Methods implementing iterative region growing
376  int CurrentGrowPass; // region growing is a multiple-pass process
378  void ExchangeRegions(vtkIdType currentRegionId, vtkIdType neiId, vtkIdType neiRegId);
381  int AssimilateCell(vtkIdType cellId, vtkIdType npts, const vtkIdType* pts);
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
Proxy object to connect input/output ports.
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:71
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
keep track of edges (edge is pair of integer id's)
Definition: vtkEdgeTable.h:41
list of point or cell ids
Definition: vtkIdList.h:143
dynamic, self-adjusting array of vtkIdType
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only polydata as output.
segment polygonal mesh based on shared edge connectivity
void GrowLargeRegionsOff()
Specify a strategy for region growing.
void SetExtractionModeToLargeRegions()
Control the extraction of connected surfaces.
void GrowSmallRegionsOn()
Specify a strategy for region growing.
void SetRegionGrowingToLargeRegions()
Specify a strategy for region growing.
void GrowLargeRegionsOn()
Specify a strategy for region growing.
int GetNumberOfSpecifiedRegions()
Get number of specified regions.
vtkSmartPointer< vtkIdTypeArray > RegionSizes
int AssimilateCell(vtkIdType cellId, vtkIdType npts, const vtkIdType *pts)
int IsScalarConnected(vtkIdType cellId, vtkIdType neiId)
void GrowSmallRegionsOff()
Specify a strategy for region growing.
const char * GetExtractionModeAsString()
Return the method of extraction as a string.
int FillInputPortInformation(int, vtkInformation *) override
Fill the input port information objects for this algorithm.
void SetExtractionModeToLargestRegion()
Control the extraction of connected surfaces.
void SetSourceData(vtkPolyData *)
Specify the source vtkPolyData object used to specify barrier edges (this is an optional connection....
void SetExtractionModeToAllRegions()
Control the extraction of connected surfaces.
void SetRegionGrowingToSmallRegions()
Specify a strategy for region growing.
void ExchangeRegions(vtkIdType currentRegionId, vtkIdType neiId, vtkIdType neiRegId)
static vtkPolyDataEdgeConnectivityFilter * New()
Standard methods to instantiate, get type information, and print the object.
void SetExtractionModeToSpecifiedRegions()
Control the extraction of connected surfaces.
vtkPolyData * GetSource()
Specify the source vtkPolyData object used to specify barrier edges (this is an optional connection....
void SetExtractionModeToPointSeededRegions()
Control the extraction of connected surfaces.
void SetSourceConnection(vtkAlgorithmOutput *algOutput)
Specify the source vtkPolyData object used to specify barrier edges (this is an optional connection....
void InitializeSeedList()
Initialize list of point ids/cell ids used to seed regions.
void SetExtractionModeToCellSeededRegions()
Control the extraction of connected surfaces.
void SetRegionGrowingOff()
Specify a strategy for region growing.
void DeleteSpecifiedRegion(int id)
Delete a region id to extract.
bool IsBarrierEdge(vtkIdType p0, vtkIdType p1)
int GetNumberOfExtractedRegions()
Obtain the number of connected regions found.
void SetExtractionModeToClosestPointRegion()
Control the extraction of connected surfaces.
void DeleteSeed(int id)
Delete a seed id (point or cell id).
void GetConnectedNeighbors(vtkIdType cellId, vtkIdType npts, const vtkIdType *pts, vtkIdList *neis)
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void AddSpecifiedRegion(int id)
Add a region id to extract.
void AddSeed(int id)
Add a seed id (point or cell id).
void InitializeSpecifiedRegionList()
Initialize list of region ids to extract.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods to instantiate, get type information, and print the object.
double GetTotalArea()
Obtain the total area of all regions combined.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_EXTRACT_CLOSEST_POINT_REGION
#define VTK_EXTRACT_POINT_SEEDED_REGIONS
#define VTK_EXTRACT_ALL_REGIONS
#define VTK_EXTRACT_CELL_SEEDED_REGIONS
#define VTK_EXTRACT_LARGE_REGIONS
#define VTK_EXTRACT_SPECIFIED_REGIONS
#define VTK_EXTRACT_LARGEST_REGION
int vtkIdType
Definition: vtkType.h:332