Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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 =========================================================================*/
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 #define VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES 11
00057 
00058 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00059 {
00060 public:
00061   vtkTypeRevisionMacro(vtkDataArray,vtkObject);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00066   virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
00067 
00069   virtual void Initialize() = 0;
00070 
00073   virtual int GetDataType() = 0;
00074 
00076 
00078   virtual int GetDataTypeSize() = 0;
00079   static unsigned long GetDataTypeSize(int type);
00081 
00083 
00085   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00086   int GetNumberOfComponents() {return this->NumberOfComponents;};
00088 
00091   virtual void SetNumberOfTuples(vtkIdType number) = 0;
00092 
00094 
00095   vtkIdType GetNumberOfTuples() 
00096     {return (this->MaxId + 1)/this->NumberOfComponents;}
00098 
00103   virtual double *GetTuple(vtkIdType i) = 0;
00104 
00108   virtual void GetTuple(vtkIdType i, double * tuple) = 0;
00109 
00111 
00114   double GetTuple1(vtkIdType i);
00115   double* GetTuple2(vtkIdType i);
00116   double* GetTuple3(vtkIdType i);
00117   double* GetTuple4(vtkIdType i);
00118   double* GetTuple9(vtkIdType i);
00120 
00124   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00125 
00129   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00130 
00132 
00135   virtual void SetTuple(vtkIdType i, const float * tuple) = 0;
00136   virtual void SetTuple(vtkIdType i, const double * tuple) = 0;
00138 
00140 
00143   void SetTuple1(vtkIdType i, double value);
00144   void SetTuple2(vtkIdType i, double val0, double val1);
00145   void SetTuple3(vtkIdType i, double val0, double val1, double val2);
00146   void SetTuple4(vtkIdType i, double val0, double val1, double val2,
00147                  double val3);
00148   void SetTuple9(vtkIdType i, double val0, double val1, double val2,
00149                  double val3, double val4, double val5, double val6,
00150                  double val7, double val8);
00152 
00154 
00156   virtual void InsertTuple(vtkIdType i, const float * tuple) = 0;
00157   virtual void InsertTuple(vtkIdType i, const double * tuple) = 0;
00159 
00161 
00164   void InsertTuple1(vtkIdType i, double value);
00165   void InsertTuple2(vtkIdType i, double val0, double val1);
00166   void InsertTuple3(vtkIdType i, double val0, double val1, double val2);
00167   void InsertTuple4(vtkIdType i, double val0, double val1, double val2,
00168                     double val3);
00169   void InsertTuple9(vtkIdType i, double val0, double val1, double val2,
00170                     double val3, double val4, double val5, double val6,
00171                     double val7, double val8);
00173 
00175 
00178   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00179   virtual vtkIdType InsertNextTuple(const double * tuple) = 0;
00181 
00183 
00186   void InsertNextTuple1(double value);
00187   void InsertNextTuple2(double val0, double val1);
00188   void InsertNextTuple3(double val0, double val1, double val2);
00189   void InsertNextTuple4(double val0, double val1, double val2,
00190                         double val3);
00191   void InsertNextTuple9(double val0, double val1, double val2,
00192                         double val3, double val4, double val5, double val6,
00193                         double val7, double val8);
00195 
00199   virtual double GetComponent(vtkIdType i, int j);
00200 
00205   virtual void SetComponent(vtkIdType i, int j, double c);
00206 
00210   virtual void InsertComponent(vtkIdType i, int j, double c);
00211 
00213 
00219   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00220                        int compMax, vtkDoubleArray* data);
00222 
00225   virtual void DeepCopy(vtkDataArray *da);
00226 
00231   virtual void FillComponent(int j, double c);
00232 
00234 
00240   virtual void CopyComponent(int j, vtkDataArray *from,
00241                              int fromComponent);
00243 
00247   virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0;
00248 
00251   virtual void *GetVoidPointer(vtkIdType id) = 0;
00252 
00254   virtual void Squeeze() = 0;
00255 
00258   virtual int Resize(vtkIdType numTuples) = 0;
00259 
00261 
00262   void Reset() 
00263     {this->MaxId = -1;}
00265 
00267 
00268   vtkIdType GetSize() 
00269     {return this->Size;}
00271   
00273 
00274   vtkIdType GetMaxId() 
00275     {return this->MaxId;}
00277 
00279 
00285   virtual void SetVoidArray(void *vtkNotUsed(array),
00286                             vtkIdType vtkNotUsed(size),
00287                             int vtkNotUsed(save)) {};
00289 
00293   virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
00294 
00301   unsigned long GetActualMemorySize();
00302   
00305   void CreateDefaultLookupTable();
00306 
00308 
00309   void SetLookupTable(vtkLookupTable *lut);
00310   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00312   
00314 
00315   vtkSetStringMacro(Name);
00316   vtkGetStringMacro(Name);
00318 
00320 
00324   void GetRange(double range[2], int comp)
00325     {
00326     this->ComputeRange(comp);
00327     memcpy(range, this->Range, 2*sizeof(double));
00328     }
00329   double* GetRange(int comp)
00330     {
00331     this->ComputeRange(comp);
00332     return this->Range;
00333     }
00335 
00336   virtual void ComputeRange(int comp);
00338 
00340   double* GetRange()
00341     {
00342     this->ComputeRange(0);
00343     return this->Range;
00344     }
00345   void GetRange(double range[2])
00346     {
00347     this->GetRange(range,0);
00348     }
00350 
00352 
00355   void GetDataTypeRange(double range[2]);
00356   double GetDataTypeMin();
00357   double GetDataTypeMax();
00358   static void GetDataTypeRange(int type, double range[2]);
00359   static double GetDataTypeMin(int type);
00360   static double GetDataTypeMax(int type);
00362 
00365   virtual double GetMaxNorm();
00366 
00372   static vtkDataArray* CreateDataArray(int dataType);
00373 
00374 protected:
00375   // Construct object with default tuple dimension (number of components) of 1.
00376   vtkDataArray(vtkIdType numComp=1);
00377   ~vtkDataArray();
00378 
00379   vtkLookupTable *LookupTable;
00380 
00381   vtkIdType Size;      // allocated size of data
00382   vtkIdType MaxId;     // maximum index inserted thus far
00383   int NumberOfComponents; // the number of components per tuple
00384 
00385   char* Name;
00386 
00387   double Range[2];
00388 
00389   // We can have arbitrary number of components, but 11 should
00390   // take care of 99.99% of the cases.  Components greater
00391   // than 11 do not get cached.  The comment below assume max of 4 comps.  
00392   // 5 components since you can compute the range of components
00393   // less than 0 to get a magnitude range. ComponentRange[4] is 
00394   // this magnitude range
00395   vtkTimeStamp 
00396      ComponentRangeComputeTime[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES];
00397   double ComponentRange[VTK_MAXIMUM_NUMBER_OF_CACHED_COMPONENT_RANGES][2];
00398   
00399 private:
00400   double* GetTupleN(vtkIdType i, int n);
00401   
00402 private:
00403   vtkDataArray(const vtkDataArray&);  // Not implemented.
00404   void operator=(const vtkDataArray&);  // Not implemented.
00405 };
00406 
00407 #endif

Generated on Mon Jan 21 23:07:16 2008 for VTK by  doxygen 1.4.3-20050530