VTK  9.3.1
vtkSelectPolyData.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
80 #ifndef vtkSelectPolyData_h
81 #define vtkSelectPolyData_h
82 
83 #include "vtkFiltersModelingModule.h" // For export macro
84 #include "vtkPolyDataAlgorithm.h"
85 
86 #define VTK_INSIDE_SMALLEST_REGION 0
87 #define VTK_INSIDE_LARGEST_REGION 1
88 #define VTK_INSIDE_CLOSEST_POINT_REGION 2
89 
90 #define VTK_GREEDY_EDGE_SEARCH 0
91 #define VTK_DIJKSTRA_EDGE_SEARCH 1
92 
93 VTK_ABI_NAMESPACE_BEGIN
94 class vtkCharArray;
95 class vtkPoints;
96 class vtkIdList;
97 
98 class VTKFILTERSMODELING_EXPORT vtkSelectPolyData : public vtkPolyDataAlgorithm
99 {
100 public:
106  static vtkSelectPolyData* New();
107 
109  void PrintSelf(ostream& os, vtkIndent indent) override;
110 
112 
119  vtkSetMacro(GenerateSelectionScalars, vtkTypeBool);
120  vtkGetMacro(GenerateSelectionScalars, vtkTypeBool);
121  vtkBooleanMacro(GenerateSelectionScalars, vtkTypeBool);
123 
125 
128  vtkSetStringMacro(SelectionScalarsArrayName);
129  vtkGetStringMacro(SelectionScalarsArrayName);
131 
133 
137  vtkSetMacro(InsideOut, vtkTypeBool);
138  vtkGetMacro(InsideOut, vtkTypeBool);
139  vtkBooleanMacro(InsideOut, vtkTypeBool);
141 
143 
151  vtkSetClampMacro(EdgeSearchMode, int, VTK_GREEDY_EDGE_SEARCH, VTK_DIJKSTRA_EDGE_SEARCH);
152  vtkGetMacro(EdgeSearchMode, int);
153  void SetEdgeSearchModeToGreedy() { this->SetEdgeSearchMode(VTK_GREEDY_EDGE_SEARCH); }
154  void SetEdgeSearchModeToDijkstra() { this->SetEdgeSearchMode(VTK_DIJKSTRA_EDGE_SEARCH); }
155  const char* GetEdgeSearchModeAsString();
157 
159 
163  virtual void SetLoop(vtkPoints*);
164  vtkGetObjectMacro(Loop, vtkPoints);
166 
168 
171  vtkSetVector3Macro(ClosestPoint, double);
172  vtkGetVector3Macro(ClosestPoint, double);
174 
176 
179  vtkSetClampMacro(SelectionMode, int, VTK_INSIDE_SMALLEST_REGION, VTK_INSIDE_CLOSEST_POINT_REGION);
180  vtkGetMacro(SelectionMode, int);
182  void SetSelectionModeToLargestRegion() { this->SetSelectionMode(VTK_INSIDE_LARGEST_REGION); }
184  {
185  this->SetSelectionMode(VTK_INSIDE_CLOSEST_POINT_REGION);
186  }
187  const char* GetSelectionModeAsString();
189 
191 
195  vtkSetMacro(GenerateUnselectedOutput, vtkTypeBool);
196  vtkGetMacro(GenerateUnselectedOutput, vtkTypeBool);
197  vtkBooleanMacro(GenerateUnselectedOutput, vtkTypeBool);
199 
204  vtkPolyData* GetUnselectedOutput();
205 
210  vtkAlgorithmOutput* GetUnselectedOutputPort();
211 
215  vtkPolyData* GetSelectionEdges();
216 
217  // Overload GetMTime() because we depend on Loop
218  vtkMTimeType GetMTime() override;
219 
220 protected:
222  ~vtkSelectPolyData() override;
223 
225 
226  // Compute point list that forms a continuous loop overy the mesh,
227  void GreedyEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
228  void DijkstraEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
229 
230  // Returns maximum front cell ID
231  vtkIdType ComputeTopologicalDistance(
232  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkIntArray* cellMarks);
233 
234  // Get closest cell to a position that is not at the boundary
235  vtkIdType GetClosestCellId(vtkPolyData* mesh, vtkIntArray* pointMarks);
236 
237  // Starting from maxFrontCell, without crossing the boundary, set all cell and point marks to -1.
238  void FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds, vtkIntArray* pointMarks,
239  vtkIntArray* cellMarks, vtkIdType cellIdInSelectedRegion);
240 
241  void SetClippedResultToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
242  vtkPolyData* mesh, vtkIntArray* cellMarks, vtkPolyData* output);
243 
244  void SetSelectionScalarsToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
245  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkPolyData* output);
246 
253  double ClosestPoint[3];
255 
256 private:
257  static void GetPointNeighbors(vtkPolyData* mesh, vtkIdType ptId, vtkIdList* nei);
258 
259  // Helper function to check if the edge between pointId1 and pointId2 is present in the
260  // edgePointIds (as direct neighbors).
261  static bool IsBoundaryEdge(vtkIdType pointId1, vtkIdType pointId2, vtkIdList* edgePointIds);
262 
263  vtkSelectPolyData(const vtkSelectPolyData&) = delete;
264  void operator=(const vtkSelectPolyData&) = delete;
265 };
266 
271 {
273  {
274  return "InsideSmallestRegion";
275  }
276  else if (this->SelectionMode == VTK_INSIDE_LARGEST_REGION)
277  {
278  return "InsideLargestRegion";
279  }
280  else
281  {
282  return "InsideClosestPointRegion";
283  }
284 }
285 
290 {
292  {
293  return "GreedyEdgeSearch";
294  }
295  else if (this->EdgeSearchMode == VTK_DIJKSTRA_EDGE_SEARCH)
296  {
297  return "DijkstraEdgeSearch";
298  }
299  else
300  {
301  // This should never occur
302  return "Invalid";
303  }
304 }
305 
306 VTK_ABI_NAMESPACE_END
307 #endif
#define VTK_GREEDY_EDGE_SEARCH
void SetSelectionModeToClosestPointRegion()
Control how inside/outside of loop is defined.
represent and manipulate point attribute data
Definition: vtkPointData.h:29
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
represent and manipulate cell attribute data
Definition: vtkCellData.h:30
vtkTypeBool GenerateSelectionScalars
int vtkIdType
Definition: vtkType.h:315
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
#define VTK_DIJKSTRA_EDGE_SEARCH
Proxy object to connect input/output ports.
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:40
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetEdgeSearchModeToGreedy()
Set the edge search mode.
list of point or cell ids
Definition: vtkIdList.h:22
void SetSelectionModeToSmallestRegion()
Control how inside/outside of loop is defined.
vtkTypeBool GenerateUnselectedOutput
virtual vtkMTimeType GetMTime()
Return this object's modified time.
const char * GetSelectionModeAsString()
Return the method of determining in/out of loop as a string.
select portion of polygonal mesh; generate selection scalars
void SetSelectionModeToLargestRegion()
Control how inside/outside of loop is defined.
void SetEdgeSearchModeToDijkstra()
Set the edge search mode.
#define VTK_INSIDE_LARGEST_REGION
#define VTK_INSIDE_SMALLEST_REGION
Store zero or more vtkInformation instances.
const char * GetEdgeSearchModeAsString()
Return the edge search mode as a string.
#define VTK_INSIDE_CLOSEST_POINT_REGION
represent and manipulate 3D points
Definition: vtkPoints.h:28
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.