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 00143 00146 virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, 00147 vtkAbstractArray* source) = 0; 00149 00153 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0; 00154 00158 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output); 00159 00163 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00164 00174 virtual bool HasStandardMemoryLayout(); 00175 00180 virtual void *GetVoidPointer(vtkIdType id) = 0; 00181 00186 virtual void DeepCopy(vtkAbstractArray* da); 00187 00189 00193 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00194 vtkAbstractArray* source, double* weights) = 0; 00196 00198 00203 virtual void InterpolateTuple(vtkIdType i, 00204 vtkIdType id1, vtkAbstractArray* source1, 00205 vtkIdType id2, vtkAbstractArray* source2, double t) =0; 00207 00210 virtual void Squeeze() = 0; 00211 00214 virtual int Resize(vtkIdType numTuples) = 0; 00215 00217 00218 void Reset() 00219 {this->MaxId = -1;} 00221 00223 00224 vtkIdType GetSize() 00225 {return this->Size;} 00227 00229 00230 vtkIdType GetMaxId() 00231 {return this->MaxId;} 00233 00235 00241 virtual void SetVoidArray(void *vtkNotUsed(array), 00242 vtkIdType vtkNotUsed(size), 00243 int vtkNotUsed(save)) =0; 00245 00249 virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {} 00250 00257 virtual unsigned long GetActualMemorySize() = 0; 00258 00260 00261 vtkSetStringMacro(Name); 00262 vtkGetStringMacro(Name); 00264 00266 00267 virtual const char *GetDataTypeAsString( void ) 00268 { return vtkImageScalarTypeNameMacro( this->GetDataType() ); } 00270 00276 static vtkAbstractArray* CreateArray(int dataType); 00277 00280 virtual int IsNumeric() = 0; 00281 00284 virtual vtkArrayIterator* NewIterator() = 0; 00285 00287 00291 virtual vtkIdType GetDataSize() 00292 { 00293 return this->GetNumberOfComponents() * this->GetNumberOfTuples(); 00294 } 00296 00298 00299 virtual vtkIdType LookupValue(vtkVariant value) = 0; 00300 virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0; 00302 00304 virtual vtkVariant GetVariantValue(vtkIdType idx); 00305 00308 virtual void InsertVariantValue(vtkIdType idx, vtkVariant value); 00309 00312 virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0; 00313 00320 virtual void DataChanged() = 0; 00321 00325 virtual void ClearLookup() = 0; 00326 00328 00369 virtual void GetProminentComponentValues(int comp, vtkVariantArray* values, 00370 double uncertainty = 1.e-6, double minimumProminence = 1.e-3); 00372 00373 // TODO: Implement these lookup functions also. 00374 //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids, 00375 // bool includeMin = true, bool includeMax = true) = 0; 00376 //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0; 00377 //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0; 00378 00382 vtkInformation* GetInformation(); 00384 00386 bool HasInformation(){ return this->Information!=0; } 00387 //BTX 00389 00390 00397 virtual int CopyInformation(vtkInformation *infoFrom, int deep=1); 00398 //ETX 00400 00403 static vtkInformationIntegerKey* GUI_HIDE(); 00404 00417 static vtkInformationInformationVectorKey* PER_COMPONENT(); 00418 00423 static vtkInformationVariantVectorKey* DISCRETE_VALUES(); 00424 00431 static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS(); 00432 00433 // Deprecated. Use vtkAbstractArray::MaxDiscreteValues instead. 00434 enum { 00435 MAX_DISCRETE_VALUES = 32 00436 }; 00437 00439 00441 vtkGetMacro(MaxDiscreteValues, unsigned int); 00442 vtkSetMacro(MaxDiscreteValues, unsigned int); 00444 00445 enum { 00446 AbstractArray = 0, 00447 DataArray, 00448 TypedDataArray, 00449 DataArrayTemplate, 00450 MappedDataArray 00451 }; 00452 00454 00455 virtual int GetArrayType() 00456 { 00457 return AbstractArray; 00458 } 00460 00461 protected: 00462 // Construct object with default tuple dimension (number of components) of 1. 00463 vtkAbstractArray(); 00464 ~vtkAbstractArray(); 00465 00469 virtual void SetInformation( vtkInformation* ); 00470 00478 virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence); 00479 00480 vtkIdType Size; // allocated size of data 00481 vtkIdType MaxId; // maximum index inserted thus far 00482 int NumberOfComponents; // the number of components per tuple 00483 00484 // maximum number of prominent values before array is considered continuous. 00485 unsigned int MaxDiscreteValues; 00486 00487 char* Name; 00488 00489 bool RebuildArray; // whether to rebuild the fast lookup data structure. 00490 00491 vtkInformation* Information; 00492 00493 //BTX 00494 class vtkInternalComponentNames; 00495 vtkInternalComponentNames* ComponentNames; //names for each component 00496 //ETX 00497 00498 private: 00499 vtkAbstractArray(const vtkAbstractArray&); // Not implemented. 00500 void operator=(const vtkAbstractArray&); // Not implemented. 00501 }; 00502 00503 #endif