VTK  9.3.20240418
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 
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 PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Base interface for all typed vtkDataArray subclasses.
a simple class to control print indentation
Definition: vtkIndent.h:108
An implementation of vtkGenericDataArray for testing fallback algorithms.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void GetTypedTuple(vtkIdType tupleIdx, ValueType *tuple) const
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
~vtkTestDataArray() override
vtkGenericDataArray< vtkTestDataArray< ArrayT >, ValueType > GenericDataArrayType
bool ReallocateTuples(vtkIdType numTuples)
vtkAbstractTemplateTypeMacro(SelfType, GenericDataArrayType)
void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
vtkTestDataArray< ArrayT > SelfType
static vtkTestDataArray< ArrayType > * New()
void * GetVoidPointer(vtkIdType valueIdx) override
Return a void pointer.
bool AllocateTuples(vtkIdType numTuples)
ValueType GetValue(vtkIdType valueIdx) const
vtkAOSArrayNewInstanceMacro(SelfType)
ArrayType::ValueType ValueType
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
void SetValue(vtkIdType valueIdx, ValueType value)
@ value
Definition: vtkX3D.h:220
#define VTK_STANDARD_NEW_BODY(thisClass)
int vtkIdType
Definition: vtkType.h:315