VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDataArray.h 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 =========================================================================*/ 00042 #ifndef __vtkDataArray_h 00043 #define __vtkDataArray_h 00044 00045 #include "vtkCommonCoreModule.h" // For export macro 00046 #include "vtkAbstractArray.h" 00047 00048 class vtkDoubleArray; 00049 class vtkIdList; 00050 class vtkInformationDoubleVectorKey; 00051 class vtkLookupTable; 00052 00053 class VTKCOMMONCORE_EXPORT vtkDataArray : public vtkAbstractArray 00054 { 00055 public: 00056 vtkTypeMacro(vtkDataArray,vtkAbstractArray); 00057 void PrintSelf(ostream& os, vtkIndent indent); 00058 00064 static vtkDataArray* FastDownCast(vtkAbstractArray *source); 00065 00067 00071 virtual int IsNumeric() 00072 { return 1; } 00074 00076 00078 virtual int GetElementComponentSize() 00079 { return this->GetDataTypeSize(); } 00081 00087 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00088 00093 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00094 00100 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0; 00101 00105 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); 00106 00110 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00111 00112 00114 00118 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00119 vtkAbstractArray* source, double* weights); 00121 00123 00128 virtual void InterpolateTuple(vtkIdType i, 00129 vtkIdType id1, vtkAbstractArray* source1, 00130 vtkIdType id2, vtkAbstractArray* source2, double t); 00132 00137 virtual double *GetTuple(vtkIdType i) = 0; 00138 00142 virtual void GetTuple(vtkIdType i, double * tuple) = 0; 00143 00145 00148 double GetTuple1(vtkIdType i); 00149 double* GetTuple2(vtkIdType i); 00150 double* GetTuple3(vtkIdType i); 00151 double* GetTuple4(vtkIdType i); 00152 double* GetTuple9(vtkIdType i); 00154 00156 00159 virtual void SetTuple(vtkIdType i, const float * tuple) = 0; 00160 virtual void SetTuple(vtkIdType i, const double * tuple) = 0; 00162 00164 00167 void SetTuple1(vtkIdType i, double value); 00168 void SetTuple2(vtkIdType i, double val0, double val1); 00169 void SetTuple3(vtkIdType i, double val0, double val1, double val2); 00170 void SetTuple4(vtkIdType i, double val0, double val1, double val2, 00171 double val3); 00172 void SetTuple9(vtkIdType i, double val0, double val1, double val2, 00173 double val3, double val4, double val5, double val6, 00174 double val7, double val8); 00176 00178 00180 virtual void InsertTuple(vtkIdType i, const float * tuple) = 0; 00181 virtual void InsertTuple(vtkIdType i, const double * tuple) = 0; 00183 00185 00188 void InsertTuple1(vtkIdType i, double value); 00189 void InsertTuple2(vtkIdType i, double val0, double val1); 00190 void InsertTuple3(vtkIdType i, double val0, double val1, double val2); 00191 void InsertTuple4(vtkIdType i, double val0, double val1, double val2, 00192 double val3); 00193 void InsertTuple9(vtkIdType i, double val0, double val1, double val2, 00194 double val3, double val4, double val5, double val6, 00195 double val7, double val8); 00197 00199 00202 virtual vtkIdType InsertNextTuple(const float * tuple) = 0; 00203 virtual vtkIdType InsertNextTuple(const double * tuple) = 0; 00205 00207 00210 void InsertNextTuple1(double value); 00211 void InsertNextTuple2(double val0, double val1); 00212 void InsertNextTuple3(double val0, double val1, double val2); 00213 void InsertNextTuple4(double val0, double val1, double val2, 00214 double val3); 00215 void InsertNextTuple9(double val0, double val1, double val2, 00216 double val3, double val4, double val5, double val6, 00217 double val7, double val8); 00219 00221 00224 virtual void RemoveTuple(vtkIdType id) = 0; 00225 virtual void RemoveFirstTuple() = 0; 00226 virtual void RemoveLastTuple() = 0; 00228 00232 virtual double GetComponent(vtkIdType i, int j); 00233 00238 virtual void SetComponent(vtkIdType i, int j, double c); 00239 00243 virtual void InsertComponent(vtkIdType i, int j, double c); 00244 00246 00252 virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin, 00253 int compMax, vtkDoubleArray* data); 00255 00257 00259 virtual void DeepCopy(vtkAbstractArray *aa); 00260 virtual void DeepCopy(vtkDataArray *da); 00262 00267 virtual void FillComponent(int j, double c); 00268 00270 00276 virtual void CopyComponent(int j, vtkDataArray *from, 00277 int fromComponent); 00279 00283 virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0; 00284 00291 virtual unsigned long GetActualMemorySize(); 00292 00295 void CreateDefaultLookupTable(); 00296 00298 00299 void SetLookupTable(vtkLookupTable *lut); 00300 vtkGetObjectMacro(LookupTable,vtkLookupTable); 00302 00304 00308 void GetRange(double range[2], int comp) 00309 { 00310 this->ComputeRange(range, comp); 00311 } 00313 00315 00320 double* GetRange(int comp) 00321 { 00322 this->GetRange(this->Range, comp); 00323 return this->Range; 00324 } 00326 00328 00330 double* GetRange() 00331 { 00332 return this->GetRange(0); 00333 } 00335 00337 00339 void GetRange(double range[2]) 00340 { 00341 this->GetRange(range,0); 00342 } 00344 00345 00348 void GetDataTypeRange(double range[2]); 00349 double GetDataTypeMin(); 00350 double GetDataTypeMax(); 00351 static void GetDataTypeRange(int type, double range[2]); 00352 static double GetDataTypeMin(int type); 00353 static double GetDataTypeMax(int type); 00355 00358 virtual double GetMaxNorm(); 00359 00365 static vtkDataArray* CreateDataArray(int dataType); 00366 00372 static vtkInformationDoubleVectorKey* COMPONENT_RANGE(); 00377 static vtkInformationDoubleVectorKey* L2_NORM_RANGE(); 00378 00384 virtual int CopyInformation(vtkInformation *infoFrom, int deep=1); 00385 00387 virtual int GetArrayType() { return DataArray; } 00388 00389 protected: 00394 virtual void ComputeRange(double range[2], int comp); 00396 00397 virtual void ComputeScalarRange(double range[2], int comp); 00398 virtual void ComputeVectorRange(double range[2]); 00400 00401 // Construct object with default tuple dimension (number of components) of 1. 00402 vtkDataArray(); 00403 ~vtkDataArray(); 00404 00405 vtkLookupTable *LookupTable; 00406 double Range[2]; 00407 00408 private: 00409 double* GetTupleN(vtkIdType i, int n); 00410 00411 private: 00412 vtkDataArray(const vtkDataArray&); // Not implemented. 00413 void operator=(const vtkDataArray&); // Not implemented. 00414 }; 00415 00416 //------------------------------------------------------------------------------ 00417 inline vtkDataArray* vtkDataArray::FastDownCast(vtkAbstractArray *source) 00418 { 00419 switch (source->GetArrayType()) 00420 { 00421 case DataArrayTemplate: 00422 case TypedDataArray: 00423 case DataArray: 00424 case MappedDataArray: 00425 return static_cast<vtkDataArray*>(source); 00426 default: 00427 return NULL; 00428 } 00429 } 00430 00431 #endif