00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00071 #ifndef __vtkSparseArray_h
00072 #define __vtkSparseArray_h
00073
00074 #include "vtkArrayCoordinates.h"
00075 #include "vtkArraySort.h"
00076 #include "vtkObjectFactory.h"
00077 #include "vtkTypeTemplate.h"
00078 #include "vtkTypedArray.h"
00079
00080 template<typename T>
00081 class vtkSparseArray :
00082 public vtkTypeTemplate<vtkSparseArray<T>, vtkTypedArray<T> >
00083 {
00084 public:
00085 static vtkSparseArray<T>* New();
00086 void PrintSelf(ostream &os, vtkIndent indent);
00087
00088
00089 bool IsDense();
00090 const vtkArrayExtents& GetExtents();
00091 vtkIdType GetNonNullSize();
00092 void GetCoordinatesN(const vtkIdType n, vtkArrayCoordinates& coordinates);
00093 vtkArray* DeepCopy();
00094
00095
00096 const T& GetValue(vtkIdType i);
00097 const T& GetValue(vtkIdType i, vtkIdType j);
00098 const T& GetValue(vtkIdType i, vtkIdType j, vtkIdType k);
00099 const T& GetValue(const vtkArrayCoordinates& coordinates);
00100 const T& GetValueN(const vtkIdType n);
00101 void SetValue(vtkIdType i, const T& value);
00102 void SetValue(vtkIdType i, vtkIdType j, const T& value);
00103 void SetValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00104 void SetValue(const vtkArrayCoordinates& coordinates, const T& value);
00105 void SetValueN(const vtkIdType n, const T& value);
00106
00107
00108
00111 void SetNullValue(const T& value);
00112
00115 const T& GetNullValue();
00116
00120 void Clear();
00121
00127 void Sort(const vtkArraySort& sort);
00128
00130 vtkstd::vector<vtkIdType> GetUniqueCoordinates(vtkIdType dimension);
00131
00136 const vtkIdType* GetCoordinateStorage(vtkIdType dimension) const;
00137
00143 vtkIdType* GetCoordinateStorage(vtkIdType dimension);
00144
00149 const T* GetValueStorage() const;
00150
00155 T* GetValueStorage();
00156
00165 void ReserveStorage(const vtkIdType value_count);
00166
00168
00171 void SetExtentsFromContents();
00172
00173
00174
00175
00176
00177 void SetExtents(const vtkArrayExtents& extents);
00179
00181
00185 inline void AddValue(vtkIdType i, const T& value);
00186 inline void AddValue(vtkIdType i, vtkIdType j, const T& value);
00187 inline void AddValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00188 void AddValue(const vtkArrayCoordinates& coordinates, const T& value);
00190
00197 bool Validate();
00198
00199 protected:
00200 vtkSparseArray();
00201 ~vtkSparseArray();
00202
00203 private:
00204 vtkSparseArray(const vtkSparseArray&);
00205 void operator=(const vtkSparseArray&);
00206
00207 void InternalResize(const vtkArrayExtents& extents);
00208 void InternalSetDimensionLabel(vtkIdType i, const vtkStdString& label);
00209 vtkStdString InternalGetDimensionLabel(vtkIdType i);
00210
00211 typedef vtkSparseArray<T> ThisT;
00212
00214 vtkArrayExtents Extents;
00215
00217 vtkstd::vector<vtkStdString> DimensionLabels;
00218
00222 vtkstd::vector<vtkstd::vector<vtkIdType> > Coordinates;
00223
00225 vtkstd::vector<T> Values;
00226
00229 T NullValue;
00230 };
00231
00232 #include "vtkSparseArray.txx"
00233
00234 #endif
00235