VTK
dox/Common/vtkDataArray.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkDataArray.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 =========================================================================*/
00042 #ifndef __vtkDataArray_h
00043 #define __vtkDataArray_h
00044 
00045 #include "vtkAbstractArray.h"
00046 
00047 class vtkDoubleArray;
00048 class vtkIdList;
00049 class vtkInformationDoubleVectorKey;
00050 class vtkInformationInformationVectorKey;
00051 class vtkLookupTable;
00052 
00053 class VTK_COMMON_EXPORT vtkDataArray : public vtkAbstractArray
00054 {
00055 public:
00056   vtkTypeMacro(vtkDataArray,vtkAbstractArray);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00060 
00064   virtual int IsNumeric() 
00065     { return 1; }
00067 
00069 
00071   virtual int GetElementComponentSize() 
00072     { return this->GetDataTypeSize(); }
00074 
00080   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00081 
00086   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00087 
00093   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
00094 
00098   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00099 
00103   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00104 
00105 
00107 
00111   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00112     vtkAbstractArray* source,  double* weights);
00114 
00116 
00121   virtual void InterpolateTuple(vtkIdType i,
00122     vtkIdType id1, vtkAbstractArray* source1,
00123     vtkIdType id2, vtkAbstractArray* source2, double t);
00125 
00130   virtual double *GetTuple(vtkIdType i) = 0;
00131 
00135   virtual void GetTuple(vtkIdType i, double * tuple) = 0;
00136 
00138 
00141   double GetTuple1(vtkIdType i);
00142   double* GetTuple2(vtkIdType i);
00143   double* GetTuple3(vtkIdType i);
00144   double* GetTuple4(vtkIdType i);
00145   double* GetTuple9(vtkIdType i);
00147 
00149 
00152   virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
00153   virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
00155 
00157 
00160   void SetTuple1(vtkIdType i, double value);
00161   void SetTuple2(vtkIdType i, double val0, double val1);
00162   void SetTuple3(vtkIdType i, double val0, double val1, double val2);
00163   void SetTuple4(vtkIdType i, double val0, double val1, double val2,
00164                  double val3);
00165   void SetTuple9(vtkIdType i, double val0, double val1, double val2,
00166                  double val3, double val4, double val5, double val6,
00167                  double val7, double val8);
00169 
00171 
00173   virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
00174   virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
00176 
00178 
00181   void InsertTuple1(vtkIdType i, double value);
00182   void InsertTuple2(vtkIdType i, double val0, double val1);
00183   void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
00184   void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
00185                     double val3);
00186   void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
00187                     double val3, double val4, double val5, double val6,
00188                     double val7, double val8);
00190 
00192 
00195   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00196   virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
00198 
00200 
00203   void InsertNextTuple1(double value);
00204   void InsertNextTuple2(double val0, double val1);
00205   void InsertNextTuple3(double val0, double val1, double val2);
00206   void InsertNextTuple4(double val0, double val1, double val2,
00207                         double val3);
00208   void InsertNextTuple9(double val0, double val1, double val2,
00209                         double val3, double val4, double val5, double val6,
00210                         double val7, double val8);
00212 
00214 
00217   virtual void RemoveTuple(vtkIdType id) = 0;
00218   virtual void RemoveFirstTuple() = 0;
00219   virtual void RemoveLastTuple() = 0;
00221 
00225   virtual double GetComponent(vtkIdType i, int j);
00226 
00231   virtual void SetComponent(vtkIdType i, int j, double c);
00232 
00236   virtual void InsertComponent(vtkIdType i, int j, double c);
00237 
00239 
00245   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00246                        int compMax, vtkDoubleArray* data);
00248 
00250 
00252   virtual void DeepCopy(vtkAbstractArray *aa);
00253   virtual void DeepCopy(vtkDataArray *da);
00255 
00260   virtual void FillComponent(int j, double c);
00261 
00263 
00269   virtual void CopyComponent(int j, vtkDataArray *from,
00270                              int fromComponent);
00272  
00276   virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0;
00277 
00284   virtual unsigned long GetActualMemorySize();
00285 
00288   void CreateDefaultLookupTable();
00289 
00291 
00292   void SetLookupTable(vtkLookupTable *lut);
00293   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00295 
00297 
00301   void GetRange(double range[2], int comp)
00302     {
00303     this->ComputeRange(comp);
00304     memcpy(range, this->Range, 2*sizeof(double));
00305     }
00306   double* GetRange(int comp)
00307     {
00308     this->ComputeRange(comp);
00309     return this->Range;
00310     }
00312 
00313 
00315   double* GetRange()
00316     {
00317     this->ComputeRange(0);
00318     return this->Range;
00319     }
00320   void GetRange(double range[2])
00321     {
00322     this->GetRange(range,0);
00323     }
00325 
00326 
00329   void GetDataTypeRange(double range[2]);
00330   double GetDataTypeMin();
00331   double GetDataTypeMax();
00332   static void GetDataTypeRange(int type, double range[2]);
00333   static double GetDataTypeMin(int type);
00334   static double GetDataTypeMax(int type);
00336 
00339   virtual double GetMaxNorm();
00340 
00346   static vtkDataArray* CreateDataArray(int dataType);
00347 
00358   static vtkInformationInformationVectorKey* PER_COMPONENT();
00364   static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
00369   static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
00370 
00376   virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
00377 
00378 protected:
00382   virtual void ComputeRange(int comp);
00384 
00385   virtual void ComputeScalarRange(int comp);
00386   virtual void ComputeVectorRange();
00388 
00389   // Construct object with default tuple dimension (number of components) of 1.
00390   vtkDataArray(vtkIdType numComp=1);
00391   ~vtkDataArray();
00392 
00393   vtkLookupTable *LookupTable;
00394   double Range[2];
00395 
00396 private:
00397   double* GetTupleN(vtkIdType i, int n);
00398   
00399 private:
00400   vtkDataArray(const vtkDataArray&);  // Not implemented.
00401   void operator=(const vtkDataArray&);  // Not implemented.
00402 };
00403 
00404 #endif