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 VTK_COMMON_EXPORT 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
00104 void GetValueRange(T range[2], int comp) {
00105 this->ComputeRange(comp);
00106 range[0] = this->ValueRange[0];
00107 range[1] = this->ValueRange[1]; }
00108 T *GetValueRange(int comp) {
00109 this->ComputeRange(comp);
00110 return this->ValueRange; }
00112
00114 void Squeeze() { this->ResizeAndExtend (this->MaxId+1, false); }
00115
00117 vtkIdType Capacity() { return this->Size; }
00118
00121 virtual int Resize(vtkIdType numTuples);
00122
00124 T GetValue(vtkIdType id) { return this->Array[id]; }
00125
00127
00129 void SetValue(vtkIdType id, T value)
00130 { this->Array[id] = value;};
00132
00136 void SetNumberOfValues(vtkIdType number);
00137
00139 void InsertValue(vtkIdType id, T f);
00140
00142 void SetVariantValue(vtkIdType id, vtkVariant value);
00143
00146 vtkIdType InsertNextValue(T f);
00147
00149
00152 virtual void RemoveTuple(vtkIdType id);
00153 virtual void RemoveFirstTuple();
00154 virtual void RemoveLastTuple();
00156
00160 double GetComponent(vtkIdType i, int j);
00161
00166 void SetComponent(vtkIdType i, int j, double c);
00167
00171 virtual void InsertComponent(vtkIdType i, int j, double c);
00172
00174
00177 T* WritePointer(vtkIdType id, vtkIdType number);
00178 virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number)
00179 { return this->WritePointer(id, number); }
00181
00183
00185 T* GetPointer(vtkIdType id) { return this->Array + id; }
00186 virtual void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00188
00190
00191 void DeepCopy(vtkDataArray* da);
00192 void DeepCopy(vtkAbstractArray* aa)
00193 { this->Superclass::DeepCopy(aa); }
00195
00196
00197 enum DeleteMethod
00198 {
00199 VTK_DATA_ARRAY_FREE,
00200 VTK_DATA_ARRAY_DELETE
00201 };
00202
00203
00205
00214 void SetArray(T* array, vtkIdType size, int save, int deleteMethod);
00215 void SetArray(T* array, vtkIdType size, int save)
00216 { this->SetArray(array, size, save, VTK_DATA_ARRAY_FREE); }
00217 virtual void SetVoidArray(void* array, vtkIdType size, int save)
00218 { this->SetArray(static_cast<T*>(array), size, save); }
00219 virtual void SetVoidArray(void* array,
00220 vtkIdType size,
00221 int save,
00222 int deleteMethod)
00223 {
00224 this->SetArray(static_cast<T*>(array), size, save, deleteMethod);
00225 }
00227
00231 virtual void ExportToVoidPointer(void *out_ptr);
00232
00234 virtual vtkArrayIterator* NewIterator();
00235
00237
00238 virtual vtkIdType LookupValue(vtkVariant value);
00239 virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00240 vtkIdType LookupValue(T value);
00241 void LookupValue(T value, vtkIdList* ids);
00243
00250 virtual void DataChanged();
00251
00255 virtual void DataElementChanged(vtkIdType id);
00256
00260 virtual void ClearLookup();
00261
00262 protected:
00263 vtkDataArrayTemplate(vtkIdType numComp);
00264 ~vtkDataArrayTemplate();
00265
00266 T* Array;
00267 T ValueRange[2];
00268 T* ResizeAndExtend(vtkIdType sz, bool useExactSize);
00269 T* Realloc(vtkIdType sz);
00270
00271 int TupleSize;
00272 double* Tuple;
00273
00274 int SaveUserArray;
00275 int DeleteMethod;
00276
00277 virtual void ComputeScalarRange(int comp);
00278 virtual void ComputeVectorRange();
00279 private:
00280 vtkDataArrayTemplate(const vtkDataArrayTemplate&);
00281 void operator=(const vtkDataArrayTemplate&);
00282
00283 vtkDataArrayTemplateLookup<T>* Lookup;
00284 void UpdateLookup();
00285
00286 void DeleteArray();
00287 };
00288
00289 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
00290 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
00291 template class VTK_COMMON_EXPORT vtkDataArrayTemplate< T >
00292 #else
00293 # include "vtkDataArrayTemplateImplicit.txx"
00294 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
00295 #endif
00296
00297 #endif // !defined(__vtkDataArrayTemplate_h)
00298
00299
00300
00301
00302 #if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
00303 # if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
00304 # pragma warning (push)
00305 # pragma warning (disable: 4091) // warning C4091: 'extern ' :
00306
00307 # pragma warning (disable: 4231) // Compiler-specific extension warning.
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 # pragma warning (disable: 4910) // extern and dllexport incompatible
00321
00322
00323
00324 extern VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
00325 # pragma warning (pop)
00326 # endif
00327 # undef VTK_DATA_ARRAY_TEMPLATE_TYPE
00328 #endif