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 vtkDataArrayTemplateLookup;
00030
00031 template <class T>
00032 class vtkDataArrayTemplate: public vtkDataArray
00033 {
00034 public:
00035 typedef vtkDataArray Superclass;
00036 void PrintSelf(ostream& os, vtkIndent indent);
00037
00040 int Allocate(vtkIdType sz, vtkIdType ext=1000);
00041
00043 void Initialize();
00044
00046 int GetDataTypeSize() { return static_cast<int>(sizeof(T)); }
00047
00049 void SetNumberOfTuples(vtkIdType number);
00050
00056 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00057
00061 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00062
00066 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00067
00070 double* GetTuple(vtkIdType i);
00071
00073
00074 void GetTuple(vtkIdType i, double* tuple);
00075 void GetTupleValue(vtkIdType i, T* tuple);
00077
00079
00080 void SetTuple(vtkIdType i, const float* tuple);
00081 void SetTuple(vtkIdType i, const double* tuple);
00082 void SetTupleValue(vtkIdType i, const T* tuple);
00084
00086
00088 void InsertTuple(vtkIdType i, const float* tuple);
00089 void InsertTuple(vtkIdType i, const double* tuple);
00090 void InsertTupleValue(vtkIdType i, const T* tuple);
00092
00094
00096 vtkIdType InsertNextTuple(const float* tuple);
00097 vtkIdType InsertNextTuple(const double* tuple);
00098 vtkIdType InsertNextTupleValue(const T* tuple);
00100
00102 void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
00103
00105 virtual int Resize(vtkIdType numTuples);
00106
00108 T GetValue(vtkIdType id) { return this->Array[id]; }
00109
00111
00113 void SetValue(vtkIdType id, T value)
00114 { this->Array[id] = value;};
00116
00120 void SetNumberOfValues(vtkIdType number);
00121
00123 void InsertValue(vtkIdType id, T f);
00124
00127 vtkIdType InsertNextValue(T f);
00128
00130
00133 virtual void RemoveTuple(vtkIdType id);
00134 virtual void RemoveFirstTuple();
00135 virtual void RemoveLastTuple();
00137
00141 double GetComponent(vtkIdType i, int j);
00142
00147 void SetComponent(vtkIdType i, int j, double c);
00148
00152 virtual void InsertComponent(vtkIdType i, int j, double c);
00153
00155
00158 T* WritePointer(vtkIdType id, vtkIdType number);
00159 virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number)
00160 { return this->WritePointer(id, number); }
00162
00164
00166 T* GetPointer(vtkIdType id) { return this->Array + id; }
00167 virtual void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00169
00171
00172 void DeepCopy(vtkDataArray* da);
00173 void DeepCopy(vtkAbstractArray* aa)
00174 { this->Superclass::DeepCopy(aa); }
00176
00177
00178 enum DeleteMethod
00179 {
00180 VTK_DATA_ARRAY_FREE,
00181 VTK_DATA_ARRAY_DELETE
00182 };
00183
00184
00186
00195 void SetArray(T* array, vtkIdType size, int save, int deleteMethod);
00196 void SetArray(T* array, vtkIdType size, int save)
00197 { this->SetArray(array, size, save, VTK_DATA_ARRAY_FREE); }
00198 virtual void SetVoidArray(void* array, vtkIdType size, int save)
00199 { this->SetArray(static_cast<T*>(array), size, save); }
00200 virtual void SetVoidArray(void* array,
00201 vtkIdType size,
00202 int save,
00203 int deleteMethod)
00204 {
00205 this->SetArray(static_cast<T*>(array), size, save, deleteMethod);
00206 }
00208
00212 virtual void ExportToVoidPointer(void *out_ptr);
00213
00215 virtual void ComputeRange(int comp);
00216
00218 virtual vtkArrayIterator* NewIterator();
00219
00220
00222
00223 virtual vtkIdType LookupValue(vtkVariant value);
00224 virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00225
00226 vtkIdType LookupValue(T value);
00227 void LookupValue(T value, vtkIdList* ids);
00229
00236 virtual void DataChanged();
00237
00241 virtual void ClearLookup();
00242
00243 protected:
00244 vtkDataArrayTemplate(vtkIdType numComp);
00245 ~vtkDataArrayTemplate();
00246
00247 T* Array;
00248 T* ResizeAndExtend(vtkIdType sz);
00249 T* Realloc(vtkIdType sz);
00250
00251 int TupleSize;
00252 double* Tuple;
00253
00254 int SaveUserArray;
00255 int DeleteMethod;
00256
00257 void ComputeScalarRange(int comp);
00258 void ComputeVectorRange();
00259 private:
00260 vtkDataArrayTemplate(const vtkDataArrayTemplate&);
00261 void operator=(const vtkDataArrayTemplate&);
00262
00263 vtkDataArrayTemplateLookup<T>* Lookup;
00264 void UpdateLookup();
00265
00266 void DeleteArray();
00267 };
00268
00269 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
00270 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
00271 template class VTK_COMMON_EXPORT vtkDataArrayTemplate< T >
00272 #else
00273 # include "vtkDataArrayTemplateImplicit.txx"
00274 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
00275 #endif
00276
00277 #endif // !defined(__vtkDataArrayTemplate_h)
00278
00279
00280
00281
00282 #if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
00283 # if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
00284 # pragma warning (push)
00285 # pragma warning (disable: 4091) // warning C4091: 'extern ' :
00286
00287 # pragma warning (disable: 4231) // Compiler-specific extension warning.
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300 # pragma warning (disable: 4910) // extern and dllexport incompatible
00301
00302
00303
00304 extern VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
00305 # pragma warning (pop)
00306 # endif
00307 # undef VTK_DATA_ARRAY_TEMPLATE_TYPE
00308 #endif