VTK
dox/Common/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 "vtkAbstractArray.h"
00039 #include "vtkStdString.h" // needed for vtkStdString definition
00040 
00041 class vtkStringArrayLookup;
00042 
00043 class VTK_COMMON_EXPORT vtkStringArray : public vtkAbstractArray
00044 {
00045 public:
00046   static vtkStringArray* New();
00047   vtkTypeMacro(vtkStringArray,vtkAbstractArray);
00048   void PrintSelf(ostream& os, vtkIndent indent);
00049 
00050   //
00051   //
00052   // Functions required by vtkAbstractArray
00053   //
00054   //
00055 
00057 
00058   int GetDataType()
00059     { return VTK_STRING; }
00061 
00062   int IsNumeric() { return 0; }
00063 
00065   void Initialize();
00066 
00070   int GetDataTypeSize();
00071 
00074   void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
00075 
00077   int Resize(vtkIdType numTuples);
00078 
00084   virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00085 
00089   virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
00090 
00094   virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source);
00095 
00097 
00101   virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
00102     vtkAbstractArray* source,  double* weights);
00104 
00106 
00111   virtual void InterpolateTuple(vtkIdType i,
00112     vtkIdType id1, vtkAbstractArray* source1,
00113     vtkIdType id2, vtkAbstractArray* source2, double t);
00115 
00120   virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
00121 
00126   virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
00127 
00130   int Allocate( vtkIdType sz, vtkIdType ext=1000 );
00131 
00133   vtkStdString &GetValue(vtkIdType id);
00134 
00135 //BTX
00137 
00139   void SetValue(vtkIdType id, vtkStdString value)
00140     { this->Array[id] = value; this->DataChanged(); }
00141 //ETX
00142   void SetValue(vtkIdType id, const char *value);
00144 
00146 
00148   virtual void SetNumberOfTuples(vtkIdType number)
00149     { this->SetNumberOfValues(this->NumberOfComponents* number); }
00151 
00155   void SetNumberOfValues(vtkIdType number);
00156 
00157   vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
00158 
00159   int GetNumberOfElementComponents() { return 0; }
00160   int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
00161 
00162 //BTX
00164 
00165   void InsertValue(vtkIdType id, vtkStdString f);
00166 //ETX
00167   void InsertValue(vtkIdType id, const char *val);
00169 
00172   void SetVariantValue(vtkIdType idx, vtkVariant value);
00173 
00174 //BTX
00176 
00178   vtkIdType InsertNextValue(vtkStdString f);
00179 //ETX
00180   vtkIdType InsertNextValue(const char *f);
00182 
00183 //BTX
00185 
00188   vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
00189 //ETX
00191 
00192 //BTX
00194 
00196   vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
00197   void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
00198 //ETX
00200 
00203   void DeepCopy( vtkAbstractArray* aa );
00204 
00205 
00206 //BTX
00208 
00217   void SetArray(vtkStdString* array, vtkIdType size, int save);
00218   virtual void SetVoidArray(void* array, vtkIdType size, int save)
00219     { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
00220 //ETX
00222 
00230   unsigned long GetActualMemorySize();
00231 
00233   virtual vtkArrayIterator* NewIterator();
00234 
00239   virtual vtkIdType GetDataSize();
00240 
00242 
00243   virtual vtkIdType LookupValue(vtkVariant value);
00244   virtual void LookupValue(vtkVariant value, vtkIdList* ids);
00245 //BTX
00246   vtkIdType LookupValue(vtkStdString value);
00247   void LookupValue(vtkStdString value, vtkIdList* ids);
00248 //ETX
00249   vtkIdType LookupValue(const char* value);
00250   void LookupValue(const char* value, vtkIdList* ids);
00252 
00259   virtual void DataChanged();
00260 
00264   virtual void DataElementChanged(vtkIdType id);
00265 
00269   virtual void ClearLookup();
00270 
00271 protected:
00272   vtkStringArray(vtkIdType numComp=1);
00273   ~vtkStringArray();
00274 
00275   vtkStdString* Array;   // pointer to data
00276   vtkStdString* ResizeAndExtend(vtkIdType sz);  // function to resize data
00277 
00278   int SaveUserArray;
00279 
00280 private:
00281   vtkStringArray(const vtkStringArray&);  // Not implemented.
00282   void operator=(const vtkStringArray&);  // Not implemented.
00283 
00284   //BTX
00285   vtkStringArrayLookup* Lookup;
00286   void UpdateLookup();
00287   //ETX
00288 };
00289 
00290 
00291 
00292 #endif