Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Common/vtkDataArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkDataArray.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 =========================================================================*/
00047 #ifndef __vtkDataArray_h
00048 #define __vtkDataArray_h
00049 
00050 #include "vtkObject.h"
00051 
00052 class vtkDoubleArray;
00053 class vtkLookupTable;
00054 class vtkIdList;
00055 
00056 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00057 {
00058 public:
00059   vtkTypeRevisionMacro(vtkDataArray,vtkObject);
00060   void PrintSelf(ostream& os, vtkIndent indent);
00061 
00063 
00065   virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
00066   virtual void Initialize() = 0;
00068 
00071   virtual int GetDataType() = 0;
00072 
00075   virtual int GetDataTypeSize() = 0;
00076 
00078 
00080   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00081   int GetNumberOfComponents() {return this->NumberOfComponents;};
00083 
00086   virtual void SetNumberOfTuples(vtkIdType number) = 0;
00087 
00089 
00090   vtkIdType GetNumberOfTuples() 
00091     {return (this->MaxId + 1)/this->NumberOfComponents;}
00093 
00098   virtual double *GetTuple(vtkIdType i) = 0;
00099 
00103   virtual void GetTuple(vtkIdType i, double * tuple) = 0;
00104 
00106 
00109   double GetTuple1(vtkIdType i);
00110   double* GetTuple2(vtkIdType i);
00111   double* GetTuple3(vtkIdType i);
00112   double* GetTuple4(vtkIdType i);
00113   double* GetTuple9(vtkIdType i);
00115 
00119   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00120 
00124   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00125 
00127 
00130   virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
00131   virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
00133 
00135 
00138   void SetTuple1(vtkIdType i, double value);
00139   void SetTuple2(vtkIdType i, double val0, double val1);
00140   void SetTuple3(vtkIdType i, double val0, double val1, double val2);
00141   void SetTuple4(vtkIdType i, double val0, double val1, double val2,
00142                  double val3);
00143   void SetTuple9(vtkIdType i, double val0, double val1, double val2,
00144                  double val3, double val4, double val5, double val6,
00145                  double val7, double val8);
00147 
00149 
00151   virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
00152   virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
00154 
00156 
00159   void InsertTuple1(vtkIdType i, double value);
00160   void InsertTuple2(vtkIdType i, double val0, double val1);
00161   void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
00162   void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
00163                     double val3);
00164   void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
00165                     double val3, double val4, double val5, double val6,
00166                     double val7, double val8);
00168 
00170 
00173   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00174   virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
00176 
00178 
00181   void InsertNextTuple1(double value);
00182   void InsertNextTuple2(double val0, double val1);
00183   void InsertNextTuple3(double val0, double val1, double val2);
00184   void InsertNextTuple4(double val0, double val1, double val2,
00185                         double val3);
00186   void InsertNextTuple9(double val0, double val1, double val2,
00187                         double val3, double val4, double val5, double val6,
00188                         double val7, double val8);
00190 
00194   virtual double GetComponent(vtkIdType i, int j);
00195 
00200   virtual void SetComponent(vtkIdType i, int j, double c);
00201 
00205   virtual void InsertComponent(vtkIdType i, int j, double c);
00206 
00208 
00214   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00215                        int compMax, vtkDoubleArray* data);
00217 
00220   virtual void DeepCopy(vtkDataArray *da);
00221 
00226   virtual void FillComponent(int j, double c);
00227 
00229 
00235   virtual void CopyComponent(int j, vtkDataArray *from,
00236                              int fromComponent);
00238 
00241   virtual void *GetVoidPointer(vtkIdType id) = 0;
00242 
00244   virtual void Squeeze() = 0;
00245 
00247   virtual void Resize(vtkIdType numTuples) = 0;
00248 
00250 
00251   void Reset() 
00252     {this->MaxId = -1;}
00254 
00256 
00257   vtkIdType GetSize() 
00258     {return this->Size;}
00260   
00262 
00263   vtkIdType GetMaxId() 
00264     {return this->MaxId;}
00266 
00268 
00274   virtual void SetVoidArray(void *vtkNotUsed(array),
00275                             vtkIdType vtkNotUsed(size),
00276                             int vtkNotUsed(save)) {};
00278 
00285   unsigned long GetActualMemorySize();
00286   
00289   void CreateDefaultLookupTable();
00290 
00292 
00293   void SetLookupTable(vtkLookupTable *lut);
00294   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00296   
00298 
00299   void SetName(const char* name);
00300   const char* GetName();
00302 
00304 
00306   void GetRange(double range[2], int comp)
00307     {
00308       this->ComputeRange(comp);
00309       memcpy(range, this->Range, 2*sizeof(double));
00310     }
00311   double* GetRange(int comp)
00312     {
00313       this->ComputeRange(comp);
00314       return this->Range;
00315     }
00317 
00318   virtual void ComputeRange(int comp);
00320 
00322   double* GetRange()
00323     {
00324       this->ComputeRange(0);
00325       return this->Range;
00326     }
00327   void GetRange(double range[2])
00328     {
00329       this->GetRange(range,0);
00330     }
00332 
00334 
00337   void GetDataTypeRange(double range[2]);
00338   double GetDataTypeMin();
00339   double GetDataTypeMax();
00341 
00344   virtual double GetMaxNorm();
00345 
00351   static vtkDataArray* CreateDataArray(int dataType);
00352 
00353 protected:
00354   // Construct object with default tuple dimension (number of components) of 1.
00355   vtkDataArray(vtkIdType numComp=1);
00356   ~vtkDataArray();
00357 
00358   vtkLookupTable *LookupTable;
00359 
00360   vtkIdType Size;      // allocated size of data
00361   vtkIdType MaxId;     // maximum index inserted thus far
00362   int NumberOfComponents; // the number of components per tuple
00363 
00364   char* Name;
00365 
00366 private:
00367   double Range[2];
00368 
00369   // 5 components since you can compute the range of components
00370   // less than 0 to get a magnitude range. ComponentRange[4] is 
00371   // this magnitude range
00372   vtkTimeStamp ComponentRangeComputeTime[5];
00373   double ComponentRange[5][2];
00374   
00375   double* GetTupleN(vtkIdType i, int n);
00376   
00377 private:
00378   vtkDataArray(const vtkDataArray&);  // Not implemented.
00379   void operator=(const vtkDataArray&);  // Not implemented.
00380 };
00381 
00382 #endif