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 vtkIdType Capacity() { return this->Size; }
00106
00108 virtual int Resize(vtkIdType numTuples);
00109
00111 T GetValue(vtkIdType id) { return this->Array[id]; }
00112
00114
00116 void SetValue(vtkIdType id, T value)
00117 { this->Array[id] = value;};
00119
00123 void SetNumberOfValues(vtkIdType number);
00124
00126 void InsertValue(vtkIdType id, T f);
00127
00129 void InsertVariantValue(vtkIdType id, vtkVariant value);
00130
00133 vtkIdType InsertNextValue(T f);
00134
00136
00139 virtual void RemoveTuple(vtkIdType id);
00140 virtual void RemoveFirstTuple();
00141 virtual void RemoveLastTuple();
00143
00147 double GetComponent(vtkIdType i, int j);
00148
00153 void SetComponent(vtkIdType i, int j, double c);
00154
00158 virtual void InsertComponent(vtkIdType i, int j, double c);
00159
00161
00164 T* WritePointer(vtkIdType id, vtkIdType number);
00165 virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number)
00166 { return this->WritePointer(id, number); }
00168
00170
00172 T* GetPointer(vtkIdType id) { return this->Array + id; }
00173 virtual void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00175
00177
00178 void DeepCopy(vtkDataArray* da);
00179 void DeepCopy(vtkAbstractArray* aa)
00180 { this->Superclass::DeepCopy(aa); }
00182
00183
00184 enum DeleteMethod
00185 {
00186 VTK_DATA_ARRAY_FREE,
00187 VTK_DATA_ARRAY_DELETE
00188 };
00189
00190
00192
00201 void SetArray(T* array, vtkIdType size, int save, int deleteMethod);
00202 void SetArray(T* array, vtkIdType size, int save)
00203 { this->SetArray(array, size, save, VTK_DATA_ARRAY_FREE); }
00204 virtual void SetVoidArray(void* array, vtkIdType size, int save)
00205 { this->SetArray(static_cast<T*>(array), size, save); }
00206 virtual void SetVoidArray(void* array,
00207 vtkIdType size,
00208 int save,
00209 int deleteMethod)
00210 {
00211 this->SetArray(static_cast<T*>(array), size, save, deleteMethod);
00212 }
00214
00218 virtual void ExportToVoidPointer(void *out_ptr);
00219
00221 virtual void ComputeRange(int comp);
00222
00224 virtual vtkArrayIterator* NewIterator();
00225
00226
00228
00229 virtual vtkIdType LookupValue(vtkVariant value);
00230 virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00231
00232 vtkIdType LookupValue(T value);
00233 void LookupValue(T value, vtkIdList* ids);
00235
00242 virtual void DataChanged();
00243
00247 virtual void DataElementChanged(vtkIdType id);
00248
00252 virtual void ClearLookup();
00253
00254 protected:
00255 vtkDataArrayTemplate(vtkIdType numComp);
00256 ~vtkDataArrayTemplate();
00257
00258 T* Array;
00259 T* ResizeAndExtend(vtkIdType sz);
00260 T* Realloc(vtkIdType sz);
00261
00262 int TupleSize;
00263 double* Tuple;
00264
00265 int SaveUserArray;
00266 int DeleteMethod;
00267
00268 void ComputeScalarRange(int comp);
00269 void ComputeVectorRange();
00270 private:
00271 vtkDataArrayTemplate(const vtkDataArrayTemplate&);
00272 void operator=(const vtkDataArrayTemplate&);
00273
00274 vtkDataArrayTemplateLookup<T>* Lookup;
00275 void UpdateLookup();
00276
00277 void DeleteArray();
00278 };
00279
00280 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
00281 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
00282 template class VTK_COMMON_EXPORT vtkDataArrayTemplate< T >
00283 #else
00284 # include "vtkDataArrayTemplateImplicit.txx"
00285 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
00286 #endif
00287
00288 #endif // !defined(__vtkDataArrayTemplate_h)
00289
00290
00291
00292
00293 #if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
00294 # if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
00295 # pragma warning (push)
00296 # pragma warning (disable: 4091) // warning C4091: 'extern ' :
00297
00298 # pragma warning (disable: 4231) // Compiler-specific extension warning.
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 # pragma warning (disable: 4910) // extern and dllexport incompatible
00312
00313
00314
00315 extern VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
00316 # pragma warning (pop)
00317 # endif
00318 # undef VTK_DATA_ARRAY_TEMPLATE_TYPE
00319 #endif