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