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 template <class T> New()24vtkArrayIteratorTemplate<T>* vtkArrayIteratorTemplate<T>::New() 25 { 26 vtkObject* ret = vtkObjectFactory::CreateInstance("vtkArrayIteratorTemplate"); 27 if (ret) 28 { 29 return static_cast<vtkArrayIteratorTemplate<T>*> (ret); 30 } 31 return new vtkArrayIteratorTemplate<T>; 32 } 33 34 template <class T> 35 vtkCxxSetObjectMacro(vtkArrayIteratorTemplate<T>, Array, vtkAbstractArray); 36 //----------------------------------------------------------------------------- 37 template <class T> vtkArrayIteratorTemplate()38vtkArrayIteratorTemplate<T>::vtkArrayIteratorTemplate() 39 { 40 this->Array = 0; 41 this->Pointer = 0; 42 } 43 44 //----------------------------------------------------------------------------- 45 template <class T> ~vtkArrayIteratorTemplate()46vtkArrayIteratorTemplate<T>::~vtkArrayIteratorTemplate() 47 { 48 this->SetArray(0); 49 this->Pointer = 0; 50 } 51 52 //----------------------------------------------------------------------------- 53 template <class T> Initialize(vtkAbstractArray * a)54void vtkArrayIteratorTemplate<T>::Initialize(vtkAbstractArray* a) 55 { 56 this->SetArray(a); 57 this->Pointer = 0; 58 if (this->Array) 59 { 60 this->Pointer = static_cast<T*>(this->Array->GetVoidPointer(0)); 61 } 62 } 63 64 //----------------------------------------------------------------------------- 65 template <class T> GetNumberOfTuples()66vtkIdType vtkArrayIteratorTemplate<T>::GetNumberOfTuples() 67 { 68 if (this->Array) 69 { 70 return this->Array->GetNumberOfTuples(); 71 } 72 return 0; 73 } 74 75 //----------------------------------------------------------------------------- 76 template <class T> GetNumberOfValues()77vtkIdType vtkArrayIteratorTemplate<T>::GetNumberOfValues() 78 { 79 if (this->Array) 80 { 81 return (this->Array->GetNumberOfTuples() * this->Array->GetNumberOfComponents()); 82 } 83 return 0; 84 } 85 86 //----------------------------------------------------------------------------- 87 template <class T> GetNumberOfComponents()88int vtkArrayIteratorTemplate<T>::GetNumberOfComponents() 89 { 90 if (this->Array) 91 { 92 return this->Array->GetNumberOfComponents(); 93 } 94 return 0; 95 } 96 97 //----------------------------------------------------------------------------- 98 template <class T> GetTuple(vtkIdType id)99T* vtkArrayIteratorTemplate<T>::GetTuple(vtkIdType id) 100 { 101 return &this->Pointer[id * this->Array->GetNumberOfComponents()]; 102 } 103 104 //----------------------------------------------------------------------------- 105 template <class T> GetDataType()106int vtkArrayIteratorTemplate<T>::GetDataType() 107 { 108 return this->Array->GetDataType(); 109 } 110 111 //----------------------------------------------------------------------------- 112 template <class T> GetDataTypeSize()113int vtkArrayIteratorTemplate<T>::GetDataTypeSize() 114 { 115 return this->Array->GetDataTypeSize(); 116 } 117 118 //----------------------------------------------------------------------------- 119 template <class T> PrintSelf(ostream & os,vtkIndent indent)120void vtkArrayIteratorTemplate<T>::PrintSelf(ostream& os, vtkIndent indent) 121 { 122 this->Superclass::PrintSelf(os, indent); 123 os << indent << "Array: " ; 124 if (this->Array) 125 { 126 os << "\n"; 127 this->Array->PrintSelf(os, indent.GetNextIndent()); 128 } 129 else 130 { 131 os << "(none)" << "\n"; 132 } 133 } 134 135 #endif 136 137