VTK  9.2.6
vtkTestDataArray.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkTestDataArray.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm 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=========================================================================*/
31
32#ifndef vtkTestDataArray_h
33#define vtkTestDataArray_h
34
35#include "vtkCommonCoreModule.h" // For export macro
36#include "vtkGenericDataArray.h"
37#include "vtkObjectFactory.h" // For VTK_STANDARD_NEW_BODY
38
39template <class ArrayT>
41 : public vtkGenericDataArray<vtkTestDataArray<ArrayT>, typename ArrayT::ValueType>
42{
43public:
44 typedef ArrayT ArrayType;
45 typedef typename ArrayType::ValueType ValueType;
48 friend class vtkGenericDataArray<vtkTestDataArray<ArrayT>, ValueType>;
49
52
54
55 void PrintSelf(ostream& os, vtkIndent indent) override
56 {
58 }
59
60 ValueType GetValue(vtkIdType valueIdx) const { return this->Array->GetValue(valueIdx); }
61 void SetValue(vtkIdType valueIdx, ValueType value) { this->Array->SetValue(valueIdx, value); }
62
63 void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
64 {
65 this->Array->SetTypedTuple(tupleIdx, tuple);
66 }
67 void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple)
68 {
69 this->Array->SetTypedTuple(tupleIdx, tuple);
70 }
71
72 ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
73 {
74 return this->Array->GetTypedComponent(tupleIdx, compIdx);
75 }
76 void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
77 {
78 this->Array->SetTypedComponent(tupleIdx, compIdx, value);
79 }
80
81 void* GetVoidPointer(vtkIdType valueIdx) override
82 {
83 return this->Array->GetVoidPointer(valueIdx);
84 }
85
86protected:
87 vtkTestDataArray() { this->Array = ArrayType::New(); }
88 ~vtkTestDataArray() override { this->Array->Delete(); }
89
90 bool AllocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
91 bool ReallocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
92
93private:
94 ArrayType* Array;
95
96 vtkTestDataArray(const vtkTestDataArray&) = delete;
97 void operator=(const vtkTestDataArray&) = delete;
98};
99
100#endif
101// VTK-HeaderTest-Exclude: vtkTestDataArray.h
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition vtkIndent.h:40
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 * GetVoidPointer(vtkIdType valueIdx) override
Default implementation raises a runtime error.
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
bool AllocateTuples(vtkIdType numTuples)
ValueType GetValue(vtkIdType valueIdx) const
static vtkTestDataArray< ArrayType > * New()
vtkAOSArrayNewInstanceMacro(SelfType)
ArrayType::ValueType ValueType
void SetTypedTuple(vtkIdType tupleIdx, const ValueType *tuple)
void SetValue(vtkIdType valueIdx, ValueType value)
#define VTK_STANDARD_NEW_BODY(thisClass)
int vtkIdType
Definition vtkType.h:332