VTK
|
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 00051 #ifndef __vtkStringArray_h 00052 #define __vtkStringArray_h 00053 00054 #include "vtkAbstractArray.h" 00055 #include "vtkStdString.h" // needed for vtkStdString definition 00056 00057 class vtkStringArrayLookup; 00058 00059 class VTK_COMMON_EXPORT vtkStringArray : public vtkAbstractArray 00060 { 00061 public: 00062 static vtkStringArray* New(); 00063 vtkTypeMacro(vtkStringArray,vtkAbstractArray); 00064 void PrintSelf(ostream& os, vtkIndent indent); 00065 00066 // 00067 // 00068 // Functions required by vtkAbstractArray 00069 // 00070 // 00071 00073 00074 int GetDataType() 00075 { return VTK_STRING; } 00077 00078 int IsNumeric() { return 0; } 00079 00081 void Initialize(); 00082 00086 int GetDataTypeSize(); 00087 00090 void Squeeze() { this->ResizeAndExtend (this->MaxId+1); } 00091 00093 int Resize(vtkIdType numTuples); 00094 00100 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00101 00105 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00106 00110 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source); 00111 00113 00117 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00118 vtkAbstractArray* source, double* weights); 00120 00122 00127 virtual void InterpolateTuple(vtkIdType i, 00128 vtkIdType id1, vtkAbstractArray* source1, 00129 vtkIdType id2, vtkAbstractArray* source2, double t); 00131 00136 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); 00137 00142 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00143 00146 int Allocate( vtkIdType sz, vtkIdType ext=1000 ); 00147 00149 vtkStdString &GetValue(vtkIdType id); 00150 00152 00155 void SetValue(vtkIdType id, vtkStdString value) 00156 { this->Array[id] = value; this->DataChanged(); } 00158 //ETX 00159 void SetValue(vtkIdType id, const char *value); 00160 00162 00164 virtual void SetNumberOfTuples(vtkIdType number) 00165 { this->SetNumberOfValues(this->NumberOfComponents* number); } 00167 00171 void SetNumberOfValues(vtkIdType number); 00172 00173 vtkIdType GetNumberOfValues() { return this->MaxId + 1; } 00174 00175 int GetNumberOfElementComponents() { return 0; } 00176 int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); } 00177 00179 void InsertValue(vtkIdType id, vtkStdString f); 00180 00182 void InsertVariantValue(vtkIdType idx, vtkVariant value); 00183 //ETX 00184 void InsertValue(vtkIdType id, const char *val); 00185 00188 vtkIdType InsertNextValue(vtkStdString f); 00189 //ETX 00190 vtkIdType InsertNextValue(const char *f); 00191 00192 //BTX 00196 vtkStdString* WritePointer(vtkIdType id, vtkIdType number); 00197 //ETX 00198 00199 //BTX 00201 00203 vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; } 00204 void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); } 00206 //ETX 00207 00210 void DeepCopy( vtkAbstractArray* aa ); 00211 00212 00213 //BTX 00215 00224 void SetArray(vtkStdString* array, vtkIdType size, int save); 00225 virtual void SetVoidArray(void* array, vtkIdType size, int save) 00226 { this->SetArray(static_cast<vtkStdString*>(array), size, save); } 00228 //ETX 00229 00237 unsigned long GetActualMemorySize(); 00238 00240 virtual vtkArrayIterator* NewIterator(); 00241 00246 virtual vtkIdType GetDataSize(); 00247 00248 //BTX 00250 00251 virtual vtkIdType LookupValue(vtkVariant value); 00252 virtual void LookupValue(vtkVariant value, vtkIdList* ids); 00253 vtkIdType LookupValue(vtkStdString value); 00254 void LookupValue(vtkStdString value, vtkIdList* ids); 00255 //ETX 00256 vtkIdType LookupValue(const char* value); 00257 void LookupValue(const char* value, vtkIdList* ids); 00259 00266 virtual void DataChanged(); 00267 00271 virtual void DataElementChanged(vtkIdType id); 00272 00276 virtual void ClearLookup(); 00277 00278 protected: 00279 vtkStringArray(vtkIdType numComp=1); 00280 ~vtkStringArray(); 00281 00282 vtkStdString* Array; // pointer to data 00283 vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data 00284 00285 int SaveUserArray; 00286 00287 private: 00288 vtkStringArray(const vtkStringArray&); // Not implemented. 00289 void operator=(const vtkStringArray&); // Not implemented. 00290 00291 //BTX 00292 vtkStringArrayLookup* Lookup; 00293 void UpdateLookup(); 00294 //ETX 00295 }; 00296 00297 00298 00299 #endif