VTK
dox/Common/Core/vtkTypedDataArray.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkTypedDataArray.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00033 #ifndef __vtkTypedDataArray_h
00034 #define __vtkTypedDataArray_h
00035 
00036 #include "vtkDataArray.h"
00037 
00038 #include "vtkCommonCoreModule.h" // For export macro
00039 #include "vtkTypeTemplate.h" // For vtkTypeTemplate
00040 #include "vtkTypeTraits.h"   // For type metadata
00041 
00042 template <class Scalar> class vtkTypedDataArrayIterator;
00043 
00044 template <class Scalar>
00045 class vtkTypedDataArray :
00046     public vtkTypeTemplate<vtkTypedDataArray<Scalar>, vtkDataArray>
00047 {
00048 public:
00050   typedef Scalar ValueType;
00051 
00055   typedef vtkTypedDataArrayIterator<ValueType> Iterator;
00056 
00060   Iterator Begin();
00061 
00065   Iterator End();
00066 
00068   enum { VTK_DATA_TYPE = vtkTypeTraits<ValueType>::VTK_TYPE_ID };
00069 
00076   static vtkTypedDataArray<Scalar>* FastDownCast(vtkAbstractArray *source);
00077 
00079   int GetDataType();
00080 
00082   int GetDataTypeSize();
00083 
00087   virtual void SetNumberOfValues(vtkIdType num);
00088 
00090   virtual void SetTupleValue(vtkIdType i, const ValueType *t) = 0;
00091 
00094   virtual void InsertTupleValue(vtkIdType i, const ValueType *t) = 0;
00095 
00098   virtual vtkIdType InsertNextTupleValue(const ValueType *t) = 0;
00099 
00101 
00102   virtual vtkIdType LookupTypedValue(ValueType value) = 0;
00103   virtual void LookupTypedValue(ValueType value, vtkIdList *ids) = 0;
00105 
00107   virtual ValueType GetValue(vtkIdType idx) = 0;
00108 
00110   virtual ValueType& GetValueReference(vtkIdType idx) = 0;
00111 
00114   virtual void SetValue(vtkIdType idx, ValueType value) = 0;
00115 
00117   virtual void GetTupleValue(vtkIdType idx, ValueType *t) = 0;
00118 
00121   virtual vtkIdType InsertNextValue(ValueType v) = 0;
00122 
00124   virtual void InsertValue(vtkIdType idx, ValueType v) = 0;
00125 
00127   virtual int GetArrayType() { return vtkAbstractArray::TypedDataArray; }
00128 
00129 protected:
00130   vtkTypedDataArray();
00131   ~vtkTypedDataArray();
00132 
00133 private:
00134   vtkTypedDataArray(const vtkTypedDataArray &); // Not implemented.
00135   void operator=(const vtkTypedDataArray &);   // Not implemented.
00136 };
00137 
00138 // Included here to resolve chicken/egg issue with container/iterator:
00139 #include "vtkTypedDataArrayIterator.h" // For iterator
00140 
00141 template <class Scalar> inline
00142 typename vtkTypedDataArray<Scalar>::Iterator vtkTypedDataArray<Scalar>::Begin()
00143 {
00144   return Iterator(this, 0);
00145 }
00146 
00147 template <class Scalar> inline
00148 typename vtkTypedDataArray<Scalar>::Iterator vtkTypedDataArray<Scalar>::End()
00149 {
00150   return Iterator(this, this->MaxId + 1);
00151 }
00152 
00153 #include "vtkTypedDataArray.txx"
00154 
00155 #endif //__vtkTypedDataArray_h
00156 
00157 // VTK-HeaderTest-Exclude: vtkTypedDataArray.h