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 
81  "Use ReserveValues/Tuples() to allocate or Initialize() to deallocate.")
82  int Allocate(vtkIdType sz, vtkIdType ext = 1000) override;
83 
84  void SetNumberOfComponents(int number) override
85  {
87  if (this->Fallback)
88  {
89  this->Fallback->SetNumberOfComponents(this->GetNumberOfComponents());
90  }
91  }
92 
93  void SetNumberOfTuples(vtkIdType number) override
94  {
95  this->BuildFallback();
96  this->Fallback->SetNumberOfTuples(number);
97  this->Capacity = this->Fallback->GetCapacity();
98  this->MaxId = this->Fallback->GetMaxId();
99  }
100 
101  // Description:
102  // A number of abstract functions from the super class that must not be called
103  void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* aa) override
104  {
105  this->BuildFallback();
106  this->Fallback->SetTuple(i, j, aa);
107  }
108  void SetTuple(vtkIdType i, const float* f) override
109  {
110  this->BuildFallback();
111  this->Fallback->SetTuple(i, f);
112  }
113  void SetTuple(vtkIdType i, const double* d) override
114  {
115  this->BuildFallback();
116  this->Fallback->SetTuple(i, d);
117  }
118 
120  {
121  this->BuildFallback();
122  this->Fallback->InsertTuple(i, j, aa);
123  }
124  void InsertTuple(vtkIdType i, const float* f) override
125  {
126  this->BuildFallback();
127  this->Fallback->InsertTuple(i, f);
128  }
129  void InsertTuple(vtkIdType i, const double* d) override
130  {
131  this->BuildFallback();
132  this->Fallback->InsertTuple(i, d);
133  }
134  void InsertTuples(vtkIdList* dstIds, vtkIdList* srcIds, vtkAbstractArray* source) override
135  {
136  this->BuildFallback();
137  this->Fallback->InsertTuples(dstIds, srcIds, source);
138  }
140  vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source) override
141  {
142  this->BuildFallback();
143  this->Fallback->InsertTuples(dstStart, n, srcStart, source);
144  }
145 
147  {
148  this->BuildFallback();
149  vtkIdType ret = this->Fallback->InsertNextTuple(i, aa);
150  this->Capacity = this->Fallback->GetCapacity();
151  this->MaxId = this->Fallback->GetMaxId();
152  return ret;
153  }
154  vtkIdType InsertNextTuple(const float* f) override
155  {
156  this->BuildFallback();
157  vtkIdType ret = this->Fallback->InsertNextTuple(f);
158  this->Capacity = this->Fallback->GetCapacity();
159  this->MaxId = this->Fallback->GetMaxId();
160  return ret;
161  }
162  vtkIdType InsertNextTuple(const double* d) override
163  {
164  this->BuildFallback();
165  vtkIdType ret = this->Fallback->InsertNextTuple(d);
166  this->Capacity = this->Fallback->GetCapacity();
167  this->MaxId = this->Fallback->GetMaxId();
168  return ret;
169  }
170 
171  void InsertVariantValue(vtkIdType idx, vtkVariant value) override
172  {
173  this->BuildFallback();
174  this->Fallback->InsertVariantValue(idx, value);
175  }
176 
177  void RemoveTuple(vtkIdType id) override
178  {
179  this->BuildFallback();
180  this->Fallback->RemoveTuple(id);
181  }
182  void RemoveFirstTuple() override
183  {
184  this->BuildFallback();
185  this->Fallback->RemoveFirstTuple();
186  }
187  void RemoveLastTuple() override
188  {
189  this->BuildFallback();
190  this->Fallback->RemoveLastTuple();
191  }
192 
193  PARAVIEW_DEPRECATED_IN_6_2_0("Use vtkAOSDataArrayTemplate::WritePointer(valueIdx, numValues) or "
194  "vtkAbstractArray::SetNumberOf[Values/Tuples]() instead")
195  void* WriteVoidPointer(vtkIdType i, vtkIdType j) override
196  {
197  this->BuildFallback();
198  return this->Fallback->WritePointer(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->Capacity = this->Fallback->GetCapacity();
229  this->MaxId = this->Fallback->GetMaxId();
230  this->Fallback->Squeeze();
231  }
232  }
233 
234  // Description:
235  PARAVIEW_DEPRECATED_IN_6_2_0("Use ReserveTuples, Squeeze or Initialize")
236  int Resize(vtkIdType numTuples) override;
237 
238  vtkTypeBool ReserveTuples(vtkIdType numTuples) override
239  {
240  this->BuildFallback();
241  return this->Fallback->ReserveTuples(numTuples);
242  }
243 
244  void DataChanged() override
245  {
246  this->BuildFallback();
247  this->Fallback->DataChanged();
248  }
249 
250  void ClearLookup() override
251  {
252  this->BuildFallback();
253  this->Fallback->ClearLookup();
254  }
255 
256 protected:
257  vtkCTHDataArray();
258  ~vtkCTHDataArray() override;
259 
260  int Dimensions[3];
261 
263  int Extents[6];
264  int Dx;
265  int Dy;
266  int Dz;
267 
269 
270  double*** Data;
271  double* CopiedData;
273  double* Tuple;
275 
276  void BuildFallback();
277  // A writable version of this array, delegated.
279 
280 private:
281  vtkCTHDataArray(const vtkCTHDataArray&) = delete;
282  void operator=(const vtkCTHDataArray&) = delete;
283 };
284 
285 #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
vtkTypeBool ReserveTuples(vtkIdType numTuples) override
void DataChanged() override
virtual vtkIdType LookupValue(vtkVariant value)=0
virtual double * GetTuple(vtkIdType tupleIdx)=0
virtual int GetDataTypeSize()=0
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()
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
int vtkTypeBool
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 int Resize(vtkIdType numTuples)=0
virtual VTK_NEWINSTANCE vtkArrayIterator * NewIterator()=0
void SetExtents(int *lo, int *hi)
virtual int Allocate(vtkIdType numValues, vtkIdType ext=1000)=0
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)