VTK  9.1.0
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=========================================================================*/
29#ifndef vtkTestDataArray_h
30#define vtkTestDataArray_h
31
32#include "vtkCommonCoreModule.h" // For export macro
33#include "vtkGenericDataArray.h"
34#include "vtkObjectFactory.h" // For VTK_STANDARD_NEW_BODY
35
36template <class ArrayT>
38 : public vtkGenericDataArray<vtkTestDataArray<ArrayT>, typename ArrayT::ValueType>
39{
40public:
41 typedef ArrayT ArrayType;
42 typedef typename ArrayType::ValueType ValueType;
45 friend class vtkGenericDataArray<vtkTestDataArray<ArrayT>, ValueType>;
46
49
51
52 void PrintSelf(ostream& os, vtkIndent indent) override
53 {
55 }
56
57 ValueType GetValue(vtkIdType valueIdx) const { return this->Array->GetValue(valueIdx); }
58 void SetValue(vtkIdType valueIdx, ValueType value) { this->Array->SetValue(valueIdx, value); }
59
60 void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
61 {
62 this->Array->SetTypedTuple(tupleIdx, tuple);
63 }
64 void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple)
65 {
66 this->Array->SetTypedTuple(tupleIdx, tuple);
67 }
68
69 ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
70 {
71 return this->Array->GetTypedComponent(tupleIdx, compIdx);
72 }
73 void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
74 {
75 this->Array->SetTypedComponent(tupleIdx, compIdx, value);
76 }
77
78 void* GetVoidPointer(vtkIdType valueIdx) override
79 {
80 return this->Array->GetVoidPointer(valueIdx);
81 }
82
83protected:
84 vtkTestDataArray() { this->Array = ArrayType::New(); }
85 ~vtkTestDataArray() override { this->Array->Delete(); }
86
87 bool AllocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
88 bool ReallocateTuples(vtkIdType numTuples) { return this->Array->Allocate(numTuples) != 0; }
89
90private:
91 ArrayType* Array;
92
93 vtkTestDataArray(const vtkTestDataArray&) = delete;
94 void operator=(const vtkTestDataArray&) = delete;
95};
96
97#endif
98// 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:113
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
Return a void pointer.
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