VTK  9.2.6
vtkSelectPolyData.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSelectPolyData.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 =========================================================================*/
92 #ifndef vtkSelectPolyData_h
93 #define vtkSelectPolyData_h
94 
95 #include "vtkFiltersModelingModule.h" // For export macro
96 #include "vtkPolyDataAlgorithm.h"
97 
98 #define VTK_INSIDE_SMALLEST_REGION 0
99 #define VTK_INSIDE_LARGEST_REGION 1
100 #define VTK_INSIDE_CLOSEST_POINT_REGION 2
101 
102 #define VTK_GREEDY_EDGE_SEARCH 0
103 #define VTK_DIJKSTRA_EDGE_SEARCH 1
104 
105 class vtkCharArray;
106 class vtkPoints;
107 class vtkIdList;
108 
109 class VTKFILTERSMODELING_EXPORT vtkSelectPolyData : public vtkPolyDataAlgorithm
110 {
111 public:
117  static vtkSelectPolyData* New();
118 
120  void PrintSelf(ostream& os, vtkIndent indent) override;
121 
123 
130  vtkSetMacro(GenerateSelectionScalars, vtkTypeBool);
131  vtkGetMacro(GenerateSelectionScalars, vtkTypeBool);
132  vtkBooleanMacro(GenerateSelectionScalars, vtkTypeBool);
134 
136 
140  vtkSetMacro(InsideOut, vtkTypeBool);
141  vtkGetMacro(InsideOut, vtkTypeBool);
142  vtkBooleanMacro(InsideOut, vtkTypeBool);
144 
146 
154  vtkSetClampMacro(EdgeSearchMode, int, VTK_GREEDY_EDGE_SEARCH, VTK_DIJKSTRA_EDGE_SEARCH);
155  vtkGetMacro(EdgeSearchMode, int);
156  void SetEdgeSearchModeToGreedy() { this->SetEdgeSearchMode(VTK_GREEDY_EDGE_SEARCH); }
157  void SetEdgeSearchModeToDijkstra() { this->SetEdgeSearchMode(VTK_DIJKSTRA_EDGE_SEARCH); }
158  const char* GetEdgeSearchModeAsString();
160 
162 
166  virtual void SetLoop(vtkPoints*);
167  vtkGetObjectMacro(Loop, vtkPoints);
169 
171 
174  vtkSetVector3Macro(ClosestPoint, double);
175  vtkGetVector3Macro(ClosestPoint, double);
177 
179 
182  vtkSetClampMacro(SelectionMode, int, VTK_INSIDE_SMALLEST_REGION, VTK_INSIDE_CLOSEST_POINT_REGION);
183  vtkGetMacro(SelectionMode, int);
185  void SetSelectionModeToLargestRegion() { this->SetSelectionMode(VTK_INSIDE_LARGEST_REGION); }
187  {
188  this->SetSelectionMode(VTK_INSIDE_CLOSEST_POINT_REGION);
189  }
190  const char* GetSelectionModeAsString();
192 
194 
198  vtkSetMacro(GenerateUnselectedOutput, vtkTypeBool);
199  vtkGetMacro(GenerateUnselectedOutput, vtkTypeBool);
200  vtkBooleanMacro(GenerateUnselectedOutput, vtkTypeBool);
202 
207  vtkPolyData* GetUnselectedOutput();
208 
213  vtkAlgorithmOutput* GetUnselectedOutputPort();
214 
218  vtkPolyData* GetSelectionEdges();
219 
220  // Overload GetMTime() because we depend on Loop
221  vtkMTimeType GetMTime() override;
222 
223 protected:
225  ~vtkSelectPolyData() override;
226 
228 
229  // Compute point list that forms a continuous loop overy the mesh,
230  void GreedyEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
231  void DijkstraEdgeSearch(vtkPolyData* mesh, vtkIdList* edgeIds);
232 
233  // Returns maximum front cell ID
234  vtkIdType ComputeTopologicalDistance(
235  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkIntArray* cellMarks);
236 
237  // Get closest cell to a position that is not at the boundary
238  vtkIdType GetClosestCellId(vtkPolyData* mesh, vtkIntArray* pointMarks);
239 
240  // Starting from maxFrontCell, without crossing the boundary, set all cell and point marks to -1.
241  void FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds, vtkIntArray* pointMarks,
242  vtkIntArray* cellMarks, vtkIdType cellIdInSelectedRegion);
243 
244  void SetClippedResultToOutput(vtkPointData* originalPointData, vtkPolyData* mesh,
245  vtkIntArray* cellMarks, vtkPolyData* output);
246 
247  void SetSelectionScalarsToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
248  vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkPolyData* output);
249 
255  double ClosestPoint[3];
257 
258 private:
259  static void GetPointNeighbors(vtkPolyData* mesh, vtkIdType ptId, vtkIdList* nei);
260 
261  // Helper function to check if the edge between pointId1 and pointId2 is present in the
262  // edgePointIds (as direct neighbors).
263  static bool IsBoundaryEdge(vtkIdType pointId1, vtkIdType pointId2, vtkIdList* edgePointIds);
264 
265 private:
266  vtkSelectPolyData(const vtkSelectPolyData&) = delete;
267  void operator=(const vtkSelectPolyData&) = delete;
268 };
269 
274 {
276  {
277  return "InsideSmallestRegion";
278  }
279  else if (this->SelectionMode == VTK_INSIDE_LARGEST_REGION)
280  {
281  return "InsideLargestRegion";
282  }
283  else
284  {
285  return "InsideClosestPointRegion";
286  }
287 }
288 
293 {
295  {
296  return "GreedyEdgeSearch";
297  }
298  else if (this->EdgeSearchMode == VTK_DIJKSTRA_EDGE_SEARCH)
299  {
300  return "DijkstraEdgeSearch";
301  }
302  else
303  {
304  // This should never occur
305  return "Invalid";
306  }
307 }
308 
309 #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:41
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
represent and manipulate cell attribute data
Definition: vtkCellData.h:41
vtkTypeBool GenerateSelectionScalars
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
#define VTK_DIJKSTRA_EDGE_SEARCH
Proxy object to connect input/output ports.
static vtkPolyDataAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:51
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
void SetEdgeSearchModeToGreedy()
Set the edge search mode.
list of point or cell ids
Definition: vtkIdList.h:33
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:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.