Common/vtkDataArrayTemplate.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00023 #ifndef __vtkDataArrayTemplate_h
00024 #define __vtkDataArrayTemplate_h
00025
00026 #include "vtkDataArray.h"
00027
00028 template <class T>
00029 class vtkDataArrayTemplate: public vtkDataArray
00030 {
00031 public:
00032 typedef vtkDataArray Superclass;
00033 void PrintSelf(ostream& os, vtkIndent indent);
00034
00037 int Allocate(vtkIdType sz, vtkIdType ext=1000);
00038
00040 void Initialize();
00041
00043 int GetDataTypeSize() { return static_cast<int>(sizeof(T)); }
00044
00046 void SetNumberOfTuples(vtkIdType number);
00047
00050 double* GetTuple(vtkIdType i);
00051
00053 void GetTuple(vtkIdType i, double* tuple);
00054
00056
00057 void SetTuple(vtkIdType i, const float* tuple);
00058 void SetTuple(vtkIdType i, const double* tuple);
00060
00062
00064 void InsertTuple(vtkIdType i, const float* tuple);
00065 void InsertTuple(vtkIdType i, const double* tuple);
00067
00069
00071 vtkIdType InsertNextTuple(const float* tuple);
00072 vtkIdType InsertNextTuple(const double* tuple);
00074
00076 void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
00077
00079 virtual void Resize(vtkIdType numTuples);
00080
00082 T GetValue(vtkIdType id) { return this->Array[id]; }
00083
00085
00087 void SetValue(vtkIdType id, T value)
00088 { this->Array[id] = value;};
00090
00094 void SetNumberOfValues(vtkIdType number);
00095
00097 void InsertValue(vtkIdType id, T f);
00098
00101 vtkIdType InsertNextValue(T f);
00102
00106 double GetComponent(vtkIdType i, int j);
00107
00112 void SetComponent(vtkIdType i, int j, double c);
00113
00117 virtual void InsertComponent(vtkIdType i, int j, double c);
00118
00122 T* WritePointer(vtkIdType id, vtkIdType number);
00123
00125
00127 T* GetPointer(vtkIdType id) { return this->Array + id; }
00128 void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00130
00132 void DeepCopy(vtkDataArray* da);
00133
00135
00141 void SetArray(T* array, vtkIdType size, int save);
00142 void SetVoidArray(void* array, vtkIdType size, int save)
00143 { this->SetArray(static_cast<T*>(array), size, save); }
00145
00146 protected:
00147 vtkDataArrayTemplate(vtkIdType numComp);
00148 ~vtkDataArrayTemplate();
00149
00150 T* Array;
00151 T* ResizeAndExtend(vtkIdType sz);
00152
00153 int TupleSize;
00154 double* Tuple;
00155
00156 int SaveUserArray;
00157
00158 private:
00159 vtkDataArrayTemplate(const vtkDataArrayTemplate&);
00160 void operator=(const vtkDataArrayTemplate&);
00161 };
00162
00163 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
00164 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
00165 template class VTK_COMMON_EXPORT vtkDataArrayTemplate< T >
00166 #else
00167 # include "vtkDataArrayTemplateImplicit.txx"
00168 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
00169 #endif
00170
00171 #endif // !defined(__vtkDataArrayTemplate_h)
00172
00173
00174
00175
00176 #if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
00177 # if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
00178 # pragma warning (push)
00179 # pragma warning (disable: 4231) // Compiler-specific extension warning.
00180
00181
00182 extern VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
00183 # pragma warning (pop)
00184 # endif
00185 # undef VTK_DATA_ARRAY_TEMPLATE_TYPE
00186 #endif