VTK
dox/Common/Core/vtkStringArray.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkStringArray.h
00005   Language:  C++
00006 
00007   Copyright 2004 Sandia Corporation.
00008   Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009   license for use of this work by or on behalf of the
00010   U.S. Government. Redistribution and use in source and binary forms, with
00011   or without modification, are permitted provided that this Notice and any
00012   statement of authorship are reproduced on all copies.
00013 
00014 =========================================================================*/
00015 
00035 #ifndef __vtkStringArray_h
00036 #define __vtkStringArray_h
00037 
00038 #include "vtkCommonCoreModule.h" // For export macro
00039 #include "vtkAbstractArray.h"
00040 #include "vtkStdString.h" // needed for vtkStdString definition
00041 
00042 class vtkStringArrayLookup;
00043 
00044 class VTKCOMMONCORE_EXPORT vtkStringArray : public vtkAbstractArray
00045 {
00046 public:
00047   static vtkStringArray* New();
00048   vtkTypeMacro(vtkStringArray,vtkAbstractArray);
00049   void PrintSelf(ostream& os, vtkIndent indent);
00050 
00051   //
00052   //
00053   // Functions required by vtkAbstractArray
00054   //
00055   //
00056 
00058 
00059   int GetDataType()
00060     { return VTK_STRING; }
00062 
00063   int IsNumeric() { return 0; }
00064 
00066   void Initialize();
00067 
00071   int GetDataTypeSize();
00072 
00075   void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
00076 
00078   int Resize(vtkIdType numTuples);
00079 
00085   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00086 
00090   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00091 
00093 
00096   virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
00097                             vtkAbstractArray *source);
00099 
00103   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00104 
00106 
00110   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00111     vtkAbstractArray* source,  double* weights);
00113 
00115 
00120   virtual void InterpolateTuple(vtkIdType i,
00121     vtkIdType id1, vtkAbstractArray* source1,
00122     vtkIdType id2, vtkAbstractArray* source2, double t);
00124 
00129   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00130 
00135   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00136 
00139   int Allocate( vtkIdType sz, vtkIdType ext=1000 );
00140 
00142   vtkStdString &GetValue(vtkIdType id);
00143 
00144 //BTX
00146 
00148   void SetValue(vtkIdType id, vtkStdString value)
00149     { this->Array[id] = value; this->DataChanged(); }
00150 //ETX
00151   void SetValue(vtkIdType id, const char *value);
00153 
00155 
00157   virtual void SetNumberOfTuples(vtkIdType number)
00158     { this->SetNumberOfValues(this->NumberOfComponents* number); }
00160 
00164   void SetNumberOfValues(vtkIdType number);
00165 
00166   vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
00167 
00168   int GetNumberOfElementComponents() { return 0; }
00169   int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
00170 
00171 //BTX
00173 
00174   void InsertValue(vtkIdType id, vtkStdString f);
00175 //ETX
00176   void InsertValue(vtkIdType id, const char *val);
00178 
00181   void SetVariantValue(vtkIdType idx, vtkVariant value);
00182 
00183 //BTX
00185 
00187   vtkIdType InsertNextValue(vtkStdString f);
00188 //ETX
00189   vtkIdType InsertNextValue(const char *f);
00191 
00192 //BTX
00194 
00197   vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
00198 //ETX
00200 
00201 //BTX
00203 
00205   vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
00206   void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00207 //ETX
00209 
00212   void DeepCopy( vtkAbstractArray* aa );
00213 
00214 
00215 //BTX
00217 
00226   void SetArray(vtkStdString* array, vtkIdType size, int save);
00227   virtual void SetVoidArray(void* array, vtkIdType size, int save)
00228     { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
00229 //ETX
00231 
00239   unsigned long GetActualMemorySize();
00240 
00242   virtual vtkArrayIterator* NewIterator();
00243 
00248   virtual vtkIdType GetDataSize();
00249 
00251 
00252   virtual vtkIdType LookupValue(vtkVariant value);
00253   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00254 //BTX
00255   vtkIdType LookupValue(vtkStdString value);
00256   void LookupValue(vtkStdString value, vtkIdList* ids);
00257 //ETX
00258   vtkIdType LookupValue(const char* value);
00259   void LookupValue(const char* value, vtkIdList* ids);
00261 
00268   virtual void DataChanged();
00269 
00273   virtual void DataElementChanged(vtkIdType id);
00274 
00278   virtual void ClearLookup();
00279 
00280 protected:
00281   vtkStringArray();
00282   ~vtkStringArray();
00283 
00284   vtkStdString* Array;   // pointer to data
00285   vtkStdString* ResizeAndExtend(vtkIdType sz);  // function to resize data
00286 
00287   int SaveUserArray;
00288 
00289 private:
00290   vtkStringArray(const vtkStringArray&);  // Not implemented.
00291   void operator=(const vtkStringArray&);  // Not implemented.
00292 
00293   //BTX
00294   vtkStringArrayLookup* Lookup;
00295   void UpdateLookup();
00296   //ETX
00297 };
00298 
00299 
00300 
00301 #endif