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     }
00311   // Description:
00312   // Return the range of the array values for the 0th component. 
00313   // Range is copied into the array provided.
00314   double* GetRange()
00315     {
00316     this->ComputeRange(0);
00317     return this->Range;
00318     }
00319   void GetRange(double range[2])
00320     {
00321     this->GetRange(range,0);
00322     }
00323   // Description:
00324   // These methods return the Min and Max possible range of the native
00325   // data type. For example if a vtkScalars consists of unsigned char
00326   // data these will return (0,255). 
00327   void GetDataTypeRange(double range[2]);
00328   double GetDataTypeMin();
00329   double GetDataTypeMax();
00330   static void GetDataTypeRange(int type, double range[2]);
00331   static double GetDataTypeMin(int type);
00332   static double GetDataTypeMax(int type);
00334 
00337   virtual double GetMaxNorm();
00338 
00344   static vtkDataArray* CreateDataArray(int dataType);
00345 
00347 
00357   static vtkInformationInformationVectorKey* PER_COMPONENT();
00358   // Description:
00359   // This key is used to hold tight bounds on the range of
00360   // one component over all tuples of the array.
00361   // Two values (a minimum and maximum) are stored for each component.
00362   // When GetRange() is called when no tuples are present in the array
00363   // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }.
00364   static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
00365   // Description:
00366   // This key is used to hold tight bounds on the $L_2$ norm
00367   // of tuples in the array.
00368   // Two values (a minimum and maximum) are stored for each component.
00369   // When GetRange() is called when no tuples are present in the array
00370   // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }.
00371   static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
00373 
00379   virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
00380 
00381 protected:
00383 
00386   virtual void ComputeRange(int comp);
00387   // Description:
00388   // Slow range computation methods. Reimplement.
00389   virtual void ComputeScalarRange(int comp);
00390   virtual void ComputeVectorRange();
00392 
00393   // Construct object with default tuple dimension (number of components) of 1.
00394   vtkDataArray(vtkIdType numComp=1);
00395   ~vtkDataArray();
00396 
00397   vtkLookupTable *LookupTable;
00398   double Range[2];
00399 
00400 private:
00401   double* GetTupleN(vtkIdType i, int n);
00402   
00403 private:
00404   vtkDataArray(const vtkDataArray&);  // Not implemented.
00405   void operator=(const vtkDataArray&);  // Not implemented.
00406 };
00407 
00408 #endif