VTK  9.3.20240423
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
99#ifndef vtkSelectPolyData_h
100#define vtkSelectPolyData_h
101
102#include "vtkFiltersModelingModule.h" // For export macro
103#include "vtkPolyDataAlgorithm.h"
104
105#define VTK_INSIDE_SMALLEST_REGION 0
106#define VTK_INSIDE_LARGEST_REGION 1
107#define VTK_INSIDE_CLOSEST_POINT_REGION 2
108
109#define VTK_GREEDY_EDGE_SEARCH 0
110#define VTK_DIJKSTRA_EDGE_SEARCH 1
111
112VTK_ABI_NAMESPACE_BEGIN
113class vtkCharArray;
114class vtkPoints;
115class vtkIdList;
116
117class VTKFILTERSMODELING_EXPORT vtkSelectPolyData : public vtkPolyDataAlgorithm
118{
119public:
126
128 void PrintSelf(ostream& os, vtkIndent indent) override;
129
131
138 vtkSetMacro(GenerateSelectionScalars, vtkTypeBool);
139 vtkGetMacro(GenerateSelectionScalars, vtkTypeBool);
140 vtkBooleanMacro(GenerateSelectionScalars, vtkTypeBool);
142
144
147 vtkSetStringMacro(SelectionScalarsArrayName);
148 vtkGetStringMacro(SelectionScalarsArrayName);
150
152
156 vtkSetMacro(InsideOut, vtkTypeBool);
157 vtkGetMacro(InsideOut, vtkTypeBool);
158 vtkBooleanMacro(InsideOut, vtkTypeBool);
160
162
170 vtkSetClampMacro(EdgeSearchMode, int, VTK_GREEDY_EDGE_SEARCH, VTK_DIJKSTRA_EDGE_SEARCH);
171 vtkGetMacro(EdgeSearchMode, int);
172 void SetEdgeSearchModeToGreedy() { this->SetEdgeSearchMode(VTK_GREEDY_EDGE_SEARCH); }
173 void SetEdgeSearchModeToDijkstra() { this->SetEdgeSearchMode(VTK_DIJKSTRA_EDGE_SEARCH); }
174 const char* GetEdgeSearchModeAsString();
176
178
182 virtual void SetLoop(vtkPoints*);
183 vtkGetObjectMacro(Loop, vtkPoints);
185
187
190 vtkSetVector3Macro(ClosestPoint, double);
191 vtkGetVector3Macro(ClosestPoint, double);
193
195
198 vtkSetClampMacro(SelectionMode, int, VTK_INSIDE_SMALLEST_REGION, VTK_INSIDE_CLOSEST_POINT_REGION);
199 vtkGetMacro(SelectionMode, int);
203 {
204 this->SetSelectionMode(VTK_INSIDE_CLOSEST_POINT_REGION);
205 }
206 const char* GetSelectionModeAsString();
208
210
214 vtkSetMacro(GenerateUnselectedOutput, vtkTypeBool);
215 vtkGetMacro(GenerateUnselectedOutput, vtkTypeBool);
216 vtkBooleanMacro(GenerateUnselectedOutput, vtkTypeBool);
218
224
230
235
236 // Overload GetMTime() because we depend on Loop
238
239protected:
242
244
245 // Compute point list that forms a continuous loop overy the mesh,
248
249 // Returns maximum front cell ID
251 vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkIntArray* cellMarks);
252
253 // Get closest cell to a position that is not at the boundary
255
256 // Starting from maxFrontCell, without crossing the boundary, set all cell and point marks to -1.
257 void FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds, vtkIntArray* pointMarks,
258 vtkIntArray* cellMarks, vtkIdType cellIdInSelectedRegion);
259
260 void SetClippedResultToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
261 vtkPolyData* mesh, vtkIntArray* cellMarks, vtkPolyData* output);
262
263 void SetSelectionScalarsToOutput(vtkPointData* originalPointData, vtkCellData* originalCellData,
264 vtkPolyData* mesh, vtkIdList* edgeIds, vtkIntArray* pointMarks, vtkPolyData* output);
265
272 double ClosestPoint[3];
274
275private:
276 static void GetPointNeighbors(vtkPolyData* mesh, vtkIdType ptId, vtkIdList* nei);
277
278 // Helper function to check if the edge between pointId1 and pointId2 is present in the
279 // edgePointIds (as direct neighbors).
280 static bool IsBoundaryEdge(vtkIdType pointId1, vtkIdType pointId2, vtkIdList* edgePointIds);
281
282 vtkSelectPolyData(const vtkSelectPolyData&) = delete;
283 void operator=(const vtkSelectPolyData&) = delete;
284};
285
290{
292 {
293 return "InsideSmallestRegion";
294 }
296 {
297 return "InsideLargestRegion";
298 }
299 else
300 {
301 return "InsideClosestPointRegion";
302 }
303}
304
309{
311 {
312 return "GreedyEdgeSearch";
313 }
315 {
316 return "DijkstraEdgeSearch";
317 }
318 else
319 {
320 // This should never occur
321 return "Invalid";
322 }
323}
324
325VTK_ABI_NAMESPACE_END
326#endif
Proxy object to connect input/output ports.
represent and manipulate cell attribute data
dynamic, self-adjusting array of char
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
represent and manipulate point attribute data
represent and manipulate 3D points
Definition vtkPoints.h:139
Superclass for algorithms that produce only polydata as output.
concrete dataset represents vertices, lines, polygons, and triangle strips
select portion of polygonal mesh; generate selection scalars
virtual void SetLoop(vtkPoints *)
Set/Get the array of point coordinates defining the loop.
vtkPolyData * GetSelectionEdges()
Return the (mesh) edges of the selection region.
vtkIdType ComputeTopologicalDistance(vtkPolyData *mesh, vtkIdList *edgeIds, vtkIntArray *pointMarks, vtkIntArray *cellMarks)
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.
static vtkSelectPolyData * New()
Instantiate object with InsideOut turned off, and GenerateSelectionScalars turned off.
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.
vtkAlgorithmOutput * GetUnselectedOutputPort()
Return output port that hasn't been selected (if GenreateUnselectedOutput is enabled).
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)
~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