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