• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Common/vtkSparseArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSparseArray.h,v $
00005   
00006 -------------------------------------------------------------------------
00007   Copyright 2008 Sandia Corporation.
00008   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009   the U.S. Government retains certain rights in this software.
00010 -------------------------------------------------------------------------
00011 
00012   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00013   All rights reserved.
00014   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00015 
00016      This software is distributed WITHOUT ANY WARRANTY; without even
00017      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00018      PURPOSE.  See the above copyright notice for more information.
00019 
00020 =========================================================================*/
00021 
00056 #ifndef __vtkSparseArray_h
00057 #define __vtkSparseArray_h
00058 
00059 #include "vtkArrayCoordinates.h"
00060 #include "vtkObjectFactory.h"
00061 #include "vtkTypeTemplate.h"
00062 #include "vtkTypedArray.h"
00063 
00064 template<typename T>
00065 class vtkSparseArray :
00066   public vtkTypeTemplate<vtkSparseArray<T>, vtkTypedArray<T> >
00067 {
00068 public:
00069   using vtkTypedArray<T>::GetValue;
00070   using vtkTypedArray<T>::SetValue;
00071 
00072   static vtkSparseArray<T>* New();
00073   void PrintSelf(ostream &os, vtkIndent indent);
00074 
00075   // vtkArray API 
00076   vtkArrayExtents GetExtents();
00077   vtkIdType GetNonNullSize();
00078   void GetCoordinatesN(const vtkIdType n, vtkArrayCoordinates& coordinates);
00079   vtkArray* DeepCopy();
00080     
00081   // vtkTypedArray API
00082   const T& GetValue(const vtkArrayCoordinates& coordinates);
00083   const T& GetValueN(const vtkIdType n);
00084   void SetValue(const vtkArrayCoordinates& coordinates, const T& value);
00085   void SetValueN(const vtkIdType n, const T& value);
00086 
00087   // vtkSparseArray API
00088 
00091   void SetNullValue(const T& value);
00092 
00095   const T& GetNullValue();
00096 
00100   void Clear();
00101 
00106   const vtkIdType* GetCoordinateStorage() const;
00107   
00112   vtkIdType* GetCoordinateStorage();
00113   
00118   const T* GetValueStorage() const;
00119   
00124   T* GetValueStorage();
00125   
00134   void ReserveStorage(const vtkIdType value_count);
00135 
00139   void ResizeToContents();
00140   
00142 
00146   inline void AddValue(vtkIdType i, const T& value);
00147   inline void AddValue(vtkIdType i, vtkIdType j, const T& value);
00148   inline void AddValue(vtkIdType i, vtkIdType j, vtkIdType k, const T& value);
00149   void AddValue(const vtkArrayCoordinates& coordinates, const T& value);
00151 
00152 protected:
00153   vtkSparseArray();
00154   ~vtkSparseArray();
00155 
00156 private:
00157   vtkSparseArray(const vtkSparseArray&); // Not implemented
00158   void operator=(const vtkSparseArray&); // Not implemented
00159 
00160   void InternalResize(const vtkArrayExtents& extents);
00161   void InternalSetDimensionLabel(vtkIdType i, const vtkStdString& label);
00162   vtkStdString InternalGetDimensionLabel(vtkIdType i);
00163 
00164   typedef vtkSparseArray<T> ThisT;
00165 
00167   vtkArrayExtents Extents;
00168   
00170   vtkstd::vector<vtkStdString> DimensionLabels;
00171   
00174   vtkstd::vector<vtkIdType> Coordinates;
00175   
00177   vtkstd::vector<T> Values;
00178 
00181   T NullValue;
00182 };
00183 
00184 #include "vtkSparseArray.txx"
00185 
00186 #endif
00187 

Generated by  doxygen 1.7.1