VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/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 "vtkCommonCoreModule.h" // For export macro
00046 #include "vtkAbstractArray.h"
00047 
00048 class vtkDoubleArray;
00049 class vtkIdList;
00050 class vtkInformationDoubleVectorKey;
00051 class vtkLookupTable;
00052 
00053 class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray
00054 {
00055 public:
00056   vtkTypeMacro(vtkDataArray,vtkAbstractArray);
00057   void PrintSelf(ostream& os, vtkIndent indent);
00058 
00064   static vtkDataArray* FastDownCast(vtkAbstractArray *source);
00065 
00067 
00071   virtual int IsNumeric()
00072     { return 1; }
00074 
00076 
00078   virtual int GetElementComponentSize()
00079     { return this->GetDataTypeSize(); }
00081 
00087   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00088 
00093   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00094 
00100   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
00101 
00105   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00106 
00110   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00111 
00112 
00114 
00118   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00119     vtkAbstractArray* source,  double* weights);
00121 
00123 
00128   virtual void InterpolateTuple(vtkIdType i,
00129     vtkIdType id1, vtkAbstractArray* source1,
00130     vtkIdType id2, vtkAbstractArray* source2, double t);
00132 
00137   virtual double *GetTuple(vtkIdType i) = 0;
00138 
00142   virtual void GetTuple(vtkIdType i, double * tuple) = 0;
00143 
00145 
00148   double GetTuple1(vtkIdType i);
00149   double* GetTuple2(vtkIdType i);
00150   double* GetTuple3(vtkIdType i);
00151   double* GetTuple4(vtkIdType i);
00152   double* GetTuple6(vtkIdType i);
00153   double* GetTuple9(vtkIdType i);
00155 
00157 
00160   virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
00161   virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
00163 
00165 
00168   void SetTuple1(vtkIdType i, double value);
00169   void SetTuple2(vtkIdType i, double val0, double val1);
00170   void SetTuple3(vtkIdType i, double val0, double val1, double val2);
00171   void SetTuple4(vtkIdType i, double val0, double val1, double val2,
00172                  double val3);
00173   void SetTuple6(vtkIdType i, double val0, double val1, double val2,
00174                  double val3, double val4, double val5);
00175   void SetTuple9(vtkIdType i, double val0, double val1, double val2,
00176                  double val3, double val4, double val5, double val6,
00177                  double val7, double val8);
00179 
00181 
00183   virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
00184   virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
00186 
00188 
00191   void InsertTuple1(vtkIdType i, double value);
00192   void InsertTuple2(vtkIdType i, double val0, double val1);
00193   void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
00194   void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
00195                     double val3);
00196   void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
00197                     double val3, double val4, double val5, double val6,
00198                     double val7, double val8);
00200 
00202 
00205   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00206   virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
00208 
00210 
00213   void InsertNextTuple1(double value);
00214   void InsertNextTuple2(double val0, double val1);
00215   void InsertNextTuple3(double val0, double val1, double val2);
00216   void InsertNextTuple4(double val0, double val1, double val2,
00217                         double val3);
00218   void InsertNextTuple9(double val0, double val1, double val2,
00219                         double val3, double val4, double val5, double val6,
00220                         double val7, double val8);
00222 
00224 
00227   virtual void RemoveTuple(vtkIdType id) = 0;
00228   virtual void RemoveFirstTuple() = 0;
00229   virtual void RemoveLastTuple() = 0;
00231 
00235   virtual double GetComponent(vtkIdType i, int j);
00236 
00241   virtual void SetComponent(vtkIdType i, int j, double c);
00242 
00246   virtual void InsertComponent(vtkIdType i, int j, double c);
00247 
00249 
00255   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00256                        int compMax, vtkDoubleArray* data);
00258 
00260 
00262   virtual void DeepCopy(vtkAbstractArray *aa);
00263   virtual void DeepCopy(vtkDataArray *da);
00265 
00270   virtual void FillComponent(int j, double c);
00271 
00273 
00279   virtual void CopyComponent(int j, vtkDataArray *from,
00280                              int fromComponent);
00282 
00286   virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0;
00287 
00294   virtual unsigned long GetActualMemorySize();
00295 
00298   void CreateDefaultLookupTable();
00299 
00301 
00302   void SetLookupTable(vtkLookupTable *lut);
00303   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00305 
00307 
00314   void GetRange(double range[2], int comp)
00315     {
00316     this->ComputeRange(range, comp);
00317     }
00319 
00321 
00327   double* GetRange(int comp)
00328     {
00329     this->GetRange(this->Range, comp);
00330     return this->Range;
00331     }
00333 
00335 
00340   double* GetRange()
00341     {
00342     return this->GetRange(0);
00343     }
00345 
00347 
00353   void GetRange(double range[2])
00354     {
00355     this->GetRange(range,0);
00356     }
00358 
00360 
00363   void GetDataTypeRange(double range[2]);
00364   double GetDataTypeMin();
00365   double GetDataTypeMax();
00366   static void GetDataTypeRange(int type, double range[2]);
00367   static double GetDataTypeMin(int type);
00368   static double GetDataTypeMax(int type);
00370 
00373   virtual double GetMaxNorm();
00374 
00380   static vtkDataArray* CreateDataArray(int dataType);
00381 
00387   static vtkInformationDoubleVectorKey* COMPONENT_RANGE();
00392   static vtkInformationDoubleVectorKey* L2_NORM_RANGE();
00393 
00399   virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
00400 
00402   virtual int GetArrayType() { return DataArray; }
00403 
00404 protected:
00409   virtual void ComputeRange(double range[2], int comp);
00410 
00415   virtual bool ComputeScalarRange(double* ranges);
00416 
00417   // Returns true if the range was computed. Will return false
00418   // if you try to compute the range of an array of length zero.
00419   virtual bool ComputeVectorRange(double range[2]);
00420 
00421   // Construct object with default tuple dimension (number of components) of 1.
00422   vtkDataArray();
00423   ~vtkDataArray();
00424 
00425   vtkLookupTable *LookupTable;
00426   double Range[2];
00427 
00428 private:
00429   double* GetTupleN(vtkIdType i, int n);
00430 
00431 private:
00432   vtkDataArray(const vtkDataArray&);  // Not implemented.
00433   void operator=(const vtkDataArray&);  // Not implemented.
00434 };
00435 
00436 //------------------------------------------------------------------------------
00437 inline vtkDataArray* vtkDataArray::FastDownCast(vtkAbstractArray *source)
00438 {
00439   switch (source->GetArrayType())
00440     {
00441     case DataArrayTemplate:
00442     case TypedDataArray:
00443     case DataArray:
00444     case MappedDataArray:
00445       return static_cast<vtkDataArray*>(source);
00446     default:
00447       return NULL;
00448     }
00449 }
00450 
00451 #endif