VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/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 
00101 
00104   virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
00105                             vtkAbstractArray* source);
00107 
00111   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00112 
00114 
00118   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00119     vtkAbstractArray* source,  double* weights);
00121 
00123 
00128   virtual void InterpolateTuple(vtkIdType i,
00129     vtkIdType id1, vtkAbstractArray* source1,
00130     vtkIdType id2, vtkAbstractArray* source2, double t);
00132 
00137   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00138 
00143   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00144 
00147   int Allocate( vtkIdType sz, vtkIdType ext=1000 );
00148 
00150   vtkStdString &GetValue(vtkIdType id);
00151 
00152 //BTX
00154 
00156   void SetValue(vtkIdType id, vtkStdString value)
00157     { this->Array[id] = value; this->DataChanged(); }
00158 //ETX
00159   void SetValue(vtkIdType id, const char *value);
00161 
00163 
00165   virtual void SetNumberOfTuples(vtkIdType number)
00166     { this->SetNumberOfValues(this->NumberOfComponents* number); }
00168 
00172   void SetNumberOfValues(vtkIdType number);
00173 
00174   vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
00175 
00176   int GetNumberOfElementComponents() { return 0; }
00177   int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
00178 
00179 //BTX
00181 
00182   void InsertValue(vtkIdType id, vtkStdString f);
00183 //ETX
00184   void InsertValue(vtkIdType id, const char *val);
00186 
00189   void SetVariantValue(vtkIdType idx, vtkVariant value);
00190 
00191 //BTX
00193 
00195   vtkIdType InsertNextValue(vtkStdString f);
00196 //ETX
00197   vtkIdType InsertNextValue(const char *f);
00199 
00200 //BTX
00202 
00205   vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
00206 //ETX
00208 
00209 //BTX
00211 
00213   vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
00214   void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00215 //ETX
00217 
00220   void DeepCopy( vtkAbstractArray* aa );
00221 
00222 
00223 //BTX
00225 
00234   void SetArray(vtkStdString* array, vtkIdType size, int save);
00235   virtual void SetVoidArray(void* array, vtkIdType size, int save)
00236     { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
00237 //ETX
00239 
00247   unsigned long GetActualMemorySize();
00248 
00250   virtual vtkArrayIterator* NewIterator();
00251 
00256   virtual vtkIdType GetDataSize();
00257 
00259 
00260   virtual vtkIdType LookupValue(vtkVariant value);
00261   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00262 //BTX
00263   vtkIdType LookupValue(vtkStdString value);
00264   void LookupValue(vtkStdString value, vtkIdList* ids);
00265 //ETX
00266   vtkIdType LookupValue(const char* value);
00267   void LookupValue(const char* value, vtkIdList* ids);
00269 
00276   virtual void DataChanged();
00277 
00281   virtual void DataElementChanged(vtkIdType id);
00282 
00286   virtual void ClearLookup();
00287 
00288 protected:
00289   vtkStringArray();
00290   ~vtkStringArray();
00291 
00292   vtkStdString* Array;   // pointer to data
00293   vtkStdString* ResizeAndExtend(vtkIdType sz);  // function to resize data
00294 
00295   int SaveUserArray;
00296 
00297 private:
00298   vtkStringArray(const vtkStringArray&);  // Not implemented.
00299   void operator=(const vtkStringArray&);  // Not implemented.
00300 
00301   //BTX
00302   vtkStringArrayLookup* Lookup;
00303   void UpdateLookup();
00304   //ETX
00305 };
00306 
00307 
00308 
00309 #endif