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

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 =========================================================================*/
00059 #ifndef __vtkDataArray_h
00060 #define __vtkDataArray_h
00061 
00062 #include "vtkObject.h"
00063 
00064 class vtkDoubleArray;
00065 class vtkLookupTable;
00066 class vtkIdList;
00067 
00068 #define VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES 11
00069 
00070 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00071 {
00072 public:
00073   vtkTypeRevisionMacro(vtkDataArray,vtkObject);
00074   void PrintSelf(ostream& os, vtkIndent indent);
00075 
00078   virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
00079 
00081   virtual void Initialize() = 0;
00082 
00085   virtual int GetDataType() = 0;
00086 
00088 
00090   virtual int GetDataTypeSize() = 0;
00091   static unsigned long GetDataTypeSize(int type);
00093 
00095 
00097   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00098   int GetNumberOfComponents() {return this->NumberOfComponents;};
00100 
00103   virtual void SetNumberOfTuples(vtkIdType number) = 0;
00104 
00106 
00107   vtkIdType GetNumberOfTuples() 
00108     {return (this->MaxId + 1)/this->NumberOfComponents;}
00110 
00115   virtual double *GetTuple(vtkIdType i) = 0;
00116 
00120   virtual void GetTuple(vtkIdType i, double * tuple) = 0;
00121 
00123 
00126   double GetTuple1(vtkIdType i);
00127   double* GetTuple2(vtkIdType i);
00128   double* GetTuple3(vtkIdType i);
00129   double* GetTuple4(vtkIdType i);
00130   double* GetTuple9(vtkIdType i);
00132 
00136   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00137 
00141   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00142 
00144 
00147   virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
00148   virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
00150 
00152 
00155   void SetTuple1(vtkIdType i, double value);
00156   void SetTuple2(vtkIdType i, double val0, double val1);
00157   void SetTuple3(vtkIdType i, double val0, double val1, double val2);
00158   void SetTuple4(vtkIdType i, double val0, double val1, double val2,
00159                  double val3);
00160   void SetTuple9(vtkIdType i, double val0, double val1, double val2,
00161                  double val3, double val4, double val5, double val6,
00162                  double val7, double val8);
00164 
00166 
00168   virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
00169   virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
00171 
00173 
00176   void InsertTuple1(vtkIdType i, double value);
00177   void InsertTuple2(vtkIdType i, double val0, double val1);
00178   void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
00179   void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
00180                     double val3);
00181   void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
00182                     double val3, double val4, double val5, double val6,
00183                     double val7, double val8);
00185 
00187 
00190   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00191   virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
00193 
00195 
00198   void InsertNextTuple1(double value);
00199   void InsertNextTuple2(double val0, double val1);
00200   void InsertNextTuple3(double val0, double val1, double val2);
00201   void InsertNextTuple4(double val0, double val1, double val2,
00202                         double val3);
00203   void InsertNextTuple9(double val0, double val1, double val2,
00204                         double val3, double val4, double val5, double val6,
00205                         double val7, double val8);
00207 
00211   virtual double GetComponent(vtkIdType i, int j);
00212 
00217   virtual void SetComponent(vtkIdType i, int j, double c);
00218 
00222   virtual void InsertComponent(vtkIdType i, int j, double c);
00223 
00225 
00231   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00232                        int compMax, vtkDoubleArray* data);
00234 
00237   virtual void DeepCopy(vtkDataArray *da);
00238 
00243   virtual void FillComponent(int j, double c);
00244 
00246 
00252   virtual void CopyComponent(int j, vtkDataArray *from,
00253                              int fromComponent);
00255 
00258   virtual void *GetVoidPointer(vtkIdType id) = 0;
00259 
00261   virtual void Squeeze() = 0;
00262 
00264   virtual void Resize(vtkIdType numTuples) = 0;
00265 
00267 
00268   void Reset() 
00269     {this->MaxId = -1;}
00271 
00273 
00274   vtkIdType GetSize() 
00275     {return this->Size;}
00277   
00279 
00280   vtkIdType GetMaxId() 
00281     {return this->MaxId;}
00283 
00285 
00291   virtual void SetVoidArray(void *vtkNotUsed(array),
00292                             vtkIdType vtkNotUsed(size),
00293                             int vtkNotUsed(save)) {};
00295 
00302   unsigned long GetActualMemorySize();
00303   
00306   void CreateDefaultLookupTable();
00307 
00309 
00310   void SetLookupTable(vtkLookupTable *lut);
00311   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00313   
00315 
00316   void SetName(const char* name);
00317   const char* GetName();
00319 
00321 
00325   void GetRange(double range[2], int comp)
00326     {
00327       this->ComputeRange(comp);
00328       memcpy(range, this->Range, 2*sizeof(double));
00329     }
00330   double* GetRange(int comp)
00331     {
00332       this->ComputeRange(comp);
00333       return this->Range;
00334     }
00336 
00337   virtual void ComputeRange(int comp);
00339 
00341   double* GetRange()
00342     {
00343       this->ComputeRange(0);
00344       return this->Range;
00345     }
00346   void GetRange(double range[2])
00347     {
00348       this->GetRange(range,0);
00349     }
00351 
00353 
00356   void GetDataTypeRange(double range[2]);
00357   double GetDataTypeMin();
00358   double GetDataTypeMax();
00360 
00363   virtual double GetMaxNorm();
00364 
00370   static vtkDataArray* CreateDataArray(int dataType);
00371 
00372 protected:
00373   // Construct object with default tuple dimension (number of components) of 1.
00374   vtkDataArray(vtkIdType numComp=1);
00375   ~vtkDataArray();
00376 
00377   vtkLookupTable *LookupTable;
00378 
00379   vtkIdType Size;      // allocated size of data
00380   vtkIdType MaxId;     // maximum index inserted thus far
00381   int NumberOfComponents; // the number of components per tuple
00382 
00383   char* Name;
00384 
00385   double Range[2];
00386 
00387   // We can have arbitrary number of components, but 11 should
00388   // take care of 99.99% of the cases.  Components greater
00389   // than 11 do not get cached.  The comment below assume max of 4 comps.  
00390   // 5 components since you can compute the range of components
00391   // less than 0 to get a magnitude range. ComponentRange[4] is 
00392   // this magnitude range
00393   vtkTimeStamp 
00394      ComponentRangeComputeTime[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES];
00395   double ComponentRange[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES][2];
00396   
00397 private:
00398   double* GetTupleN(vtkIdType i, int n);
00399   
00400 private:
00401   vtkDataArray(const vtkDataArray&);  // Not implemented.
00402   void operator=(const vtkDataArray&);  // Not implemented.
00403 };
00404 
00405 #endif