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 typedef typename vtkArray::CoordinateT CoordinateT;
00089 typedef typename vtkArray::DimensionT DimensionT;
00090 typedef typename vtkArray::SizeT SizeT;
00091
00092
00093 bool IsDense();
00094 const vtkArrayExtents& GetExtents();
00095 SizeT GetNonNullSize();
00096 void GetCoordinatesN(const SizeT n, vtkArrayCoordinates& coordinates);
00097 vtkArray* DeepCopy();
00098
00099
00100 const T& GetValue(CoordinateT i);
00101 const T& GetValue(CoordinateT i, CoordinateT j);
00102 const T& GetValue(CoordinateT i, CoordinateT j, CoordinateT k);
00103 const T& GetValue(const vtkArrayCoordinates& coordinates);
00104 const T& GetValueN(const SizeT n);
00105 void SetValue(CoordinateT i, const T& value);
00106 void SetValue(CoordinateT i, CoordinateT j, const T& value);
00107 void SetValue(CoordinateT i, CoordinateT j, CoordinateT k, const T& value);
00108 void SetValue(const vtkArrayCoordinates& coordinates, const T& value);
00109 void SetValueN(const SizeT n, const T& value);
00110
00111
00112
00115 void SetNullValue(const T& value);
00116
00119 const T& GetNullValue();
00120
00124 void Clear();
00125
00131 void Sort(const vtkArraySort& sort);
00132
00134 vtkstd::vector<CoordinateT> GetUniqueCoordinates(DimensionT dimension);
00135
00140 const CoordinateT* GetCoordinateStorage(DimensionT dimension) const;
00141
00147 CoordinateT* GetCoordinateStorage(DimensionT dimension);
00148
00153 const T* GetValueStorage() const;
00154
00159 T* GetValueStorage();
00160
00169 void ReserveStorage(const SizeT value_count);
00170
00172
00175 void SetExtentsFromContents();
00176
00177
00178
00179
00180
00181 void SetExtents(const vtkArrayExtents& extents);
00183
00185
00189 inline void AddValue(CoordinateT i, const T& value);
00190 inline void AddValue(CoordinateT i, CoordinateT j, const T& value);
00191 inline void AddValue(CoordinateT i, CoordinateT j, CoordinateT k, const T& value);
00192 void AddValue(const vtkArrayCoordinates& coordinates, const T& value);
00194
00201 bool Validate();
00202
00203 protected:
00204 vtkSparseArray();
00205 ~vtkSparseArray();
00206
00207 private:
00208 vtkSparseArray(const vtkSparseArray&);
00209 void operator=(const vtkSparseArray&);
00210
00211 void InternalResize(const vtkArrayExtents& extents);
00212 void InternalSetDimensionLabel(DimensionT i, const vtkStdString& label);
00213 vtkStdString InternalGetDimensionLabel(DimensionT i);
00214
00215 typedef vtkSparseArray<T> ThisT;
00216
00218 vtkArrayExtents Extents;
00219
00221 vtkstd::vector<vtkStdString> DimensionLabels;
00222
00226 vtkstd::vector<vtkstd::vector<CoordinateT> > Coordinates;
00227
00229 vtkstd::vector<T> Values;
00230
00232
00234 T NullValue;
00235 };
00237
00238 #include "vtkSparseArray.txx"
00239
00240 #endif