VTK  9.3.20241006
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
19VTK_ABI_NAMESPACE_BEGIN
20
21class VTKFILTERSCELLGRID_EXPORT vtkDGArrayOutputAccessor
22{
23public:
27
29
32 struct Tuple
33 {
34 Tuple() = default;
35 Tuple(double* data, int size)
36 : Data(data)
37 , Size(size)
38 {
39 }
40 Tuple(const Tuple&) = default;
41 Tuple& operator=(const Tuple&) = default;
42
43 double& operator[](int ii)
44 {
45 assert(ii < this->Size);
46 return this->Data[ii];
47 }
48 const double* data() const { return this->Data; }
49 double* data() { return this->Data; }
50 int size() const { return this->Size; }
51
53 operator bool() const { return !!this->Data && this->Size > 0; }
54
55 double* Data{ nullptr };
56 int Size{ 0 };
57 };
58
59 Tuple operator[](vtkTypeUInt64 tupleId);
60 vtkTypeUInt64 GetKey() const { return this->Key; }
62 void Restart();
63 bool IsAtEnd() const;
64
65 std::size_t size() const;
66
67 vtkTypeUInt64 operator++();
68 vtkTypeUInt64 operator++(int);
69
70 vtkDGArrayOutputAccessor& operator+=(vtkTypeUInt64 count);
71
72protected:
73 vtkTypeUInt64 Key{ 0 };
74 vtkDoubleArray* Result{ nullptr };
75};
76
77VTK_ABI_NAMESPACE_END
78
79#endif // vtkDGArrayOutputAccessor_h
Store values interpolated from DG cells into a vtkDoubleArray instance.
vtkTypeUInt64 operator++(int)
std::size_t size() const
vtkDGArrayOutputAccessor & operator+=(vtkTypeUInt64 count)
vtkDGArrayOutputAccessor(vtkDoubleArray *result)
vtkTypeUInt64 operator++()
vtkDGArrayOutputAccessor & operator=(const vtkDGArrayOutputAccessor &other)
Tuple operator[](vtkTypeUInt64 tupleId)
vtkDGArrayOutputAccessor(const vtkDGArrayOutputAccessor &other)
dynamic, self-adjusting array of double
Expose a tuple in a vtkDoubleArray as an object with a size() method to satisfy requirements of the o...
Tuple(const Tuple &)=default
Tuple & operator=(const Tuple &)=default