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 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 00095 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source); 00096 00098 00102 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00103 vtkAbstractArray* source, double* weights); 00105 00107 00112 virtual void InterpolateTuple(vtkIdType i, 00113 vtkIdType id1, vtkAbstractArray* source1, 00114 vtkIdType id2, vtkAbstractArray* source2, double t); 00116 00121 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); 00122 00127 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00128 00131 int Allocate( vtkIdType sz, vtkIdType ext=1000 ); 00132 00134 vtkStdString &GetValue(vtkIdType id); 00135 00136 //BTX 00138 00140 void SetValue(vtkIdType id, vtkStdString value) 00141 { this->Array[id] = value; this->DataChanged(); } 00142 //ETX 00143 void SetValue(vtkIdType id, const char *value); 00145 00147 00149 virtual void SetNumberOfTuples(vtkIdType number) 00150 { this->SetNumberOfValues(this->NumberOfComponents* number); } 00152 00156 void SetNumberOfValues(vtkIdType number); 00157 00158 vtkIdType GetNumberOfValues() { return this->MaxId + 1; } 00159 00160 int GetNumberOfElementComponents() { return 0; } 00161 int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); } 00162 00163 //BTX 00165 00166 void InsertValue(vtkIdType id, vtkStdString f); 00167 //ETX 00168 void InsertValue(vtkIdType id, const char *val); 00170 00173 void SetVariantValue(vtkIdType idx, vtkVariant value); 00174 00175 //BTX 00177 00179 vtkIdType InsertNextValue(vtkStdString f); 00180 //ETX 00181 vtkIdType InsertNextValue(const char *f); 00183 00184 //BTX 00186 00189 vtkStdString* WritePointer(vtkIdType id, vtkIdType number); 00190 //ETX 00192 00193 //BTX 00195 00197 vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; } 00198 void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); } 00199 //ETX 00201 00204 void DeepCopy( vtkAbstractArray* aa ); 00205 00206 00207 //BTX 00209 00218 void SetArray(vtkStdString* array, vtkIdType size, int save); 00219 virtual void SetVoidArray(void* array, vtkIdType size, int save) 00220 { this->SetArray(static_cast<vtkStdString*>(array), size, save); } 00221 //ETX 00223 00231 unsigned long GetActualMemorySize(); 00232 00234 virtual vtkArrayIterator* NewIterator(); 00235 00240 virtual vtkIdType GetDataSize(); 00241 00243 00244 virtual vtkIdType LookupValue(vtkVariant value); 00245 virtual void LookupValue(vtkVariant value, vtkIdList* ids); 00246 //BTX 00247 vtkIdType LookupValue(vtkStdString value); 00248 void LookupValue(vtkStdString value, vtkIdList* ids); 00249 //ETX 00250 vtkIdType LookupValue(const char* value); 00251 void LookupValue(const char* value, vtkIdList* ids); 00253 00260 virtual void DataChanged(); 00261 00265 virtual void DataElementChanged(vtkIdType id); 00266 00270 virtual void ClearLookup(); 00271 00272 protected: 00273 vtkStringArray(vtkIdType numComp=1); 00274 ~vtkStringArray(); 00275 00276 vtkStdString* Array; // pointer to data 00277 vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data 00278 00279 int SaveUserArray; 00280 00281 private: 00282 vtkStringArray(const vtkStringArray&); // Not implemented. 00283 void operator=(const vtkStringArray&); // Not implemented. 00284 00285 //BTX 00286 vtkStringArrayLookup* Lookup; 00287 void UpdateLookup(); 00288 //ETX 00289 }; 00290 00291 00292 00293 #endif