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

dox/Common/vtkDataArrayTemplate.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataArrayTemplate.h,v $
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 =========================================================================*/
00023 #ifndef __vtkDataArrayTemplate_h
00024 #define __vtkDataArrayTemplate_h
00025 
00026 #include "vtkDataArray.h"
00027 
00028 template <class T>
00029 class vtkDataArrayTemplateLookup;
00030 
00031 template <class T>
00032 class vtkDataArrayTemplate: public vtkDataArray
00033 {
00034 public:
00035   typedef vtkDataArray Superclass;
00036   void PrintSelf(ostream& os, vtkIndent indent);
00037 
00040   int Allocate(vtkIdType sz, vtkIdType ext=1000);
00041 
00043   void Initialize();
00044 
00046   int GetDataTypeSize() { return static_cast<int>(sizeof(T)); }
00047 
00049   void SetNumberOfTuples(vtkIdType number);
00050 
00056   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00057 
00061   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00062 
00066   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00067   
00070   double* GetTuple(vtkIdType i);
00071 
00073 
00074   void GetTuple(vtkIdType i, double* tuple);
00075   void GetTupleValue(vtkIdType i, T* tuple);
00077 
00079 
00080   void SetTuple(vtkIdType i, const float* tuple);
00081   void SetTuple(vtkIdType i, const double* tuple);
00082   void SetTupleValue(vtkIdType i, const T* tuple);
00084 
00086 
00088   void InsertTuple(vtkIdType i, const float* tuple);
00089   void InsertTuple(vtkIdType i, const double* tuple);
00090   void InsertTupleValue(vtkIdType i, const T* tuple);
00092 
00094 
00096   vtkIdType InsertNextTuple(const float* tuple);
00097   vtkIdType InsertNextTuple(const double* tuple);
00098   vtkIdType InsertNextTupleValue(const T* tuple);
00100 
00102   void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
00103 
00105   vtkIdType Capacity() { return this->Size; }
00106 
00108   virtual int Resize(vtkIdType numTuples);
00109 
00111   T GetValue(vtkIdType id) { return this->Array[id]; }
00112 
00114 
00116   void SetValue(vtkIdType id, T value)
00117     { this->Array[id] = value;};
00119 
00123   void SetNumberOfValues(vtkIdType number);
00124 
00126   void InsertValue(vtkIdType id, T f);
00127 
00129   void InsertVariantValue(vtkIdType id, vtkVariant value);
00130 
00133   vtkIdType InsertNextValue(T f);
00134 
00136 
00139   virtual void RemoveTuple(vtkIdType id);
00140   virtual void RemoveFirstTuple();
00141   virtual void RemoveLastTuple();
00143 
00147   double GetComponent(vtkIdType i, int j);
00148 
00153   void SetComponent(vtkIdType i, int j, double c);
00154 
00158   virtual void InsertComponent(vtkIdType i, int j, double c);
00159 
00161 
00164   T* WritePointer(vtkIdType id, vtkIdType number);
00165   virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number)
00166     { return this->WritePointer(id, number); }
00168 
00170 
00172   T* GetPointer(vtkIdType id) { return this->Array + id; }
00173   virtual void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00175 
00177 
00178   void DeepCopy(vtkDataArray* da);
00179   void DeepCopy(vtkAbstractArray* aa)
00180     { this->Superclass::DeepCopy(aa); }
00182 
00183 //BTX
00184   enum DeleteMethod
00185   {
00186     VTK_DATA_ARRAY_FREE,
00187     VTK_DATA_ARRAY_DELETE
00188   };
00189 //ETX
00190 
00192 
00201   void SetArray(T* array, vtkIdType size, int save, int deleteMethod);
00202   void SetArray(T* array, vtkIdType size, int save)
00203     { this->SetArray(array, size, save, VTK_DATA_ARRAY_FREE); }
00204   virtual void SetVoidArray(void* array, vtkIdType size, int save)
00205     { this->SetArray(static_cast<T*>(array), size, save); }
00206   virtual void SetVoidArray(void* array, 
00207                             vtkIdType size, 
00208                             int save, 
00209                             int deleteMethod)
00210     { 
00211       this->SetArray(static_cast<T*>(array), size, save, deleteMethod); 
00212     }
00214 
00218   virtual void ExportToVoidPointer(void *out_ptr);
00219 
00221   virtual vtkArrayIterator* NewIterator();
00222   
00223   //BTX
00225 
00226   virtual vtkIdType LookupValue(vtkVariant value);
00227   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00228   //ETX
00229   vtkIdType LookupValue(T value);
00230   void LookupValue(T value, vtkIdList* ids);
00232   
00239   virtual void DataChanged();
00240   
00244   virtual void DataElementChanged(vtkIdType id);
00245 
00249   virtual void ClearLookup();
00250   
00251 protected:
00252   vtkDataArrayTemplate(vtkIdType numComp);
00253   ~vtkDataArrayTemplate();
00254 
00255   T* Array;   // pointer to data
00256   T* ResizeAndExtend(vtkIdType sz);  // function to resize data
00257   T* Realloc(vtkIdType sz);
00258   
00259   int TupleSize; //used for data conversion
00260   double* Tuple;
00261 
00262   int SaveUserArray;
00263   int DeleteMethod;
00264 
00265   virtual void ComputeScalarRange(int comp);
00266   virtual void ComputeVectorRange();
00267 private:
00268   vtkDataArrayTemplate(const vtkDataArrayTemplate&);  // Not implemented.
00269   void operator=(const vtkDataArrayTemplate&);  // Not implemented.
00270 
00271   vtkDataArrayTemplateLookup<T>* Lookup;
00272   void UpdateLookup();
00273 
00274   void DeleteArray();
00275 };
00276 
00277 #if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
00278 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
00279    template class VTK_COMMON_EXPORT vtkDataArrayTemplate< T >
00280 #else
00281 # include "vtkDataArrayTemplateImplicit.txx"
00282 # define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
00283 #endif
00284 
00285 #endif // !defined(__vtkDataArrayTemplate_h)
00286 
00287 // This portion must be OUTSIDE the include blockers.  Each
00288 // vtkDataArray subclass uses this to give its instantiation of this
00289 // template a DLL interface.
00290 #if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
00291 # if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
00292 #  pragma warning (push)
00293 #  pragma warning (disable: 4091) // warning C4091: 'extern ' : 
00294    // ignored on left of 'int' when no variable is declared
00295 #  pragma warning (disable: 4231) // Compiler-specific extension warning.
00296 
00297    // We need to disable warning 4910 and do an extern dllexport
00298    // anyway.  When deriving vtkCharArray and other types from an
00299    // instantiation of this template the compiler does an explicit
00300    // instantiation of the base class.  From outside the vtkCommon
00301    // library we block this using an extern dllimport instantiation.
00302    // For classes inside vtkCommon we should be able to just do an
00303    // extern instantiation, but VS 2008 complains about missing
00304    // definitions.  We cannot do an extern dllimport inside vtkCommon
00305    // since the symbols are local to the dll.  An extern dllexport
00306    // seems to be the only way to convince VS 2008 to do the right
00307    // thing, so we just disable the warning.
00308 #  pragma warning (disable: 4910) // extern and dllexport incompatible
00309 
00310    // Use an "extern explicit instantiation" to give the class a DLL
00311    // interface.  This is a compiler-specific extension.
00312    extern VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
00313 #  pragma warning (pop)
00314 # endif
00315 # undef VTK_DATA_ARRAY_TEMPLATE_TYPE
00316 #endif

Generated by  doxygen 1.7.1