00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00048 #ifndef __vtkDenseArray_h
00049 #define __vtkDenseArray_h
00050
00051 #include "vtkArrayCoordinates.h"
00052 #include "vtkObjectFactory.h"
00053 #include "vtkTypedArray.h"
00054 #include "vtkTypeTemplate.h"
00055
00056 template<typename T>
00057 class vtkDenseArray :
00058 public vtkTypeTemplate<vtkDenseArray<T>, vtkTypedArray<T> >
00059 {
00060 public:
00061 static vtkDenseArray<T>* New();
00062 void PrintSelf(ostream &os, vtkIndent indent);
00063
00064
00065 bool IsDense();
00066 const vtkArrayExtents& GetExtents();
00067 vtkIdType GetNonNullSize();
00068 void GetCoordinatesN(const vtkIdType n, vtkArrayCoordinates& coordinates);
00069 vtkArray* DeepCopy();
00070
00071
00072 const T& GetValue(vtkIdType i);
00073 const T& GetValue(vtkIdType i, vtkIdType j);
00074 const T& GetValue(vtkIdType i, vtkIdType j, vtkIdType k);
00075 const T& GetValue(const vtkArrayCoordinates& coordinates);
00076 const T& GetValueN(const vtkIdType n);
00077 void SetValue(vtkIdType i, const T& value);
00078 void SetValue(vtkIdType i, vtkIdType j, const T& value);
00079 void SetValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00080 void SetValue(const vtkArrayCoordinates& coordinates, const T& value);
00081 void SetValueN(const vtkIdType n, const T& value);
00082
00083
00084
00086
00089 class MemoryBlock
00090 {
00091 public:
00092 virtual ~MemoryBlock();
00093
00094
00095 virtual T* GetAddress() = 0;
00096 };
00098
00100
00103 class HeapMemoryBlock :
00104 public MemoryBlock
00105 {
00106 public:
00107 HeapMemoryBlock(const vtkArrayExtents& extents);
00108 virtual ~HeapMemoryBlock();
00109 virtual T* GetAddress();
00111
00112 private:
00113 T* Storage;
00114 };
00115
00117
00119 class StaticMemoryBlock :
00120 public MemoryBlock
00121 {
00122 public:
00123 StaticMemoryBlock(T* const storage);
00124 virtual T* GetAddress();
00126
00127 private:
00128 T* Storage;
00129 };
00130
00144 void ExternalStorage(const vtkArrayExtents& extents, MemoryBlock* storage);
00145
00147 void Fill(const T& value);
00148
00151 T& operator[](const vtkArrayCoordinates& coordinates);
00152
00155 const T* GetStorage() const;
00156
00159 T* GetStorage();
00160
00161 protected:
00162 vtkDenseArray();
00163 ~vtkDenseArray();
00164
00165 private:
00166 vtkDenseArray(const vtkDenseArray&);
00167 void operator=(const vtkDenseArray&);
00168
00169 void InternalResize(const vtkArrayExtents& extents);
00170 void InternalSetDimensionLabel(vtkIdType i, const vtkStdString& label);
00171 vtkStdString InternalGetDimensionLabel(vtkIdType i);
00172 inline vtkIdType MapCoordinates(vtkIdType i);
00173 inline vtkIdType MapCoordinates(vtkIdType i, vtkIdType j);
00174 inline vtkIdType MapCoordinates(vtkIdType i, vtkIdType j, vtkIdType k);
00175 inline vtkIdType MapCoordinates(const vtkArrayCoordinates& coordinates);
00176
00177 void Reconfigure(const vtkArrayExtents& extents, MemoryBlock* storage);
00178
00179 typedef vtkDenseArray<T> ThisT;
00180
00182 vtkArrayExtents Extents;
00183
00185 vtkstd::vector<vtkStdString> DimensionLabels;
00186
00188 MemoryBlock* Storage;
00189
00191
00193 T* Begin;
00194 T* End;
00196
00198
00199 vtkstd::vector<vtkIdType> Offsets;
00200
00201
00202 vtkstd::vector<vtkIdType> Strides;
00204 };
00205
00206 #include "vtkDenseArray.txx"
00207
00208 #endif
00209