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 =========================================================================*/
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 
36 template <class ArrayT>
37 class vtkTestDataArray : public vtkGenericDataArray<vtkTestDataArray<ArrayT>,
38  typename ArrayT::ValueType>
39 {
40 public:
41  typedef ArrayT ArrayType;
42  typedef typename ArrayType::ValueType ValueType;
47 
50 
53 
54  void PrintSelf(ostream &os, vtkIndent indent) override
55  { GenericDataArrayType::PrintSelf(os,indent); }
56 
57  ValueType GetValue(vtkIdType valueIdx) const
58  { return this->Array->GetValue(valueIdx); }
60  { this->Array->SetValue(valueIdx,value); }
61 
62  void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const
63  { this->Array->SetTypedTuple(tupleIdx,tuple); }
64  void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple)
65  { this->Array->SetTypedTuple(tupleIdx,tuple); }
66 
67  ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const
68  { return this->Array->GetTypedComponent(tupleIdx,compIdx); }
69  void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value)
70  { this->Array->SetTypedComponent(tupleIdx,compIdx,value); }
71 
72  void *GetVoidPointer(vtkIdType valueIdx) override
73  { return this->Array->GetVoidPointer(valueIdx); }
74 
75 protected:
76  vtkTestDataArray() { this->Array = ArrayType::New(); }
77  ~vtkTestDataArray() override { this->Array->Delete(); }
78 
79  bool AllocateTuples(vtkIdType numTuples)
80  { return this->Array->Allocate(numTuples) != 0; }
81  bool ReallocateTuples(vtkIdType numTuples)
82  { return this->Array->Allocate(numTuples) != 0; }
83 
84 private:
85  ArrayType* Array;
86 
87  vtkTestDataArray(const vtkTestDataArray &) = delete;
88  void operator=(const vtkTestDataArray &) = delete;
89 };
90 
91 #endif
92 // VTK-HeaderTest-Exclude: vtkTestDataArray.h
void * GetVoidPointer(vtkIdType valueIdx) override
Return a void pointer.
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:345
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
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAbstractTemplateTypeMacro(SelfType, GenericDataArrayType) vtkAOSArrayNewInstanceMacro(SelfType) static vtkTestDataArray< ArrayType > *New()
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) 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
void GetTypedTuple(vtkIdType tupleIdx, ValueType *tuple) const
ValueType GetValue(vtkIdType valueIdx) const
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)