VTK
vtkStringArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkStringArray.h
5  Language: C++
6 
7  Copyright 2004 Sandia Corporation.
8  Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9  license for use of this work by or on behalf of the
10  U.S. Government. Redistribution and use in source and binary forms, with
11  or without modification, are permitted provided that this Notice and any
12  statement of authorship are reproduced on all copies.
13 
14 =========================================================================*/
15 
35 #ifndef __vtkStringArray_h
36 #define __vtkStringArray_h
37 
38 #include "vtkAbstractArray.h"
39 #include "vtkStdString.h" // needed for vtkStdString definition
40 
41 class vtkStringArrayLookup;
42 
44 {
45 public:
46  static vtkStringArray* New();
48  void PrintSelf(ostream& os, vtkIndent indent);
49 
50  //
51  //
52  // Functions required by vtkAbstractArray
53  //
54  //
55 
57 
59  { return VTK_STRING; }
61 
62  int IsNumeric() { return 0; }
63 
65  void Initialize();
66 
70  int GetDataTypeSize();
71 
74  void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
75 
77  int Resize(vtkIdType numTuples);
78 
84  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
85 
90 
95 
97 
101  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
102  vtkAbstractArray* source, double* weights);
104 
106 
111  virtual void InterpolateTuple(vtkIdType i,
112  vtkIdType id1, vtkAbstractArray* source1,
113  vtkIdType id2, vtkAbstractArray* source2, double t);
115 
120  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
121 
126  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
127 
130  int Allocate( vtkIdType sz, vtkIdType ext=1000 );
131 
133  vtkStdString &GetValue(vtkIdType id);
134 
135 //BTX
137 
139  void SetValue(vtkIdType id, vtkStdString value)
140  { this->Array[id] = value; this->DataChanged(); }
141 //ETX
142  void SetValue(vtkIdType id, const char *value);
144 
146 
148  virtual void SetNumberOfTuples(vtkIdType number)
149  { this->SetNumberOfValues(this->NumberOfComponents* number); }
151 
155  void SetNumberOfValues(vtkIdType number);
156 
157  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
158 
159  int GetNumberOfElementComponents() { return 0; }
160  int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
161 
162 //BTX
164 
165  void InsertValue(vtkIdType id, vtkStdString f);
166 //ETX
167  void InsertValue(vtkIdType id, const char *val);
169 
173 
174 //BTX
176 
178  vtkIdType InsertNextValue(vtkStdString f);
179 //ETX
180  vtkIdType InsertNextValue(const char *f);
182 
183 //BTX
185 
188  vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
189 //ETX
191 
192 //BTX
194 
196  vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
197  void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
198 //ETX
200 
203  void DeepCopy( vtkAbstractArray* aa );
204 
205 
206 //BTX
208 
217  void SetArray(vtkStdString* array, vtkIdType size, int save);
218  virtual void SetVoidArray(void* array, vtkIdType size, int save)
219  { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
220 //ETX
222 
230  unsigned long GetActualMemorySize();
231 
233  virtual vtkArrayIterator* NewIterator();
234 
239  virtual vtkIdType GetDataSize();
240 
242 
244  virtual void LookupValue(vtkVariant value, vtkIdList* ids);
245 //BTX
248 //ETX
249  vtkIdType LookupValue(const char* value);
250  void LookupValue(const char* value, vtkIdList* ids);
252 
259  virtual void DataChanged();
260 
264  virtual void DataElementChanged(vtkIdType id);
265 
269  virtual void ClearLookup();
270 
271 protected:
272  vtkStringArray(vtkIdType numComp=1);
273  ~vtkStringArray();
274 
275  vtkStdString* Array; // pointer to data
276  vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data
277 
279 
280 private:
281  vtkStringArray(const vtkStringArray&); // Not implemented.
282  void operator=(const vtkStringArray&); // Not implemented.
283 
284  //BTX
285  vtkStringArrayLookup* Lookup;
286  void UpdateLookup();
287  //ETX
288 };
289 
290 
291 
292 #endif