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   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 =========================================================================*/
00063 #ifndef __vtkDataArray_h
00064 #define __vtkDataArray_h
00065 
00066 #include "vtkObject.h"
00067 
00068 class vtkFloatArray;
00069 class vtkLookupTable;
00070 class vtkIdList;
00071 
00072 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 
00073 {
00074 public:
00075   vtkTypeRevisionMacro(vtkDataArray,vtkObject);
00076   void PrintSelf(ostream& os, vtkIndent indent);
00077 
00079 
00081   virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000) = 0;
00082   virtual void Initialize() = 0;
00084 
00085 #ifndef VTK_REMOVE_LEGACY_CODE
00086 
00087   virtual vtkDataArray* MakeObject();
00088 #endif
00089 
00092   virtual int GetDataType() = 0;
00093 
00096   virtual int GetDataTypeSize() = 0;
00097 
00099 
00101   vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER);
00102   int GetNumberOfComponents() {return this->NumberOfComponents;};
00104 
00107   virtual void SetNumberOfTuples(const vtkIdType number) = 0;
00108 
00110 
00111   vtkIdType GetNumberOfTuples() 
00112     {return (this->MaxId + 1)/this->NumberOfComponents;}
00114 
00119   virtual float *GetTuple(const vtkIdType i) = 0;
00120 
00122 
00125   virtual void GetTuple(const vtkIdType i, float * tuple) = 0;
00126   virtual void GetTuple(const vtkIdType i, double * tuple);
00128 
00130 
00133   float GetTuple1(const vtkIdType i);
00134   float* GetTuple2(const vtkIdType i);
00135   float* GetTuple3(const vtkIdType i);
00136   float* GetTuple4(const vtkIdType i);
00137   float* GetTuple9(const vtkIdType i);
00139 
00143   void GetTuples(vtkIdList *ptIds, vtkDataArray *output);
00144 
00148   void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output);
00149 
00151 
00154   virtual void SetTuple(const vtkIdType i, const float * tuple) = 0;
00155   virtual void SetTuple(const vtkIdType i, const double * tuple);
00157 
00159 
00162   void SetTuple1(const vtkIdType i, float value);
00163   void SetTuple2(const vtkIdType i, float val0, float val1);
00164   void SetTuple3(const vtkIdType i, float val0, float val1, float val2);
00165   void SetTuple4(const vtkIdType i, float val0, float val1, float val2,
00166                  float val3);
00167   void SetTuple9(const vtkIdType i, float val0, float val1, float val2,
00168                  float val3, float val4, float val5, float val6,
00169                  float val7, float val8);
00171 
00173 
00175   virtual void InsertTuple(const vtkIdType i, const float * tuple) = 0;
00176   virtual void InsertTuple(const vtkIdType i, const double * tuple);
00178 
00180 
00183   void InsertTuple1(const vtkIdType i, float value);
00184   void InsertTuple2(const vtkIdType i, float val0, float val1);
00185   void InsertTuple3(const vtkIdType i, float val0, float val1, float val2);
00186   void InsertTuple4(const vtkIdType i, float val0, float val1, float val2,
00187                     float val3);
00188   void InsertTuple9(const vtkIdType i, float val0, float val1, float val2,
00189                     float val3, float val4, float val5, float val6,
00190                     float val7, float val8);
00192 
00194 
00197   virtual vtkIdType InsertNextTuple(const float * tuple) = 0;
00198   virtual vtkIdType InsertNextTuple(const double * tuple);
00200 
00202 
00205   void InsertNextTuple1(float value);
00206   void InsertNextTuple2(float val0, float val1);
00207   void InsertNextTuple3(float val0, float val1, float val2);
00208   void InsertNextTuple4(float val0, float val1, float val2,
00209                         float val3);
00210   void InsertNextTuple9(float val0, float val1, float val2,
00211                         float val3, float val4, float val5, float val6,
00212                         float val7, float val8);
00214 
00218   virtual float GetComponent(const vtkIdType i, const int j);
00219 
00224   virtual void SetComponent(const vtkIdType i, const int j, float c);
00225 
00229   virtual void InsertComponent(const vtkIdType i, const int j, float c);
00230 
00232 
00238   virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
00239                        int compMax, vtkFloatArray* data);
00241 
00244   virtual void DeepCopy(vtkDataArray *da);
00245 
00250   virtual void FillComponent(const int j, const float c);
00251 
00253 
00259   virtual void CopyComponent(const int j, vtkDataArray *from,
00260                              const int fromComponent);
00262 
00265   virtual void *GetVoidPointer(const vtkIdType id) = 0;
00266 
00268   virtual void Squeeze() = 0;
00269 
00271   virtual void Resize(vtkIdType numTuples) = 0;
00272 
00274 
00275   void Reset() 
00276     {this->MaxId = -1;}
00278 
00280 
00281   vtkIdType GetSize() 
00282     {return this->Size;}
00284   
00286 
00287   vtkIdType GetMaxId() 
00288     {return this->MaxId;}
00290 
00292 
00298   virtual void SetVoidArray(void *vtkNotUsed(array),
00299                             vtkIdType vtkNotUsed(size),
00300                             int vtkNotUsed(save)) {};
00302 
00309   unsigned long GetActualMemorySize();
00310   
00313   void CreateDefaultLookupTable();
00314 
00316 
00317   void SetLookupTable(vtkLookupTable *lut);
00318   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00320   
00322 
00323   void SetName(const char* name);
00324   const char* GetName();
00326 
00328 
00330   void GetRange(float range[2], int comp)
00331     {
00332       this->ComputeRange(comp);
00333       memcpy(range, this->Range, 2*sizeof(float));
00334     }
00335   float* GetRange(int comp)
00336     {
00337       this->ComputeRange(comp);
00338       return this->Range;
00339     }
00341 
00342   virtual void ComputeRange(int comp);
00344 
00346   float* GetRange()
00347     {
00348       this->ComputeRange(0);
00349       return this->Range;
00350     }
00351   void GetRange(float range[2])
00352     {
00353       this->GetRange(range,0);
00354     }
00356 
00358 
00361   void GetDataTypeRange(double range[2]);
00362   double GetDataTypeMin();
00363   double GetDataTypeMax();
00365 
00368   virtual float GetMaxNorm();
00369 
00375   static vtkDataArray* CreateDataArray(int dataType);
00376 
00377 protected:
00378   // Construct object with default tuple dimension (number of components) of 1.
00379   vtkDataArray(vtkIdType numComp=1);
00380   ~vtkDataArray();
00381 
00382   vtkLookupTable *LookupTable;
00383 
00384   vtkIdType Size;      // allocated size of data
00385   vtkIdType MaxId;     // maximum index inserted thus far
00386   int NumberOfComponents; // the number of components per tuple
00387 
00388   char* Name;
00389 
00390 private:
00391   float Range[2];
00392   int ComponentForLastRange;
00393   vtkTimeStamp ComputeTimeForLastRange;
00394 
00395   float* GetTupleN(const vtkIdType i, int n);
00396   
00397 private:
00398   vtkDataArray(const vtkDataArray&);  // Not implemented.
00399   void operator=(const vtkDataArray&);  // Not implemented.
00400 };
00401 
00402 #endif