VTK  9.7.1
vtkDGArrayOutputAccessor.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
10 #ifndef vtkDGArrayOutputAccessor_h
11 #define vtkDGArrayOutputAccessor_h
12 
13 #include "vtkDoubleArray.h" // For API.
14 #include "vtkFiltersCellGridModule.h" // For export macro.
15 #include "vtkVector.h" // For API.
16 
17 #include <cassert>
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 
21 class VTKFILTERSCELLGRID_EXPORT vtkDGArrayOutputAccessor
22 {
23 public:
24  vtkDGArrayOutputAccessor() = default;
28 
29  vtkDGArrayOutputAccessor& operator=(const vtkDGArrayOutputAccessor& other);
30 
31  void SetResult(vtkDoubleArray* result);
32 
35  struct Tuple
36  {
37  Tuple() = default;
38  Tuple(double* data, int size)
39  : Data(data)
40  , Size(size)
41  {
42  }
43  Tuple(const Tuple&) = default;
44  Tuple& operator=(const Tuple&) = default;
45 
46  double& operator[](int ii)
47  {
48  assert(ii < this->Size);
49  return this->Data[ii];
50  }
51  const double* data() const { return this->Data; }
52  double* data() { return this->Data; }
53  int size() const { return this->Size; }
54 
56  operator bool() const { return !!this->Data && this->Size > 0; }
57 
58  double* Data{ nullptr };
59  int Size{ 0 };
60  };
61 
62  Tuple operator[](vtkTypeUInt64 tupleId);
63  vtkTypeUInt64 GetKey() const { return this->Key; }
64  Tuple GetTuple();
65  void Restart();
66  bool IsAtEnd() const;
67 
68  std::size_t size() const;
69 
70  vtkTypeUInt64 operator++();
71  vtkTypeUInt64 operator++(int);
72 
73  vtkDGArrayOutputAccessor& operator+=(vtkTypeUInt64 count);
74 
75 protected:
76  vtkTypeUInt64 Key{ 0 };
77  vtkDoubleArray* Result{ nullptr };
78 };
79 
80 VTK_ABI_NAMESPACE_END
81 
82 #endif // vtkDGArrayOutputAccessor_h
Expose a tuple in a vtkDoubleArray as an object with a size() method to satisfy requirements of the o...
Store values interpolated from DG cells into a vtkDoubleArray instance.
vtkVector< T, Size > & operator+=(vtkVector< T, Size > &a, const vtkVector< T, Size > &b)
Add the vector b to the vector a of the same basic type.
Definition: vtkVector.h:553
dynamic, self-adjusting array of double
vtkTypeUInt64 GetKey() const