VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAbstractArray.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 =========================================================================*/ 00015 // 00046 #ifndef __vtkAbstractArray_h 00047 #define __vtkAbstractArray_h 00048 00049 #include "vtkObject.h" 00050 #include "vtkVariant.h" // for variant arguments 00051 00052 class vtkArrayIterator; 00053 class vtkDataArray; 00054 class vtkIdList; 00055 class vtkIdTypeArray; 00056 class vtkInformation; 00057 class vtkInformationIntegerKey; 00058 00059 class VTK_COMMON_EXPORT vtkAbstractArray : public vtkObject 00060 { 00061 public: 00062 vtkTypeMacro(vtkAbstractArray,vtkObject); 00063 void PrintSelf(ostream& os, vtkIndent indent); 00064 00067 virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0; 00068 00070 virtual void Initialize() = 0; 00071 00074 virtual int GetDataType() =0; 00075 00077 00080 virtual int GetDataTypeSize() = 0; 00081 static int GetDataTypeSize(int type); 00083 00088 virtual int GetElementComponentSize() = 0; 00089 00091 00093 vtkSetClampMacro(NumberOfComponents, int, 1, VTK_LARGE_INTEGER); 00094 int GetNumberOfComponents() { return this->NumberOfComponents; } 00096 00098 void SetComponentName( vtkIdType component, const char *name ); 00099 00102 const char* GetComponentName( vtkIdType component ); 00103 00105 bool HasAComponentName(); 00106 00110 int CopyComponentNames( vtkAbstractArray *da ); 00111 00117 virtual void SetNumberOfTuples(vtkIdType number) = 0; 00118 00120 00121 vtkIdType GetNumberOfTuples() 00122 {return (this->MaxId + 1)/this->NumberOfComponents;} 00124 00130 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00131 00135 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00136 00140 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0; 00141 00145 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output); 00146 00150 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00151 00154 virtual void *GetVoidPointer(vtkIdType id) = 0; 00155 00160 virtual void DeepCopy(vtkAbstractArray* da); 00161 00163 00167 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00168 vtkAbstractArray* source, double* weights) = 0; 00170 00172 00177 virtual void InterpolateTuple(vtkIdType i, 00178 vtkIdType id1, vtkAbstractArray* source1, 00179 vtkIdType id2, vtkAbstractArray* source2, double t) =0; 00181 00184 virtual void Squeeze() = 0; 00185 00188 virtual int Resize(vtkIdType numTuples) = 0; 00189 00191 00192 void Reset() 00193 {this->MaxId = -1;} 00195 00197 00198 vtkIdType GetSize() 00199 {return this->Size;} 00201 00203 00204 vtkIdType GetMaxId() 00205 {return this->MaxId;} 00207 00209 00215 virtual void SetVoidArray(void *vtkNotUsed(array), 00216 vtkIdType vtkNotUsed(size), 00217 int vtkNotUsed(save)) =0; 00219 00223 virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {} 00224 00231 virtual unsigned long GetActualMemorySize() = 0; 00232 00234 00235 vtkSetStringMacro(Name); 00236 vtkGetStringMacro(Name); 00238 00240 00241 virtual const char *GetDataTypeAsString( void ) 00242 { return vtkImageScalarTypeNameMacro( this->GetDataType() ); } 00244 00250 static vtkAbstractArray* CreateArray(int dataType); 00251 00254 virtual int IsNumeric() = 0; 00255 00258 virtual vtkArrayIterator* NewIterator() = 0; 00259 00261 00265 virtual vtkIdType GetDataSize() 00266 { 00267 return this->GetNumberOfComponents() * this->GetNumberOfTuples(); 00268 } 00270 00272 00273 virtual vtkIdType LookupValue(vtkVariant value) = 0; 00274 virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0; 00276 00278 virtual vtkVariant GetVariantValue(vtkIdType idx); 00279 00282 virtual void InsertVariantValue(vtkIdType idx, vtkVariant value); 00283 00286 virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0; 00287 00294 virtual void DataChanged() = 0; 00295 00299 virtual void ClearLookup() = 0; 00300 00301 // TODO: Implement these lookup functions also. 00302 //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids, 00303 // bool includeMin = true, bool includeMax = true) = 0; 00304 //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0; 00305 //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0; 00306 00310 vtkInformation* GetInformation(); 00312 00314 bool HasInformation(){ return this->Information!=0; } 00315 //BTX 00317 00318 00325 virtual int CopyInformation(vtkInformation *infoFrom, int deep=1); 00326 //ETX 00328 00331 static vtkInformationIntegerKey* GUI_HIDE(); 00332 00333 protected: 00337 virtual void SetInformation( vtkInformation* ); 00338 00339 // Construct object with default tuple dimension (number of components) of 1. 00340 vtkAbstractArray(vtkIdType numComp=1); 00341 ~vtkAbstractArray(); 00342 00343 vtkIdType Size; // allocated size of data 00344 vtkIdType MaxId; // maximum index inserted thus far 00345 int NumberOfComponents; // the number of components per tuple 00346 00347 char* Name; 00348 00349 bool RebuildArray; // whether to rebuild the fast lookup data structure. 00350 00351 vtkInformation* Information; 00352 00353 //BTX 00354 class vtkInternalComponentNames; 00355 vtkInternalComponentNames* ComponentNames; //names for each component 00356 //ETX 00357 00358 private: 00359 vtkAbstractArray(const vtkAbstractArray&); // Not implemented. 00360 void operator=(const vtkAbstractArray&); // Not implemented. 00361 }; 00362 00363 #endif