VTK  9.3.0
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
89 #ifndef vtkSelectPolyData_h
90 #define vtkSelectPolyData_h
91 
92 #include "vtkFiltersModelingModule.h" // For export macro
93 #include "vtkPolyDataAlgorithm.h"
94 
95 #define VTK_INSIDE_SMALLEST_REGION 0
96 #define VTK_INSIDE_LARGEST_REGION 1
97 #define VTK_INSIDE_CLOSEST_POINT_REGION 2
98 
99 #define VTK_GREEDY_EDGE_SEARCH 0
100 #define VTK_DIJKSTRA_EDGE_SEARCH 1
101 
102 VTK_ABI_NAMESPACE_BEGIN
103 class vtkCharArray;
104 class vtkPoints;
105 class vtkIdList;
106 
107 class VTKFILTERSMODELING_EXPORT vtkSelectPolyData : public vtkPolyDataAlgorithm
108 {
109 public:
116 
118  void PrintSelf(ostream& os, vtkIndent indent) override;
119 
121 
128  vtkSetMacro(GenerateSelectionScalars, vtkTypeBool);
129  vtkGetMacro(GenerateSelectionScalars, vtkTypeBool);
130  vtkBooleanMacro(GenerateSelectionScalars, vtkTypeBool);
132 
134 
137  vtkSetStringMacro(SelectionScalarsArrayName);
138  vtkGetStringMacro(SelectionScalarsArrayName);
140 
142 
146  vtkSetMacro(InsideOut, vtkTypeBool);
147  vtkGetMacro(InsideOut, vtkTypeBool);
148  vtkBooleanMacro(InsideOut, vtkTypeBool);
150 
152 
160  vtkSetClampMacro(EdgeSearchMode, int, VTK_GREEDY_EDGE_SEARCH, VTK_DIJKSTRA_EDGE_SEARCH);
161  vtkGetMacro(EdgeSearchMode, int);
162  void SetEdgeSearchModeToGreedy() { this->SetEdgeSearchMode(VTK_GREEDY_EDGE_SEARCH); }
163  void SetEdgeSearchModeToDijkstra() { this->SetEdgeSearchMode(VTK_DIJKSTRA_EDGE_SEARCH); }
164  const char* GetEdgeSearchModeAsString();
166 
168 
172  virtual void SetLoop(vtkPoints*);
173  vtkGetObjectMacro(Loop, vtkPoints);
175 
177 
180  vtkSetVector3Macro(ClosestPoint, double);
181  vtkGetVector3Macro(ClosestPoint, double);
183 
185 
188  vtkSetClampMacro(SelectionMode, int, VTK_INSIDE_SMALLEST_REGION, VTK_INSIDE_CLOSEST_POINT_REGION);
189  vtkGetMacro(SelectionMode, int);
191  void SetSelectionModeToLargestRegion() { this->SetSelectionMode(VTK_INSIDE_LARGEST_REGION); }
193  {
194  this->SetSelectionMode(VTK_INSIDE_CLOSEST_POINT_REGION);
195  }
196  const char* GetSelectionModeAsString();
198 
200 
204  vtkSetMacro(GenerateUnselectedOutput, vtkTypeBool);
205  vtkGetMacro(GenerateUnselectedOutput, vtkTypeBool);
206  vtkBooleanMacro(GenerateUnselectedOutput, vtkTypeBool);
208 
214 
220 
225 
226  // Overload GetMTime() because we depend on Loop
227  vtkMTimeType GetMTime() override;
228 
229 protected:
231  ~vtkSelectPolyData() override;
232 
234 
235  // Compute point list that forms a continuous loop overy the mesh,
236  void GreedyEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
237  void DijkstraEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
238 
239  // Returns maximum front cell ID
241  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkIntArray* cellMarks);
242 
243  // Get closest cell to a position that is not at the boundary
245 
246  // Starting from maxFrontCell, without crossing the boundary, set all cell and point marks to -1.
247  void FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds, vtkIntArray* pointMarks,
248  vtkIntArray* cellMarks, vtkIdType cellIdInSelectedRegion);
249 
250  void SetClippedResultToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
251  vtkPolyData* mesh, vtkIntArray* cellMarks, vtkPolyData* output);
252 
253  void SetSelectionScalarsToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
254  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkPolyData* output);
255 
262  double ClosestPoint[3];
264 
265 private:
266  static void GetPointNeighbors(vtkPolyData* mesh, vtkIdType ptId, vtkIdList* nei);
267 
268  // Helper function to check if the edge between pointId1 and pointId2 is present in the
269  // edgePointIds (as direct neighbors).
270  static bool IsBoundaryEdge(vtkIdType pointId1, vtkIdType pointId2, vtkIdList* edgePointIds);
271 
272  vtkSelectPolyData(const vtkSelectPolyData&) = delete;
273  void operator=(const vtkSelectPolyData&) = delete;
274 };
275 
280 {
282  {
283  return "InsideSmallestRegion";
284  }
285  else if (this->SelectionMode == VTK_INSIDE_LARGEST_REGION)
286  {
287  return "InsideLargestRegion";
288  }
289  else
290  {
291  return "InsideClosestPointRegion";
292  }
293 }
294 
299 {
301  {
302  return "GreedyEdgeSearch";
303  }
304  else if (this->EdgeSearchMode == VTK_DIJKSTRA_EDGE_SEARCH)
305  {
306  return "DijkstraEdgeSearch";
307  }
308  else
309  {
310  // This should never occur
311  return "Invalid";
312  }
313 }
314 
315 VTK_ABI_NAMESPACE_END
316 #endif
Proxy object to connect input/output ports.
represent and manipulate cell attribute data
Definition: vtkCellData.h:40
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:50
list of point or cell ids
Definition: vtkIdList.h:32
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:44
represent and manipulate point attribute data
Definition: vtkPointData.h:39
represent and manipulate 3D points
Definition: vtkPoints.h:38
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
select portion of polygonal mesh; generate selection scalars
virtual void SetLoop(vtkPoints *)
Set/Get the array of point coordinates defining the loop.
vtkIdType ComputeTopologicalDistance(vtkPolyData *mesh, vtkIdList *edgeIds, vtkIntArray *pointMarks, vtkIntArray *cellMarks)
static vtkSelectPolyData * New()
Instantiate object with InsideOut turned off, and GenerateSelectionScalars turned off.
void SetSelectionScalarsToOutput(vtkPointData *originalPointData, vtkCellData *originalCellData, vtkPolyData *mesh, vtkIdList *edgeIds, vtkIntArray *pointMarks, vtkPolyData *output)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetSelectionModeToSmallestRegion()
Control how inside/outside of loop is defined.
void SetEdgeSearchModeToGreedy()
Set the edge search mode.
vtkPolyData * GetSelectionEdges()
Return the (mesh) edges of the selection region.
void SetSelectionModeToLargestRegion()
Control how inside/outside of loop is defined.
vtkTypeBool GenerateUnselectedOutput
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkIdType GetClosestCellId(vtkPolyData *mesh, vtkIntArray *pointMarks)
void SetClippedResultToOutput(vtkPointData *originalPointData, vtkCellData *originalCellData, vtkPolyData *mesh, vtkIntArray *cellMarks, vtkPolyData *output)
void DijkstraEdgeSearch(vtkPolyData *mesh, vtkIdList *edgeIds)
const char * GetSelectionModeAsString()
Return the method of determining in/out of loop as a string.
const char * GetEdgeSearchModeAsString()
Return the edge search mode as a string.
vtkTypeBool GenerateSelectionScalars
void SetSelectionModeToClosestPointRegion()
Control how inside/outside of loop is defined.
void FillMarksInRegion(vtkPolyData *mesh, vtkIdList *edgePointIds, vtkIntArray *pointMarks, vtkIntArray *cellMarks, vtkIdType cellIdInSelectedRegion)
void SetEdgeSearchModeToDijkstra()
Set the edge search mode.
vtkMTimeType GetMTime() override
Return this object's modified time.
void GreedyEdgeSearch(vtkPolyData *mesh, vtkIdList *edgeIds)
vtkAlgorithmOutput * GetUnselectedOutputPort()
Return output port that hasn't been selected (if GenreateUnselectedOutput is enabled).
~vtkSelectPolyData() override
vtkPolyData * GetUnselectedOutput()
Return output that hasn't been selected (if GenreateUnselectedOutput is enabled).
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_INSIDE_SMALLEST_REGION
#define VTK_DIJKSTRA_EDGE_SEARCH
#define VTK_INSIDE_LARGEST_REGION
#define VTK_GREEDY_EDGE_SEARCH
#define VTK_INSIDE_CLOSEST_POINT_REGION
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270