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 "vtkCommonCoreModule.h" // For export macro 00050 #include "vtkObject.h" 00051 #include "vtkVariant.h" // for variant arguments 00052 00053 class vtkArrayIterator; 00054 class vtkDataArray; 00055 class vtkIdList; 00056 class vtkIdTypeArray; 00057 class vtkInformation; 00058 class vtkInformationDoubleVectorKey; 00059 class vtkInformationIntegerKey; 00060 class vtkInformationInformationVectorKey; 00061 class vtkInformationVariantVectorKey; 00062 class vtkVariantArray; 00063 00064 class VTKCOMMONCORE_EXPORT vtkAbstractArray : public vtkObject 00065 { 00066 public: 00067 vtkTypeMacro(vtkAbstractArray,vtkObject); 00068 void PrintSelf(ostream& os, vtkIndent indent); 00069 00072 virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0; 00073 00075 virtual void Initialize() = 0; 00076 00079 virtual int GetDataType() =0; 00080 00082 00085 virtual int GetDataTypeSize() = 0; 00086 static int GetDataTypeSize(int type); 00088 00093 virtual int GetElementComponentSize() = 0; 00094 00096 00098 vtkSetClampMacro(NumberOfComponents, int, 1, VTK_INT_MAX); 00099 int GetNumberOfComponents() { return this->NumberOfComponents; } 00101 00103 void SetComponentName( vtkIdType component, const char *name ); 00104 00107 const char* GetComponentName( vtkIdType component ); 00108 00110 bool HasAComponentName(); 00111 00115 int CopyComponentNames( vtkAbstractArray *da ); 00116 00122 virtual void SetNumberOfTuples(vtkIdType number) = 0; 00123 00125 00126 vtkIdType GetNumberOfTuples() 00127 {return (this->MaxId + 1)/this->NumberOfComponents;} 00129 00135 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00136 00140 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0; 00141 00145 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0; 00146 00150 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output); 00151 00155 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00156 00159 virtual void *GetVoidPointer(vtkIdType id) = 0; 00160 00165 virtual void DeepCopy(vtkAbstractArray* da); 00166 00168 00172 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00173 vtkAbstractArray* source, double* weights) = 0; 00175 00177 00182 virtual void InterpolateTuple(vtkIdType i, 00183 vtkIdType id1, vtkAbstractArray* source1, 00184 vtkIdType id2, vtkAbstractArray* source2, double t) =0; 00186 00189 virtual void Squeeze() = 0; 00190 00193 virtual int Resize(vtkIdType numTuples) = 0; 00194 00196 00197 void Reset() 00198 {this->MaxId = -1;} 00200 00202 00203 vtkIdType GetSize() 00204 {return this->Size;} 00206 00208 00209 vtkIdType GetMaxId() 00210 {return this->MaxId;} 00212 00214 00220 virtual void SetVoidArray(void *vtkNotUsed(array), 00221 vtkIdType vtkNotUsed(size), 00222 int vtkNotUsed(save)) =0; 00224 00228 virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {} 00229 00236 virtual unsigned long GetActualMemorySize() = 0; 00237 00239 00240 vtkSetStringMacro(Name); 00241 vtkGetStringMacro(Name); 00243 00245 00246 virtual const char *GetDataTypeAsString( void ) 00247 { return vtkImageScalarTypeNameMacro( this->GetDataType() ); } 00249 00255 static vtkAbstractArray* CreateArray(int dataType); 00256 00259 virtual int IsNumeric() = 0; 00260 00263 virtual vtkArrayIterator* NewIterator() = 0; 00264 00266 00270 virtual vtkIdType GetDataSize() 00271 { 00272 return this->GetNumberOfComponents() * this->GetNumberOfTuples(); 00273 } 00275 00277 00278 virtual vtkIdType LookupValue(vtkVariant value) = 0; 00279 virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0; 00281 00283 virtual vtkVariant GetVariantValue(vtkIdType idx); 00284 00287 virtual void InsertVariantValue(vtkIdType idx, vtkVariant value); 00288 00291 virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0; 00292 00299 virtual void DataChanged() = 0; 00300 00304 virtual void ClearLookup() = 0; 00305 00307 00348 virtual void GetProminentComponentValues(int comp, vtkVariantArray* values, 00349 double uncertainty = 1.e-6, double minimumProminence = 1.e-3); 00351 00352 // TODO: Implement these lookup functions also. 00353 //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids, 00354 // bool includeMin = true, bool includeMax = true) = 0; 00355 //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0; 00356 //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0; 00357 00361 vtkInformation* GetInformation(); 00363 00365 bool HasInformation(){ return this->Information!=0; } 00366 //BTX 00368 00369 00376 virtual int CopyInformation(vtkInformation *infoFrom, int deep=1); 00377 //ETX 00379 00382 static vtkInformationIntegerKey* GUI_HIDE(); 00383 00396 static vtkInformationInformationVectorKey* PER_COMPONENT(); 00397 00402 static vtkInformationVariantVectorKey* DISCRETE_VALUES(); 00403 00410 static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS(); 00411 00412 enum { 00413 MAX_DISCRETE_VALUES = 32 00414 }; 00415 00416 protected: 00417 // Construct object with default tuple dimension (number of components) of 1. 00418 vtkAbstractArray(vtkIdType numComp=1); 00419 ~vtkAbstractArray(); 00420 00424 virtual void SetInformation( vtkInformation* ); 00425 00433 virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence); 00434 00435 vtkIdType Size; // allocated size of data 00436 vtkIdType MaxId; // maximum index inserted thus far 00437 int NumberOfComponents; // the number of components per tuple 00438 00439 char* Name; 00440 00441 bool RebuildArray; // whether to rebuild the fast lookup data structure. 00442 00443 vtkInformation* Information; 00444 00445 //BTX 00446 class vtkInternalComponentNames; 00447 vtkInternalComponentNames* ComponentNames; //names for each component 00448 //ETX 00449 00450 private: 00451 vtkAbstractArray(const vtkAbstractArray&); // Not implemented. 00452 void operator=(const vtkAbstractArray&); // Not implemented. 00453 }; 00454 00455 #endif