VTK  9.3.1
vtkTestDataArray.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
20 #ifndef vtkTestDataArray_h
21 #define vtkTestDataArray_h
22 
23 #include "vtkCommonCoreModule.h" // For export macro
24 #include "vtkGenericDataArray.h"
25 #include "vtkObjectFactory.h" // For VTK_STANDARD_NEW_BODY
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 template <class ArrayT>
30  : public vtkGenericDataArray<vtkTestDataArray<ArrayT>, typename ArrayT::ValueType>
31 {
32 public:
33  typedef ArrayT ArrayType;
34  typedef typename ArrayType::ValueType ValueType;
37  friend class vtkGenericDataArray<vtkTestDataArray<ArrayT>, ValueType>;
38 
39  vtkAbstractTemplateTypeMacro(SelfType, GenericDataArrayType);
41 
43 
44  void PrintSelf(ostream& os, vtkIndent indent) override
45  {
47  }
48 
49  ValueType GetValue(vtkIdType valueIdx) const { return this->Array->GetValue(valueIdx); }
50  void SetValue(vtkIdType valueIdx, ValueType value) { this->Array->SetValue(valueIdx, value); }
51 
52  void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
53  {
54  this->Array->SetTypedTuple(tupleIdx, tuple);
55  }
56  void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple)
57  {
58  this->Array->SetTypedTuple(tupleIdx, tuple);
59  }
60 
61  ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
62  {
63  return this->Array->GetTypedComponent(tupleIdx, compIdx);
64  }
65  void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
66  {
67  this->Array->SetTypedComponent(tupleIdx, compIdx, value);
68  }
69 
70  void* GetVoidPointer(vtkIdType valueIdx) override
71  {
72  return this->Array->GetVoidPointer(valueIdx);
73  }
74 
75 protected:
76  vtkTestDataArray() { this->Array = ArrayType::New(); }
77  ~vtkTestDataArray() override { this->Array->Delete(); }
78 
79  bool AllocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
80  bool ReallocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
81 
82 private:
83  ArrayType* Array;
84 
85  vtkTestDataArray(const vtkTestDataArray&) = delete;
86  void operator=(const vtkTestDataArray&) = delete;
87 };
88 
89 VTK_ABI_NAMESPACE_END
90 #endif
91 // VTK-HeaderTest-Exclude: vtkTestDataArray.h
void * GetVoidPointer(vtkIdType valueIdx) override
Return a void pointer.
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
static vtkTestDataArray< ArrayType > * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
int vtkIdType
Definition: vtkType.h:315
Base interface for all typed vtkDataArray subclasses.
void SetValue(vtkIdType valueIdx, ValueType value)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTestDataArray< ArrayT > SelfType
ArrayType::ValueType ValueType
ValueType GetValue(vtkIdType valueIdx) const
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_STANDARD_NEW_BODY(thisClass)
void GetTypedTuple(vtkIdType tupleIdx, ValueType *tuple) const
vtkAbstractTemplateTypeMacro(SelfType, GenericDataArrayType)
bool ReallocateTuples(vtkIdType numTuples)
void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
An implementation of vtkGenericDataArray for testing fallback algorithms.
vtkGenericDataArray< vtkTestDataArray< ArrayT >, ValueType > GenericDataArrayType
vtkAOSArrayNewInstanceMacro(SelfType)
~vtkTestDataArray() override
bool AllocateTuples(vtkIdType numTuples)