00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00068 #ifndef __vtkSparseArray_h
00069 #define __vtkSparseArray_h
00070
00071 #include "vtkArrayCoordinates.h"
00072 #include "vtkArraySort.h"
00073 #include "vtkObjectFactory.h"
00074 #include "vtkTypeTemplate.h"
00075 #include "vtkTypedArray.h"
00076
00077 template<typename T>
00078 class vtkSparseArray :
00079 public vtkTypeTemplate<vtkSparseArray<T>, vtkTypedArray<T> >
00080 {
00081 public:
00082 static vtkSparseArray<T>* New();
00083 void PrintSelf(ostream &os, vtkIndent indent);
00084
00085
00086 bool IsDense();
00087 const vtkArrayExtents& GetExtents();
00088 vtkIdType GetNonNullSize();
00089 void GetCoordinatesN(const vtkIdType n, vtkArrayCoordinates& coordinates);
00090 vtkArray* DeepCopy();
00091
00092
00093 const T& GetValue(vtkIdType i);
00094 const T& GetValue(vtkIdType i, vtkIdType j);
00095 const T& GetValue(vtkIdType i, vtkIdType j, vtkIdType k);
00096 const T& GetValue(const vtkArrayCoordinates& coordinates);
00097 const T& GetValueN(const vtkIdType n);
00098 void SetValue(vtkIdType i, const T& value);
00099 void SetValue(vtkIdType i, vtkIdType j, const T& value);
00100 void SetValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00101 void SetValue(const vtkArrayCoordinates& coordinates, const T& value);
00102 void SetValueN(const vtkIdType n, const T& value);
00103
00104
00105
00108 void SetNullValue(const T& value);
00109
00112 const T& GetNullValue();
00113
00117 void Clear();
00118
00124 void Sort(const vtkArraySort& sort);
00125
00127 vtkstd::vector<vtkIdType> GetUniqueCoordinates(vtkIdType dimension);
00128
00133 const vtkIdType* GetCoordinateStorage(vtkIdType dimension) const;
00134
00140 vtkIdType* GetCoordinateStorage(vtkIdType dimension);
00141
00146 const T* GetValueStorage() const;
00147
00152 T* GetValueStorage();
00153
00162 void ReserveStorage(const vtkIdType value_count);
00163
00165
00168 void SetExtentsFromContents();
00169
00170
00171
00172
00173
00174 void SetExtents(const vtkArrayExtents& extents);
00176
00178
00182 inline void AddValue(vtkIdType i, const T& value);
00183 inline void AddValue(vtkIdType i, vtkIdType j, const T& value);
00184 inline void AddValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00185 void AddValue(const vtkArrayCoordinates& coordinates, const T& value);
00187
00194 bool Validate();
00195
00196 protected:
00197 vtkSparseArray();
00198 ~vtkSparseArray();
00199
00200 private:
00201 vtkSparseArray(const vtkSparseArray&);
00202 void operator=(const vtkSparseArray&);
00203
00204 void InternalResize(const vtkArrayExtents& extents);
00205 void InternalSetDimensionLabel(vtkIdType i, const vtkStdString& label);
00206 vtkStdString InternalGetDimensionLabel(vtkIdType i);
00207
00208 typedef vtkSparseArray<T> ThisT;
00209
00211 vtkArrayExtents Extents;
00212
00214 vtkstd::vector<vtkStdString> DimensionLabels;
00215
00219 vtkstd::vector<vtkstd::vector<vtkIdType> > Coordinates;
00220
00222 vtkstd::vector<T> Values;
00223
00226 T NullValue;
00227 };
00228
00229 #include "vtkSparseArray.txx"
00230
00231 #endif
00232