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

dox/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 =========================================================================*/ 00051 #ifndef __vtkDataArray_h 00052 #define __vtkDataArray_h 00053 00054 #include "vtkObject.h" 00055 00056 class vtkFloatArray; 00057 class vtkLookupTable; 00058 class vtkIdList; 00059 00060 class VTK_COMMON_EXPORT vtkDataArray : public vtkObject 00061 { 00062 public: 00063 vtkTypeRevisionMacro(vtkDataArray,vtkObject); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00067 00069 virtual int Allocate(const vtkIdType sz, const vtkIdType ext=1000) = 0; 00070 virtual void Initialize() = 0; 00072 00073 #ifndef VTK_REMOVE_LEGACY_CODE 00074 00075 virtual vtkDataArray* MakeObject(); 00076 #endif 00077 00080 virtual int GetDataType() = 0; 00081 00084 virtual int GetDataTypeSize() = 0; 00085 00087 00089 vtkSetClampMacro(NumberOfComponents,int,1,VTK_LARGE_INTEGER); 00090 int GetNumberOfComponents() {return this->NumberOfComponents;}; 00092 00095 virtual void SetNumberOfTuples(const vtkIdType number) = 0; 00096 00098 00099 vtkIdType GetNumberOfTuples() 00100 {return (this->MaxId + 1)/this->NumberOfComponents;} 00102 00107 virtual float *GetTuple(const vtkIdType i) = 0; 00108 00110 00113 virtual void GetTuple(const vtkIdType i, float * tuple) = 0; 00114 virtual void GetTuple(const vtkIdType i, double * tuple); 00116 00118 00121 float GetTuple1(const vtkIdType i); 00122 float* GetTuple2(const vtkIdType i); 00123 float* GetTuple3(const vtkIdType i); 00124 float* GetTuple4(const vtkIdType i); 00125 float* GetTuple9(const vtkIdType i); 00127 00131 void GetTuples(vtkIdList *ptIds, vtkDataArray *output); 00132 00136 void GetTuples(vtkIdType p1, vtkIdType p2, vtkDataArray *output); 00137 00139 00142 virtual void SetTuple(const vtkIdType i, const float * tuple) = 0; 00143 virtual void SetTuple(const vtkIdType i, const double * tuple); 00145 00147 00150 void SetTuple1(const vtkIdType i, float value); 00151 void SetTuple2(const vtkIdType i, float val0, float val1); 00152 void SetTuple3(const vtkIdType i, float val0, float val1, float val2); 00153 void SetTuple4(const vtkIdType i, float val0, float val1, float val2, 00154 float val3); 00155 void SetTuple9(const vtkIdType i, float val0, float val1, float val2, 00156 float val3, float val4, float val5, float val6, 00157 float val7, float val8); 00159 00161 00163 virtual void InsertTuple(const vtkIdType i, const float * tuple) = 0; 00164 virtual void InsertTuple(const vtkIdType i, const double * tuple); 00166 00168 00171 void InsertTuple1(const vtkIdType i, float value); 00172 void InsertTuple2(const vtkIdType i, float val0, float val1); 00173 void InsertTuple3(const vtkIdType i, float val0, float val1, float val2); 00174 void InsertTuple4(const vtkIdType i, float val0, float val1, float val2, 00175 float val3); 00176 void InsertTuple9(const vtkIdType i, float val0, float val1, float val2, 00177 float val3, float val4, float val5, float val6, 00178 float val7, float val8); 00180 00182 00185 virtual vtkIdType InsertNextTuple(const float * tuple) = 0; 00186 virtual vtkIdType InsertNextTuple(const double * tuple); 00188 00190 00193 void InsertNextTuple1(float value); 00194 void InsertNextTuple2(float val0, float val1); 00195 void InsertNextTuple3(float val0, float val1, float val2); 00196 void InsertNextTuple4(float val0, float val1, float val2, 00197 float val3); 00198 void InsertNextTuple9(float val0, float val1, float val2, 00199 float val3, float val4, float val5, float val6, 00200 float val7, float val8); 00202 00206 virtual float GetComponent(const vtkIdType i, const int j); 00207 00212 virtual void SetComponent(const vtkIdType i, const int j, float c); 00213 00217 virtual void InsertComponent(const vtkIdType i, const int j, float c); 00218 00220 00226 virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin, 00227 int compMax, vtkFloatArray* data); 00229 00232 virtual void DeepCopy(vtkDataArray *da); 00233 00238 virtual void FillComponent(const int j, const float c); 00239 00241 00247 virtual void CopyComponent(const int j, vtkDataArray *from, 00248 const int fromComponent); 00250 00253 virtual void *GetVoidPointer(const vtkIdType id) = 0; 00254 00256 virtual void Squeeze() = 0; 00257 00259 virtual void Resize(vtkIdType numTuples) = 0; 00260 00262 00263 void Reset() 00264 {this->MaxId = -1;} 00266 00268 00269 vtkIdType GetSize() 00270 {return this->Size;} 00272 00274 00275 vtkIdType GetMaxId() 00276 {return this->MaxId;} 00278 00280 00286 virtual void SetVoidArray(void *vtkNotUsed(array), 00287 vtkIdType vtkNotUsed(size), 00288 int vtkNotUsed(save)) {}; 00290 00297 unsigned long GetActualMemorySize(); 00298 00301 void CreateDefaultLookupTable(); 00302 00304 00305 void SetLookupTable(vtkLookupTable *lut); 00306 vtkGetObjectMacro(LookupTable,vtkLookupTable); 00308 00310 00311 void SetName(const char* name); 00312 const char* GetName(); 00314 00316 00318 void GetRange(float range[2], int comp) 00319 { 00320 this->ComputeRange(comp); 00321 memcpy(range, this->Range, 2*sizeof(float)); 00322 } 00323 float* GetRange(int comp) 00324 { 00325 this->ComputeRange(comp); 00326 return this->Range; 00327 } 00329 00330 virtual void ComputeRange(int comp); 00332 00334 float* GetRange() 00335 { 00336 this->ComputeRange(0); 00337 return this->Range; 00338 } 00339 void GetRange(float range[2]) 00340 { 00341 this->GetRange(range,0); 00342 } 00344 00346 00349 void GetDataTypeRange(double range[2]); 00350 double GetDataTypeMin(); 00351 double GetDataTypeMax(); 00353 00356 virtual float GetMaxNorm(); 00357 00363 static vtkDataArray* CreateDataArray(int dataType); 00364 00365 protected: 00366 // Construct object with default tuple dimension (number of components) of 1. 00367 vtkDataArray(vtkIdType numComp=1); 00368 ~vtkDataArray(); 00369 00370 vtkLookupTable *LookupTable; 00371 00372 vtkIdType Size; // allocated size of data 00373 vtkIdType MaxId; // maximum index inserted thus far 00374 int NumberOfComponents; // the number of components per tuple 00375 00376 char* Name; 00377 00378 private: 00379 float Range[2]; 00380 int ComponentForLastRange; 00381 vtkTimeStamp ComputeTimeForLastRange; 00382 00383 float* GetTupleN(const vtkIdType i, int n); 00384 00385 private: 00386 vtkDataArray(const vtkDataArray&); // Not implemented. 00387 void operator=(const vtkDataArray&); // Not implemented. 00388 }; 00389 00390 #endif