VTK
vtkTestDataArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSOADataArrayTemplate.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 =========================================================================*/
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 
39 template <class ArrayT>
40 class vtkTestDataArray : public vtkGenericDataArray<vtkTestDataArray<ArrayT>,
41  typename ArrayT::ValueType>
42 {
43 public:
44  typedef ArrayT ArrayType;
45  typedef typename ArrayType::ValueType ValueType;
49  friend class vtkGenericDataArray<vtkTestDataArray<ArrayT>, ValueType>;
50 
53 
54  static vtkTestDataArray<ArrayType>* New()
56 
57  void PrintSelf(ostream &os, vtkIndent indent) override
58  { GenericDataArrayType::PrintSelf(os,indent); }
59 
60  ValueType GetValue(vtkIdType valueIdx) const
61  { return this->Array->GetValue(valueIdx); }
62  void SetValue(vtkIdType valueIdx, ValueType value)
63  { this->Array->SetValue(valueIdx,value); }
64 
65  void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
66  { this->Array->SetTypedTuple(tupleIdx,tuple); }
67  void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple)
68  { this->Array->SetTypedTuple(tupleIdx,tuple); }
69 
70  ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
71  { return this->Array->GetTypedComponent(tupleIdx,compIdx); }
72  void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
73  { this->Array->SetTypedComponent(tupleIdx,compIdx,value); }
74 
75  void *GetVoidPointer(vtkIdType valueIdx) override
76  { return this->Array->GetVoidPointer(valueIdx); }
77 
78 protected:
79  vtkTestDataArray() { this->Array = ArrayType::New(); }
80  ~vtkTestDataArray() override { this->Array->Delete(); }
81 
82  bool AllocateTuples(vtkIdType numTuples)
83  { return this->Array->Allocate(numTuples) != 0; }
84  bool ReallocateTuples(vtkIdType numTuples)
85  { return this->Array->Allocate(numTuples) != 0; }
86 
87 private:
88  ArrayType* Array;
89 
90  vtkTestDataArray(const vtkTestDataArray &) = delete;
91  void operator=(const vtkTestDataArray &) = delete;
92 };
93 
94 #endif
95 // VTK-HeaderTest-Exclude: vtkTestDataArray.h
void * GetVoidPointer(vtkIdType valueIdx) override
Return a void pointer.
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
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:347
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:39
vtkAbstractTemplateTypeMacro(SelfType, GenericDataArrayType) vtkAOSArrayNewInstanceMacro(SelfType) static vtkTestDataArray< ArrayType > *New()
void GetTypedTuple(vtkIdType tupleIdx, ValueType *tuple) const
bool ReallocateTuples(vtkIdType numTuples)
void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
#define VTK_STANDARD_NEW_BODY(thisClass)
#define vtkAOSArrayNewInstanceMacro(thisClass)
An implementation of vtkGenericDataArray for testing fallback algorithms.
vtkGenericDataArray< vtkTestDataArray< ArrayT >, ValueType > GenericDataArrayType
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
~vtkTestDataArray() override
bool AllocateTuples(vtkIdType numTuples)