VTK  9.7.1
vtkCellGridSidesQuery.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
3 #ifndef vtkCellGridSidesQuery_h
4 #define vtkCellGridSidesQuery_h
5 
6 #include "vtkCellGridQuery.h"
7 
8 #include "vtkStringToken.h" // For API.
9 
10 #include <functional>
11 #include <map>
12 #include <set>
13 #include <unordered_map>
14 #include <vector>
15 
16 VTK_ABI_NAMESPACE_BEGIN
17 
19 class vtkIdTypeArray;
20 
37 class VTKCOMMONDATAMODEL_EXPORT vtkCellGridSidesQuery : public vtkCellGridQuery
38 {
39 public:
40  static vtkCellGridSidesQuery* New();
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
45  enum SideFlags : int
46  {
47  // Individual bits
48  VerticesOfEdges = 0x01,
49  VerticesOfSurfaces = 0x02,
50  EdgesOfSurfaces = 0x04,
51  VerticesOfVolumes = 0x08,
52  EdgesOfVolumes = 0x10,
53  SurfacesOfVolumes = 0x20,
54 
55  // Useful (but not exhaustive) combinations
56  SurfacesOfInputs = 0x20,
57  EdgesOfInputs = 0x14,
58  VerticesOfInputs = 0x0b,
59  AllSides = 0x3f,
60  NextLowestDimension = 0x25
61  };
62 
64  enum PassWork : int
65  {
68  HashSides = 0,
72  Summarize = 1,
75  GenerateSideSets = 2
76  };
77 
81  {
94  Boundary
95  };
96 
99  {
101  Output
102  };
103 
106  {
113  };
114 
122  vtkSetMacro(PreserveRenderableInputs, vtkTypeBool);
123  vtkGetMacro(PreserveRenderableInputs, vtkTypeBool);
124  vtkBooleanMacro(PreserveRenderableInputs, vtkTypeBool);
125 
136  vtkSetMacro(OmitSidesForRenderableInputs, vtkTypeBool);
137  vtkGetMacro(OmitSidesForRenderableInputs, vtkTypeBool);
138  vtkBooleanMacro(OmitSidesForRenderableInputs, vtkTypeBool);
139 
146  vtkSetMacro(OutputDimensionControl, int);
147  vtkGetMacro(OutputDimensionControl, int);
148  vtkBooleanMacro(OutputDimensionControl, int);
149 
154  vtkSetEnumMacro(Strategy, SummaryStrategy);
155  vtkGetEnumMacro(Strategy, SummaryStrategy);
156  void SetStrategyToWinding() { this->SetStrategy(SummaryStrategy::Winding); }
157  void SetStrategyToAnyOccurrence() { this->SetStrategy(SummaryStrategy::AnyOccurrence); }
158  void SetStrategyToBoundary() { this->SetStrategy(SummaryStrategy::Boundary); }
160  virtual void SetStrategy(int strategy)
161  {
162  this->SetStrategy(static_cast<SummaryStrategy>(strategy));
163  }
164 
175  vtkSetEnumMacro(SelectionType, SelectionMode);
176  vtkGetEnumMacro(SelectionType, SelectionMode);
178  virtual void SetSelectionType(int selnType)
179  {
180  this->SetSelectionType(static_cast<SelectionMode>(selnType));
181  }
182 
183  bool Initialize() override;
184  void StartPass() override;
185  bool IsAnotherPassRequired() override;
186  bool Finalize() override;
187 
188  std::unordered_map<vtkStringToken,
189  std::unordered_map<vtkStringToken, std::unordered_map<vtkIdType, std::set<int>>>>&
191  {
192  return this->Sides;
193  }
194 
196  std::vector<SideSetArray> GetSideSetArrays(vtkStringToken cellType);
197 
199  static vtkStringToken SelectionModeToLabel(SelectionMode mode);
200  static SelectionMode SelectionModeFromLabel(vtkStringToken token);
201 
203  static vtkStringToken SummaryStrategyToLabel(SummaryStrategy strategy);
204  static SummaryStrategy SummaryStrategyFromLabel(vtkStringToken token);
205 
215  vtkGetObjectMacro(SideCache, vtkCellGridSidesCache);
216  virtual void SetSideCache(vtkCellGridSidesCache* cache);
217 
218 protected:
219  vtkCellGridSidesQuery() = default;
220  ~vtkCellGridSidesQuery() override;
221 
222  vtkTypeBool PreserveRenderableInputs{ false };
223  vtkTypeBool OmitSidesForRenderableInputs{ false };
224  int OutputDimensionControl{ SideFlags::SurfacesOfInputs };
225  SelectionMode SelectionType{ SelectionMode::Input };
226  SummaryStrategy Strategy{ SummaryStrategy::Boundary };
227  vtkCellGridSidesCache* SideCache{ nullptr };
228  bool TemporarySideCache{ false };
229  std::unordered_map<vtkStringToken,
230  std::unordered_map<vtkStringToken, std::unordered_map<vtkIdType, std::set<int>>>>
232 
233 private:
235  void operator=(const vtkCellGridSidesQuery&) = delete;
236 };
237 
238 VTK_ABI_NAMESPACE_END
239 #endif // vtkCellGridSidesQuery_h
A cell-grid query for enumerating sides of cells.
std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkIdType, std::set< int > > > > & GetSides()
Perform an operation on cells in a vtkCellMetadata instance.
PassWork
An enum specifying the work responders should perform for each pass.
vtkSmartPointer< vtkIdTypeArray > Sides
An array of tuples of (cell-id, side-id) specifying sides.
Input shapes should be selected when output sides are picked.
A structure created by the GetSideSetArrays() method for responders to use.
dynamic, self-adjusting array of vtkIdType
vtkStringToken CellType
The type of parent cell which created the sides.
int vtkTypeBool
Definition: vtkABI.h:64
virtual bool Finalize()
Override this if your query-result state requires finalization.
If a hash entry entry exists, a single side should be included in the output.
a simple class to control print indentation
Definition: vtkIndent.h:28
std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, std::unordered_map< vtkIdType, std::set< int > > > > Sides
A side specified by a cell ID and an integer index into sides.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Represent a string by its integer hash.
vtkStringToken SideShape
The shape of all the sides in the Sides array.
SideFlags
An enum specifying which side(s) each responder should generate.
The number of hash entries for a given side should be used to decide whether to include a hash's side...
SelectionMode
Indicate how output should be generated or marked so selection works as expected. ...
SummaryStrategy
An enum specifying the strategy by which input hashes are summarized into output Sides entries...
virtual void SetStrategy(int strategy)
This method exists for ParaView to set the strategy.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual bool IsAnotherPassRequired()
Override this if your query allows responders to execute in multiple phases.
Hold a map from hash-ids (representing sides of cells of multiple types) to details on the cells that...
virtual void SetSelectionType(int selnType)
This method exists for ParaView to set the selection mode.
virtual bool Initialize()
Override this if your query-result state requires initialization.
virtual void StartPass()
Mark the start of a pass through each cell type.