VTK
|
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 =========================================================================*/ 00039 #ifndef __vtkDataArray_h 00040 #define __vtkDataArray_h 00041 00042 #include "vtkAbstractArray.h" 00043 00044 class vtkDoubleArray; 00045 class vtkIdList; 00046 class vtkInformationDoubleVectorKey; 00047 class vtkInformationInformationVectorKey; 00048 class vtkLookupTable; 00049 00050 class VTK_COMMON_EXPORT vtkDataArray : public vtkAbstractArray 00051 { 00052 public: 00053 vtkTypeRevisionMacro(vtkDataArray,vtkAbstractArray); 00054 void PrintSelf(ostream& os, vtkIndent indent); 00055 00057 00061 virtual int IsNumeric() 00062 { return 1; } 00064 00066 00068 virtual int GetElementComponentSize() 00069 { return this->GetDataTypeSize(); } 00071 00077 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00078 00083 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00084 00090 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0; 00091 00095 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); 00096 00100 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00101 00102 00104 00108 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00109 vtkAbstractArray* source, double* weights); 00111 00113 00118 virtual void InterpolateTuple(vtkIdType i, 00119 vtkIdType id1, vtkAbstractArray* source1, 00120 vtkIdType id2, vtkAbstractArray* source2, double t); 00122 00127 virtual double *GetTuple(vtkIdType i) = 0; 00128 00132 virtual void GetTuple(vtkIdType i, double * tuple) = 0; 00133 00135 00138 double GetTuple1(vtkIdType i); 00139 double* GetTuple2(vtkIdType i); 00140 double* GetTuple3(vtkIdType i); 00141 double* GetTuple4(vtkIdType i); 00142 double* GetTuple9(vtkIdType i); 00144 00146 00149 virtual void SetTuple(vtkIdType i, const float * tuple) = 0; 00150 virtual void SetTuple(vtkIdType i, const double * tuple) = 0; 00152 00154 00157 void SetTuple1(vtkIdType i, double value); 00158 void SetTuple2(vtkIdType i, double val0, double val1); 00159 void SetTuple3(vtkIdType i, double val0, double val1, double val2); 00160 void SetTuple4(vtkIdType i, double val0, double val1, double val2, 00161 double val3); 00162 void SetTuple9(vtkIdType i, double val0, double val1, double val2, 00163 double val3, double val4, double val5, double val6, 00164 double val7, double val8); 00166 00168 00170 virtual void InsertTuple(vtkIdType i, const float * tuple) = 0; 00171 virtual void InsertTuple(vtkIdType i, const double * tuple) = 0; 00173 00175 00178 void InsertTuple1(vtkIdType i, double value); 00179 void InsertTuple2(vtkIdType i, double val0, double val1); 00180 void InsertTuple3(vtkIdType i, double val0, double val1, double val2); 00181 void InsertTuple4(vtkIdType i, double val0, double val1, double val2, 00182 double val3); 00183 void InsertTuple9(vtkIdType i, double val0, double val1, double val2, 00184 double val3, double val4, double val5, double val6, 00185 double val7, double val8); 00187 00189 00192 virtual vtkIdType InsertNextTuple(const float * tuple) = 0; 00193 virtual vtkIdType InsertNextTuple(const double * tuple) = 0; 00195 00197 00200 void InsertNextTuple1(double value); 00201 void InsertNextTuple2(double val0, double val1); 00202 void InsertNextTuple3(double val0, double val1, double val2); 00203 void InsertNextTuple4(double val0, double val1, double val2, 00204 double val3); 00205 void InsertNextTuple9(double val0, double val1, double val2, 00206 double val3, double val4, double val5, double val6, 00207 double val7, double val8); 00209 00211 00214 virtual void RemoveTuple(vtkIdType id) = 0; 00215 virtual void RemoveFirstTuple() = 0; 00216 virtual void RemoveLastTuple() = 0; 00218 00222 virtual double GetComponent(vtkIdType i, int j); 00223 00228 virtual void SetComponent(vtkIdType i, int j, double c); 00229 00233 virtual void InsertComponent(vtkIdType i, int j, double c); 00234 00236 00242 virtual void GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin, 00243 int compMax, vtkDoubleArray* data); 00245 00247 00249 virtual void DeepCopy(vtkAbstractArray *aa); 00250 virtual void DeepCopy(vtkDataArray *da); 00252 00257 virtual void FillComponent(int j, double c); 00258 00260 00266 virtual void CopyComponent(int j, vtkDataArray *from, 00267 int fromComponent); 00269 00273 virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number) = 0; 00274 00281 virtual unsigned long GetActualMemorySize(); 00282 00285 void CreateDefaultLookupTable(); 00286 00288 00289 void SetLookupTable(vtkLookupTable *lut); 00290 vtkGetObjectMacro(LookupTable,vtkLookupTable); 00292 00294 00298 void GetRange(double range[2], int comp) 00299 { 00300 this->ComputeRange(comp); 00301 memcpy(range, this->Range, 2*sizeof(double)); 00302 } 00303 double* GetRange(int comp) 00304 { 00305 this->ComputeRange(comp); 00306 return this->Range; 00307 } 00308 // Description: 00309 // Return the range of the array values for the 0th component. 00310 // Range is copied into the array provided. 00311 double* GetRange() 00312 { 00313 this->ComputeRange(0); 00314 return this->Range; 00315 } 00316 void GetRange(double range[2]) 00317 { 00318 this->GetRange(range,0); 00319 } 00320 // Description: 00321 // These methods return the Min and Max possible range of the native 00322 // data type. For example if a vtkScalars consists of unsigned char 00323 // data these will return (0,255). 00324 void GetDataTypeRange(double range[2]); 00325 double GetDataTypeMin(); 00326 double GetDataTypeMax(); 00327 static void GetDataTypeRange(int type, double range[2]); 00328 static double GetDataTypeMin(int type); 00329 static double GetDataTypeMax(int type); 00331 00334 virtual double GetMaxNorm(); 00335 00341 static vtkDataArray* CreateDataArray(int dataType); 00342 00344 00354 static vtkInformationInformationVectorKey* PER_COMPONENT(); 00355 // Description: 00356 // This key is used to hold tight bounds on the range of 00357 // one component over all tuples of the array. 00358 // Two values (a minimum and maximum) are stored for each component. 00359 // When GetRange() is called when no tuples are present in the array 00360 // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }. 00361 static vtkInformationDoubleVectorKey* COMPONENT_RANGE(); 00362 // Description: 00363 // This key is used to hold tight bounds on the $L_2$ norm 00364 // of tuples in the array. 00365 // Two values (a minimum and maximum) are stored for each component. 00366 // When GetRange() is called when no tuples are present in the array 00367 // this value is set to { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN }. 00368 static vtkInformationDoubleVectorKey* L2_NORM_RANGE(); 00370 00376 virtual int CopyInformation(vtkInformation *infoFrom, int deep=1); 00377 00378 protected: 00380 00383 virtual void ComputeRange(int comp); 00384 // Description: 00385 // Slow range computation methods. Reimplement. 00386 virtual void ComputeScalarRange(int comp); 00387 virtual void ComputeVectorRange(); 00389 00390 // Construct object with default tuple dimension (number of components) of 1. 00391 vtkDataArray(vtkIdType numComp=1); 00392 ~vtkDataArray(); 00393 00394 vtkLookupTable *LookupTable; 00395 double Range[2]; 00396 00397 private: 00398 double* GetTupleN(vtkIdType i, int n); 00399 00400 private: 00401 vtkDataArray(const vtkDataArray&); // Not implemented. 00402 void operator=(const vtkDataArray&); // Not implemented. 00403 }; 00404 00405 #endif