VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkStringArray.h,v $ 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 00048 #ifndef __vtkStringArray_h 00049 #define __vtkStringArray_h 00050 00051 #include "vtkAbstractArray.h" 00052 #include "vtkStdString.h" // needed for vtkStdString definition 00053 00054 class vtkStringArrayLookup; 00055 00056 class VTK_COMMON_EXPORT vtkStringArray : public vtkAbstractArray 00057 { 00058 public: 00059 static vtkStringArray* New(); 00060 vtkTypeRevisionMacro(vtkStringArray,vtkAbstractArray); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 00063 // 00064 // 00065 // Functions required by vtkAbstractArray 00066 // 00067 // 00068 00070 00071 int GetDataType() 00072 { return VTK_STRING; } 00074 00075 int IsNumeric() { return 0; } 00076 00078 void Initialize(); 00079 00083 int GetDataTypeSize(); 00084 00087 void Squeeze() { this->ResizeAndExtend (this->MaxId+1); } 00088 00090 int Resize(vtkIdType numTuples); 00091 00097 virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00098 00102 virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source); 00103 00107 virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray* source); 00108 00110 00114 virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, 00115 vtkAbstractArray* source, double* weights); 00117 00119 00124 virtual void InterpolateTuple(vtkIdType i, 00125 vtkIdType id1, vtkAbstractArray* source1, 00126 vtkIdType id2, vtkAbstractArray* source2, double t); 00128 00133 virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); 00134 00139 virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); 00140 00143 int Allocate( vtkIdType sz, vtkIdType ext=1000 ); 00144 00146 vtkStdString &GetValue(vtkIdType id); 00147 00149 00152 void SetValue(vtkIdType id, vtkStdString value) 00153 { this->Array[id] = value; this->DataChanged(); } 00155 //ETX 00156 void SetValue(vtkIdType id, const char *value); 00157 00159 00161 virtual void SetNumberOfTuples(vtkIdType number) 00162 { this->SetNumberOfValues(this->NumberOfComponents* number); } 00164 00168 void SetNumberOfValues(vtkIdType number); 00169 00170 vtkIdType GetNumberOfValues() { return this->MaxId + 1; } 00171 00172 int GetNumberOfElementComponents() { return 0; } 00173 int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); } 00174 00176 void InsertValue(vtkIdType id, vtkStdString f); 00177 00179 void InsertVariantValue(vtkIdType idx, vtkVariant value); 00180 //ETX 00181 void InsertValue(vtkIdType id, const char *val); 00182 00185 vtkIdType InsertNextValue(vtkStdString f); 00186 //ETX 00187 vtkIdType InsertNextValue(const char *f); 00188 00189 //BTX 00193 vtkStdString* WritePointer(vtkIdType id, vtkIdType number); 00194 //ETX 00195 00196 //BTX 00198 00200 vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; } 00201 void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); } 00203 //ETX 00204 00207 void DeepCopy( vtkAbstractArray* aa ); 00208 00209 00210 //BTX 00212 00221 void SetArray(vtkStdString* array, vtkIdType size, int save); 00222 virtual void SetVoidArray(void* array, vtkIdType size, int save) 00223 { this->SetArray(static_cast<vtkStdString*>(array), size, save); } 00225 //ETX 00226 00234 unsigned long GetActualMemorySize(); 00235 00237 virtual vtkArrayIterator* NewIterator(); 00238 00243 virtual vtkIdType GetDataSize(); 00244 00245 //BTX 00247 00248 virtual vtkIdType LookupValue(vtkVariant value); 00249 virtual void LookupValue(vtkVariant value, vtkIdList* ids); 00250 vtkIdType LookupValue(vtkStdString value); 00251 void LookupValue(vtkStdString value, vtkIdList* ids); 00252 //ETX 00253 vtkIdType LookupValue(const char* value); 00254 void LookupValue(const char* value, vtkIdList* ids); 00256 00263 virtual void DataChanged(); 00264 00268 virtual void DataElementChanged(vtkIdType id); 00269 00273 virtual void ClearLookup(); 00274 00275 protected: 00276 vtkStringArray(vtkIdType numComp=1); 00277 ~vtkStringArray(); 00278 00279 vtkStdString* Array; // pointer to data 00280 vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data 00281 00282 int SaveUserArray; 00283 00284 private: 00285 vtkStringArray(const vtkStringArray&); // Not implemented. 00286 void operator=(const vtkStringArray&); // Not implemented. 00287 00288 //BTX 00289 vtkStringArrayLookup* Lookup; 00290 void UpdateLookup(); 00291 //ETX 00292 }; 00293 00294 00295 00296 #endif