VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Common/Core/vtkAbstractArray.h
Go to the documentation of this file.
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   friend class vtkDataArrayTemplateHelper;
00068 
00069   vtkTypeMacro(vtkAbstractArray,vtkObject);
00070   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00074   virtual int Allocate(vtkIdType sz, vtkIdType ext=1000) = 0;
00075 
00077   virtual void Initialize() = 0;
00078 
00081   virtual int GetDataType() =0;
00082 
00084 
00087   virtual int GetDataTypeSize() = 0;
00088   static int GetDataTypeSize(int type);
00090 
00095   virtual int GetElementComponentSize() = 0;
00096 
00098 
00100   vtkSetClampMacro(NumberOfComponents, int, 1, VTK_INT_MAX);
00101   int GetNumberOfComponents() { return this->NumberOfComponents; }
00103 
00105   void SetComponentName( vtkIdType component, const char *name );
00106 
00109   const char* GetComponentName( vtkIdType component );
00110 
00112   bool HasAComponentName();
00113 
00117   int CopyComponentNames( vtkAbstractArray *da );
00118 
00124   virtual void SetNumberOfTuples(vtkIdType number) = 0;
00125 
00127 
00128   vtkIdType GetNumberOfTuples()
00129     {return (this->MaxId + 1)/this->NumberOfComponents;}
00131 
00137   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00138 
00142   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source) = 0;
00143 
00145 
00148   virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
00149                             vtkAbstractArray* source) = 0;
00151 
00153 
00156   virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
00157                             vtkAbstractArray* source) = 0;
00159 
00163   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source) = 0;
00164 
00168   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray* output);
00169 
00173   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00174 
00184   virtual bool HasStandardMemoryLayout();
00185 
00190   virtual void *GetVoidPointer(vtkIdType id) = 0;
00191 
00196   virtual void DeepCopy(vtkAbstractArray* da);
00197 
00199 
00203   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00204     vtkAbstractArray* source,  double* weights) = 0;
00206 
00208 
00213   virtual void InterpolateTuple(vtkIdType i,
00214     vtkIdType id1, vtkAbstractArray* source1,
00215     vtkIdType id2, vtkAbstractArray* source2, double t) =0;
00217 
00220   virtual void Squeeze() = 0;
00221 
00224   virtual int Resize(vtkIdType numTuples) = 0;
00225 
00227 
00228   void Reset()
00229     {this->MaxId = -1;}
00231 
00233 
00234   vtkIdType GetSize()
00235   {return this->Size;}
00237 
00239 
00240   vtkIdType GetMaxId()
00241     {return this->MaxId;}
00243 
00245 
00251   virtual void SetVoidArray(void *vtkNotUsed(array),
00252                             vtkIdType vtkNotUsed(size),
00253                             int vtkNotUsed(save)) =0;
00255 
00259   virtual void ExportToVoidPointer(void *vtkNotUsed(out_ptr)) {}
00260 
00267   virtual unsigned long GetActualMemorySize() = 0;
00268 
00270 
00271   vtkSetStringMacro(Name);
00272   vtkGetStringMacro(Name);
00274 
00276 
00277   virtual const char *GetDataTypeAsString( void )
00278     { return vtkImageScalarTypeNameMacro( this->GetDataType() ); }
00280 
00286   static vtkAbstractArray* CreateArray(int dataType);
00287 
00290   virtual int IsNumeric() = 0;
00291 
00294   virtual vtkArrayIterator* NewIterator() = 0;
00295 
00297 
00301   virtual vtkIdType GetDataSize()
00302     {
00303     return this->GetNumberOfComponents() * this->GetNumberOfTuples();
00304     }
00306 
00308 
00309   virtual vtkIdType LookupValue(vtkVariant value) = 0;
00310   virtual void LookupValue(vtkVariant value, vtkIdList* ids) = 0;
00312 
00314   virtual vtkVariant GetVariantValue(vtkIdType idx);
00315 
00318   virtual void InsertVariantValue(vtkIdType idx, vtkVariant value);
00319 
00322   virtual void SetVariantValue(vtkIdType idx, vtkVariant value) = 0;
00323 
00330   virtual void DataChanged() = 0;
00331 
00335   virtual void ClearLookup() = 0;
00336 
00338 
00379   virtual void GetProminentComponentValues(int comp, vtkVariantArray* values,
00380     double uncertainty = 1.e-6, double minimumProminence = 1.e-3);
00382 
00383   // TODO: Implement these lookup functions also.
00384   //virtual void LookupRange(vtkVariant min, vtkVariant max, vtkIdList* ids,
00385   //  bool includeMin = true, bool includeMax = true) = 0;
00386   //virtual void LookupGreaterThan(vtkVariant min, vtkIdList* ids, bool includeMin = false) = 0;
00387   //virtual void LookupLessThan(vtkVariant max, vtkIdList* ids, bool includeMax = false) = 0;
00388 
00392   vtkInformation* GetInformation();
00394 
00396   bool HasInformation(){ return this->Information!=0; }
00397   //BTX
00399 
00400 
00407   virtual int CopyInformation(vtkInformation *infoFrom, int deep=1);
00408   //ETX
00410 
00413   static vtkInformationIntegerKey* GUI_HIDE();
00414 
00427   static vtkInformationInformationVectorKey* PER_COMPONENT();
00428 
00433   static vtkInformationVariantVectorKey* DISCRETE_VALUES();
00434 
00441   static vtkInformationDoubleVectorKey* DISCRETE_VALUE_SAMPLE_PARAMETERS();
00442 
00443   // Deprecated.  Use vtkAbstractArray::MaxDiscreteValues instead.
00444   enum {
00445     MAX_DISCRETE_VALUES = 32
00446   };
00447 
00449 
00451   vtkGetMacro(MaxDiscreteValues, unsigned int);
00452   vtkSetMacro(MaxDiscreteValues, unsigned int);
00454 
00455   enum {
00456     AbstractArray = 0,
00457     DataArray,
00458     TypedDataArray,
00459     DataArrayTemplate,
00460     MappedDataArray
00461     };
00462 
00464 
00465   virtual int GetArrayType()
00466   {
00467     return AbstractArray;
00468   }
00470 
00471 protected:
00472   // Construct object with default tuple dimension (number of components) of 1.
00473   vtkAbstractArray();
00474   ~vtkAbstractArray();
00475 
00479   virtual void SetInformation( vtkInformation* );
00480 
00488   virtual void UpdateDiscreteValueSet(double uncertainty, double minProminence);
00489 
00490   vtkIdType Size;         // allocated size of data
00491   vtkIdType MaxId;        // maximum index inserted thus far
00492   int NumberOfComponents; // the number of components per tuple
00493 
00494   // maximum number of prominent values before array is considered continuous.
00495   unsigned int MaxDiscreteValues;
00496 
00497   char* Name;
00498 
00499   bool RebuildArray;      // whether to rebuild the fast lookup data structure.
00500 
00501   vtkInformation* Information;
00502 
00503   //BTX
00504   class vtkInternalComponentNames;
00505   vtkInternalComponentNames* ComponentNames; //names for each component
00506   //ETX
00507 
00508 private:
00509   vtkAbstractArray(const vtkAbstractArray&);  // Not implemented.
00510   void operator=(const vtkAbstractArray&);  // Not implemented.
00511 };
00512 
00513 #endif