1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkArrayIteratorTemplate.txx 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 =========================================================================*/ 15 #ifndef vtkArrayIteratorTemplate_txx 16 #define vtkArrayIteratorTemplate_txx 17 18 #include "vtkArrayIteratorTemplate.h" 19 20 #include "vtkAbstractArray.h" 21 #include "vtkObjectFactory.h" 22 23 //----------------------------------------------------------------------------- 24 template <class T> New()25vtkArrayIteratorTemplate<T>* vtkArrayIteratorTemplate<T>::New() 26 { 27 VTK_STANDARD_NEW_BODY(vtkArrayIteratorTemplate<T>); 28 } 29 30 template <class T> 31 vtkCxxSetObjectMacro(vtkArrayIteratorTemplate<T>, Array, vtkAbstractArray); 32 33 //----------------------------------------------------------------------------- 34 template <class T> vtkArrayIteratorTemplate()35vtkArrayIteratorTemplate<T>::vtkArrayIteratorTemplate() 36 { 37 this->Array = nullptr; 38 this->Pointer = nullptr; 39 } 40 41 //----------------------------------------------------------------------------- 42 template <class T> ~vtkArrayIteratorTemplate()43vtkArrayIteratorTemplate<T>::~vtkArrayIteratorTemplate() 44 { 45 this->SetArray(nullptr); 46 this->Pointer = nullptr; 47 } 48 49 //----------------------------------------------------------------------------- 50 template <class T> Initialize(vtkAbstractArray * a)51void vtkArrayIteratorTemplate<T>::Initialize(vtkAbstractArray* a) 52 { 53 this->SetArray(a); 54 this->Pointer = nullptr; 55 if (this->Array) 56 { 57 this->Pointer = static_cast<T*>(this->Array->GetVoidPointer(0)); 58 } 59 } 60 61 //----------------------------------------------------------------------------- 62 template <class T> GetNumberOfTuples() const63vtkIdType vtkArrayIteratorTemplate<T>::GetNumberOfTuples() const 64 { 65 if (this->Array) 66 { 67 return this->Array->GetNumberOfTuples(); 68 } 69 return 0; 70 } 71 72 //----------------------------------------------------------------------------- 73 template <class T> GetNumberOfValues() const74vtkIdType vtkArrayIteratorTemplate<T>::GetNumberOfValues() const 75 { 76 if (this->Array) 77 { 78 return (this->Array->GetNumberOfTuples() * this->Array->GetNumberOfComponents()); 79 } 80 return 0; 81 } 82 83 //----------------------------------------------------------------------------- 84 template <class T> GetNumberOfComponents() const85int vtkArrayIteratorTemplate<T>::GetNumberOfComponents() const 86 { 87 if (this->Array) 88 { 89 return this->Array->GetNumberOfComponents(); 90 } 91 return 0; 92 } 93 94 //----------------------------------------------------------------------------- 95 template <class T> GetTuple(vtkIdType id)96T* vtkArrayIteratorTemplate<T>::GetTuple(vtkIdType id) 97 { 98 return &this->Pointer[id * this->Array->GetNumberOfComponents()]; 99 } 100 101 //----------------------------------------------------------------------------- 102 template <class T> GetDataType() const103int vtkArrayIteratorTemplate<T>::GetDataType() const 104 { 105 return this->Array->GetDataType(); 106 } 107 108 //----------------------------------------------------------------------------- 109 template <class T> GetDataTypeSize() const110int vtkArrayIteratorTemplate<T>::GetDataTypeSize() const 111 { 112 return this->Array->GetDataTypeSize(); 113 } 114 115 //----------------------------------------------------------------------------- 116 template <class T> PrintSelf(ostream & os,vtkIndent indent)117void vtkArrayIteratorTemplate<T>::PrintSelf(ostream& os, vtkIndent indent) 118 { 119 this->Superclass::PrintSelf(os, indent); 120 os << indent << "Array: "; 121 if (this->Array) 122 { 123 os << "\n"; 124 this->Array->PrintSelf(os, indent.GetNextIndent()); 125 } 126 else 127 { 128 os << "(none)" 129 << "\n"; 130 } 131 } 132 133 #endif 134