VTK  9.7.1
vtkCellGridCellCenters.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
19 #ifndef vtkCellGridCellCenters_h
20 #define vtkCellGridCellCenters_h
21 
22 #include "vtkCellGridAlgorithm.h"
23 #include "vtkFiltersCellGridModule.h" // For export macro
24 #include "vtkNew.h" // for ivar
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 
28 class VTKFILTERSCELLGRID_EXPORT vtkCellGridCellCenters : public vtkCellGridAlgorithm
29 {
30 public:
34  class Query : public vtkCellGridQuery
35  {
36  public:
37  static Query* New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
42  using OutputAllocations =
43  std::unordered_map<vtkStringToken, std::unordered_map<vtkStringToken, vtkIdType>>;
44 
45  enum PassType : int
46  {
47  CountOutputs = 0,
48  AllocateOutputs = 1,
49  GenerateOutputs = 2
50  };
51 
52  bool Initialize() override;
53 
55  bool IsAnotherPassRequired() override { return this->Pass < PassType::GenerateOutputs; }
56 
58  vtkCellGrid* GetOutput() const { return this->Output; }
60  vtkCellGrid* GetInput() const { return this->Input; }
61 
64  void AddOutputCenters(
65  vtkStringToken inputCellType, vtkStringToken outputCellType, vtkIdType numberOfOutputs);
66 
69  OutputAllocations& GetOutputAllocations() { return this->OutputOffsets; }
70  const OutputAllocations& GetOutputAllocations() const { return this->OutputOffsets; }
71 
73  vtkCellAttribute* GetOutputAttribute(vtkCellAttribute* inputAttribute);
74 
75  protected:
76  friend class vtkCellGridCellCenters;
77  Query() = default;
78  ~Query() override = default;
79 
80  vtkCellGrid* Input{ nullptr };
81  vtkCellGrid* Output{ nullptr };
82 
86  // Map input to output attributes:
87  std::unordered_map<vtkCellAttribute*, vtkCellAttribute*> AttributeMap;
88 
89  private:
90  Query(const Query&) = delete;
91  void operator=(const Query&) = delete;
92  };
93 
94  static vtkCellGridCellCenters* New();
96  void PrintSelf(ostream& os, vtkIndent indent) override;
97 
98 protected:
100  ~vtkCellGridCellCenters() override = default;
101 
102  int RequestData(
103  vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* ouInfo) override;
104 
106 
107 private:
109  void operator=(const vtkCellGridCellCenters&) = delete;
110 };
111 
112 VTK_ABI_NAMESPACE_END
113 #endif // vtkCellGridCellCenters_h
Perform an operation on cells in a vtkCellMetadata instance.
Output a vertex cell at the center of each input cell.
vtkCellGrid * GetInput() const
Get the request's input cell-grid.
Store vtkAlgorithm input/output information.
static vtkCellGridAlgorithm * New()
~vtkCellGridCellCenters() override=default
const OutputAllocations & GetOutputAllocations() const
OutputAllocations OutputOffsets
Map output cell-typename to input cell-typename to count (offset after the AllocateOutputs pass has r...
int vtkIdType
Definition: vtkType.h:363
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
OutputAllocations & GetOutputAllocations()
Return the data structure that AddOutputCenters() modifies in the PassType::CountOutputs pass...
Visualization data composed of cells of arbitrary type.
Definition: vtkCellGrid.h:48
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:28
A function defined over the physical domain of a vtkCellGrid.
std::unordered_map< vtkStringToken, std::unordered_map< vtkStringToken, vtkIdType >> OutputAllocations
A map used to allocate output vertex cells for various input cell types.
vtkCellGrid * GetOutput() const
Get the request's output cell-grid.
Represent a string by its integer hash.
A query corresponding to this algorithm.
Allocate and hold a VTK object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
std::unordered_map< vtkCellAttribute *, vtkCellAttribute * > AttributeMap
Store zero or more vtkInformation instances.
bool IsAnotherPassRequired() override
Force three passes through this query.