vtkCTHDataArray.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkCTHDataArray_h
5 #define vtkCTHDataArray_h
6 
7 #include "vtkDataArray.h"
8 #include "vtkDoubleArray.h" // For multiple usage in implemented methods
9 #include "vtkPVAdaptorsCTHModule.h" //For export macro
10 
12 {
13 public:
14  static vtkCTHDataArray* New();
15  vtkTypeMacro(vtkCTHDataArray, vtkDataArray);
16  void PrintSelf(ostream& os, vtkIndent indent) override;
17 
18  // Description:
19  // Prepares for new data
20  void Initialize() override;
21 
22  // Description:
23  // Get the data type
24  int GetDataType() const override { return VTK_DOUBLE; }
25 
26  int GetDataTypeSize() const override { return static_cast<int>(sizeof(double)); }
27 
28  // Description:
29  // Return the size, in bytes, of the lowest-level element of an
30  // array. For vtkDataArray and subclasses this is the size of the
31  // data type.
32  int GetElementComponentSize() const override { return this->GetDataTypeSize(); }
33 
34  // Description:
35  // Set the dimensions the data will be contained within
36  void SetDimensions(int x, int y, int z);
37  void SetDimensions(int* x) { this->SetDimensions(x[0], x[1], x[2]); }
38  const int* GetDimensions() { return this->Dimensions; }
39 
40  // Description:
41  // Sets the extent over which the data is valid.
42  // This is because with CTH cells can extend one past the boundary,
43  // so we must skip over the data associated with those and consequently
44  // act externally (as a vtkDataArray) as though our dimensions are one less.
45  void SetExtents(int x0, int x1, int y0, int y1, int z0, int z1);
46  void SetExtents(int* lo, int* hi) { this->SetExtents(lo[0], hi[0], lo[1], hi[1], lo[2], hi[2]); }
47  void SetExtent(int* x) { this->SetExtents(x[0], x[1], x[2], x[3], x[4], x[5]); }
48  int* GetExtents() { return this->Extents; }
49  void UnsetExtents();
50 
51  // Description:
52  // Set the data pointers from the CTH code
53  void SetDataPointer(int comp, int k, int j, double* istrip);
54 
55  // Description:
56  // Copy the tuple value into a user-provided array.
57  void GetTuple(vtkIdType i, double* tuple) override;
58  double* GetTuple(vtkIdType i) override;
59 
60  // Description:
61  // Returns an ArrayIterator over doubles, this will end up with a deep copy
62  vtkArrayIterator* NewIterator() override;
63 
65  void LookupValue(vtkVariant value, vtkIdList* ids) override;
66  void SetVariantValue(vtkIdType vtkNotUsed(index), vtkVariant vtkNotUsed(value)) override
67  { /* TODO */
68  }
69 
70  // Description:
71  // Get the address of a particular data index. Performs no checks
72  // to verify that the memory has been allocated etc.
73  double* GetPointer(vtkIdType id);
74  void* GetVoidPointer(vtkIdType id) override { return this->GetPointer(id); }
75  void ExportToVoidPointer(void* out_ptr) override;
76 
77  int Allocate(vtkIdType sz, vtkIdType ext = 1000) override
78  {
79  BuildFallback();
80  return Fallback->Allocate(sz, ext);
81  }
82 
83  void SetNumberOfComponents(int number) override
84  {
86  if (this->Fallback)
87  {
88  this->Fallback->SetNumberOfComponents(this->GetNumberOfComponents());
89  }
90  }
91 
92  void SetNumberOfTuples(vtkIdType number) override
93  {
94  this->BuildFallback();
95  this->Fallback->SetNumberOfTuples(number);
96  this->Size = this->Fallback->GetSize();
97  this->MaxId = this->Fallback->GetMaxId();
98  }
99 
100  // Description:
101  // A number of abstract functions from the super class that must not be called
102  void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* aa) override
103  {
104  this->BuildFallback();
105  this->Fallback->SetTuple(i, j, aa);
106  }
107  void SetTuple(vtkIdType i, const float* f) override
108  {
109  this->BuildFallback();
110  this->Fallback->SetTuple(i, f);
111  }
112  void SetTuple(vtkIdType i, const double* d) override
113  {
114  this->BuildFallback();
115  this->Fallback->SetTuple(i, d);
116  }
117 
119  {
120  this->BuildFallback();
121  this->Fallback->InsertTuple(i, j, aa);
122  }
123  void InsertTuple(vtkIdType i, const float* f) override
124  {
125  this->BuildFallback();
126  this->Fallback->InsertTuple(i, f);
127  }
128  void InsertTuple(vtkIdType i, const double* d) override
129  {
130  this->BuildFallback();
131  this->Fallback->InsertTuple(i, d);
132  }
133  void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override
134  {
135  this->BuildFallback();
136  this->Fallback->InsertTuples(dstIds, srcIds, source);
137  }
139  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source) override
140  {
141  this->BuildFallback();
142  this->Fallback->InsertTuples(dstStart, n, srcStart, source);
143  }
144 
146  {
147  this->BuildFallback();
148  vtkIdType ret = this->Fallback->InsertNextTuple(i, aa);
149  this->Size = this->Fallback->GetSize();
150  this->MaxId = this->Fallback->GetMaxId();
151  return ret;
152  }
153  vtkIdType InsertNextTuple(const float* f) override
154  {
155  this->BuildFallback();
156  vtkIdType ret = this->Fallback->InsertNextTuple(f);
157  this->Size = this->Fallback->GetSize();
158  this->MaxId = this->Fallback->GetMaxId();
159  return ret;
160  }
161  vtkIdType InsertNextTuple(const double* d) override
162  {
163  this->BuildFallback();
164  vtkIdType ret = this->Fallback->InsertNextTuple(d);
165  this->Size = this->Fallback->GetSize();
166  this->MaxId = this->Fallback->GetMaxId();
167  return ret;
168  }
169 
170  void InsertVariantValue(vtkIdType idx, vtkVariant value) override
171  {
172  this->BuildFallback();
173  return this->Fallback->InsertVariantValue(idx, value);
174  }
175 
176  void RemoveTuple(vtkIdType id) override
177  {
178  this->BuildFallback();
179  this->Fallback->RemoveTuple(id);
180  }
181  void RemoveFirstTuple() override
182  {
183  this->BuildFallback();
184  this->Fallback->RemoveFirstTuple();
185  }
186  void RemoveLastTuple() override
187  {
188  this->BuildFallback();
189  this->Fallback->RemoveLastTuple();
190  }
191 
192  void* WriteVoidPointer(vtkIdType i, vtkIdType j) override
193  {
194  this->BuildFallback();
195  return this->Fallback->WriteVoidPointer(i, j);
196  }
197 
198  void DeepCopy(vtkAbstractArray* aa) override
199  {
200  this->BuildFallback();
201  return this->Fallback->DeepCopy(aa);
202  }
203 
204  void DeepCopy(vtkDataArray* da) override { return this->DeepCopy((vtkAbstractArray*)da); }
205 
206  void SetVoidArray(void* p, vtkIdType id, int i, int j) override
207  {
208  this->BuildFallback();
209  return this->Fallback->SetVoidArray(p, id, i, j);
210  }
211  void SetVoidArray(void* p, vtkIdType id, int i) override
212  {
213  this->BuildFallback();
214  return this->Fallback->SetVoidArray(p, id, i);
215  }
216  void SetArrayFreeFunction(void (*)(void*)) override {}
217 
218  // Description:
219  // Since we don't allocate, this does nothing
220  // unless we're already falling back
221  void Squeeze() override
222  {
223  if (this->Fallback)
224  {
225  this->Size = this->Fallback->GetSize();
226  this->MaxId = this->Fallback->GetMaxId();
227  this->Fallback->Squeeze();
228  }
229  }
230 
231  // Description:
232  int Resize(vtkIdType numTuples) override
233  {
234  this->BuildFallback();
235  return this->Fallback->Resize(numTuples);
236  }
237 
238  void DataChanged() override
239  {
240  this->BuildFallback();
241  return this->Fallback->DataChanged();
242  }
243 
244  void ClearLookup() override
245  {
246  this->BuildFallback();
247  return this->Fallback->ClearLookup();
248  }
249 
250 protected:
251  vtkCTHDataArray();
252  ~vtkCTHDataArray() override;
253 
254  int Dimensions[3];
255 
257  int Extents[6];
258  int Dx;
259  int Dy;
260  int Dz;
261 
263 
264  double*** Data;
265  double* CopiedData;
267  double* Tuple;
269 
270  void BuildFallback();
271  // A writable version of this array, delegated.
273 
274 private:
275  vtkCTHDataArray(const vtkCTHDataArray&) = delete;
276  void operator=(const vtkCTHDataArray&) = delete;
277 };
278 
279 #endif /* vtkCTHDataArray_h */
#define VTKPVADAPTORSCTH_EXPORT
void DeepCopy(vtkAbstractArray *aa) override
void ClearLookup() override
void SetVoidArray(void *p, vtkIdType id, int i, int j) override
void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray *source) override
void * GetVoidPointer(vtkIdType id) override
vtkDoubleArray * Fallback
void DataChanged() override
virtual vtkIdType LookupValue(vtkVariant value)=0
virtual double * GetTuple(vtkIdType tupleIdx)=0
virtual int GetDataTypeSize()=0
void * WriteVoidPointer(vtkIdType i, vtkIdType j) override
void SetNumberOfTuples(vtkIdType number) override
void RemoveLastTuple() override
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
int vtkIdType
void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *aa) override
int GetNumberOfComponents()
int Allocate(vtkIdType sz, vtkIdType ext=1000) override
void SetDimensions(int *x)
vtkTypeUInt64 vtkMTimeType
virtual void Initialize()=0
vtkMTimeType PointerTime
void Squeeze() override
void InsertVariantValue(vtkIdType idx, vtkVariant value) override
void RemoveTuple(vtkIdType id) override
void SetVoidArray(void *p, vtkIdType id, int i) override
#define VTK_DOUBLE
double
void InsertTuple(vtkIdType i, const double *d) override
void SetNumberOfComponents(int number) override
void SetExtent(int *x)
void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source) override
void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *aa) override
vtkIdType InsertNextTuple(const double *d) override
void InsertTuple(vtkIdType i, const float *f) override
int GetElementComponentSize() const override
void SetArrayFreeFunction(void(*)(void *)) override
virtual VTK_NEWINSTANCE vtkArrayIterator * NewIterator()=0
void SetExtents(int *lo, int *hi)
int Resize(vtkIdType numTuples) override
int GetDataTypeSize() const override
virtual void SetNumberOfComponents(int)
value
void SetTuple(vtkIdType i, const float *f) override
void RemoveFirstTuple() override
void DeepCopy(vtkDataArray *da) override
const int * GetDimensions()
static vtkObject * New()
void SetVariantValue(vtkIdType vtkNotUsed(index), vtkVariant vtkNotUsed(value)) override
void operator=(const vtkObjectBase &)
int GetDataType() const override
vtkIdType InsertNextTuple(const float *f) override
vtkIdType InsertNextTuple(vtkIdType i, vtkAbstractArray *aa) override
void SetTuple(vtkIdType i, const double *d) override
virtual void ExportToVoidPointer(void *out_ptr)