Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound 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   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00062 #ifndef __vtkDataArray_h
00063 #define __vtkDataArray_h
00064 
00065 #include "vtkObject.h"
00066 
00067 class vtkFloatArray;
00068 class vtkLookupTable;
00069 class vtkIdList;
00070 
00071 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00072 {
00073 public:
00074   vtkTypeRevisionMacro(vtkDataArray,vtkObject);
00075   void PrintSelf(ostream& os, vtkIndent indent);
00076 
00078 
00080   virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000) = 0;
00081   virtual void Initialize() = 0;
00083 
00084 #ifndef VTK_REMOVE_LEGACY_CODE
00085 
00086   virtual vtkDataArray* MakeObject();
00087 #endif
00088 
00091   virtual int GetDataType() = 0;
00092 
00095   virtual int GetDataTypeSize() = 0;
00096 
00098 
00100   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00101   int GetNumberOfComponents() {return this->NumberOfComponents;};
00103 
00106   virtual void SetNumberOfTuples(const vtkIdType number) = 0;
00107 
00109 
00110   vtkIdType GetNumberOfTuples() 
00111     {return (this->MaxId + 1)/this->NumberOfComponents;}
00113 
00118   virtual float *GetTuple(const vtkIdType i) = 0;
00119 
00121 
00124   virtual void GetTuple(const vtkIdType i, float * tuple) = 0;
00125   virtual void GetTuple(const vtkIdType i, double * tuple);
00127 
00129 
00132   float GetTuple1(const vtkIdType i);
00133   float* GetTuple2(const vtkIdType i);
00134   float* GetTuple3(const vtkIdType i);
00135   float* GetTuple4(const vtkIdType i);
00136   float* GetTuple9(const vtkIdType i);
00138 
00142   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00143 
00147   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00148 
00150 
00153   virtual void SetTuple(const vtkIdType i, const float * tuple) = 0;
00154   virtual void SetTuple(const vtkIdType i, const double * tuple);
00156 
00158 
00161   void SetTuple1(const vtkIdType i, float value);
00162   void SetTuple2(const vtkIdType i, float val0, float val1);
00163   void SetTuple3(const vtkIdType i, float val0, float val1, float val2);
00164   void SetTuple4(const vtkIdType i, float val0, float val1, float val2,
00165                  float val3);
00166   void SetTuple9(const vtkIdType i, float val0, float val1, float val2,
00167                  float val3, float val4, float val5, float val6,
00168                  float val7, float val8);
00170 
00172 
00174   virtual void InsertTuple(const vtkIdType i, const float * tuple) = 0;
00175   virtual void InsertTuple(const vtkIdType i, const double * tuple);
00177 
00179 
00182   void InsertTuple1(const vtkIdType i, float value);
00183   void InsertTuple2(const vtkIdType i, float val0, float val1);
00184   void InsertTuple3(const vtkIdType i, float val0, float val1, float val2);
00185   void InsertTuple4(const vtkIdType i, float val0, float val1, float val2,
00186                     float val3);
00187   void InsertTuple9(const vtkIdType i, float val0, float val1, float val2,
00188                     float val3, float val4, float val5, float val6,
00189                     float val7, float val8);
00191 
00193 
00196   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00197   virtual vtkIdType InsertNextTuple(const double * tuple);
00199 
00201 
00204   void InsertNextTuple1(float value);
00205   void InsertNextTuple2(float val0, float val1);
00206   void InsertNextTuple3(float val0, float val1, float val2);
00207   void InsertNextTuple4(float val0, float val1, float val2,
00208                         float val3);
00209   void InsertNextTuple9(float val0, float val1, float val2,
00210                         float val3, float val4, float val5, float val6,
00211                         float val7, float val8);
00213 
00217   virtual float GetComponent(const vtkIdType i, const int j);
00218 
00223   virtual void SetComponent(const vtkIdType i, const int j, float c);
00224 
00228   virtual void InsertComponent(const vtkIdType i, const int j, float c);
00229 
00231 
00237   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00238                        int compMax, vtkFloatArray* data);
00240 
00243   virtual void DeepCopy(vtkDataArray *da);
00244 
00249   virtual void FillComponent(const int j, const float c);
00250 
00252 
00258   virtual void CopyComponent(const int j, vtkDataArray *from,
00259                              const int fromComponent);
00261 
00264   virtual void *GetVoidPointer(const vtkIdType id) = 0;
00265 
00267   virtual void Squeeze() = 0;
00268 
00270   virtual void Resize(vtkIdType numTuples) = 0;
00271 
00273 
00274   void Reset() 
00275     {this->MaxId = -1;}
00277 
00279 
00280   vtkIdType GetSize() 
00281     {return this->Size;}
00283   
00285 
00286   vtkIdType GetMaxId() 
00287     {return this->MaxId;}
00289 
00291 
00297   virtual void SetVoidArray(void *vtkNotUsed(array),
00298                             vtkIdType vtkNotUsed(size),
00299                             int vtkNotUsed(save)) {};
00301 
00308   unsigned long GetActualMemorySize();
00309   
00312   void CreateDefaultLookupTable();
00313 
00315 
00316   void SetLookupTable(vtkLookupTable *lut);
00317   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00319   
00321 
00322   void SetName(const char* name);
00323   const char* GetName();
00325 
00327 
00329   void GetRange(float range[2], int comp)
00330     {
00331       this->ComputeRange(comp);
00332       memcpy(range, this->Range, 2*sizeof(float));
00333     }
00334   float* GetRange(int comp)
00335     {
00336       this->ComputeRange(comp);
00337       return this->Range;
00338     }
00340 
00341   virtual void ComputeRange(int comp);
00343 
00345   float* GetRange()
00346     {
00347       this->ComputeRange(0);
00348       return this->Range;
00349     }
00350   void GetRange(float range[2])
00351     {
00352       this->GetRange(range,0);
00353     }
00355 
00357 
00360   void GetDataTypeRange(double range[2]);
00361   double GetDataTypeMin();
00362   double GetDataTypeMax();
00364 
00367   virtual float GetMaxNorm();
00368 
00374   static vtkDataArray* CreateDataArray(int dataType);
00375 
00376 protected:
00377   // Construct object with default tuple dimension (number of components) of 1.
00378   vtkDataArray(vtkIdType numComp=1);
00379   ~vtkDataArray();
00380 
00381   vtkLookupTable *LookupTable;
00382 
00383   vtkIdType Size;      // allocated size of data
00384   vtkIdType MaxId;     // maximum index inserted thus far
00385   int NumberOfComponents; // the number of components per tuple
00386 
00387   char* Name;
00388 
00389 private:
00390   float Range[2];
00391   int ComponentForLastRange;
00392   vtkTimeStamp ComputeTimeForLastRange;
00393 
00394   float* GetTupleN(const vtkIdType i, int n);
00395   
00396 private:
00397   vtkDataArray(const vtkDataArray&);  // Not implemented.
00398   void operator=(const vtkDataArray&);  // Not implemented.
00399 };
00400 
00401 #endif