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 "vtkCommonCoreModule.h" // For export macro
39 #include "vtkAbstractArray.h"
40 #include "vtkStdString.h" // needed for vtkStdString definition
41 
42 class vtkStringArrayLookup;
43 
45 {
46 public:
47  static vtkStringArray* New();
49  void PrintSelf(ostream& os, vtkIndent indent);
50 
51  //
52  //
53  // Functions required by vtkAbstractArray
54  //
55  //
56 
58 
60  { return VTK_STRING; }
62 
63  int IsNumeric() { return 0; }
64 
66  void Initialize();
67 
71  int GetDataTypeSize();
72 
75  void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
76 
78  int Resize(vtkIdType numTuples);
79 
85  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
86 
91 
93 
96  virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
99 
101 
104  virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
107 
112 
114 
118  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
119  vtkAbstractArray* source, double* weights);
121 
123 
128  virtual void InterpolateTuple(vtkIdType i,
129  vtkIdType id1, vtkAbstractArray* source1,
130  vtkIdType id2, vtkAbstractArray* source2, double t);
132 
137  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
138 
143  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
144 
147  int Allocate( vtkIdType sz, vtkIdType ext=1000 );
148 
150  vtkStdString &GetValue(vtkIdType id);
151 
152 //BTX
154 
157  { this->Array[id] = value; this->DataChanged(); }
158 //ETX
159  void SetValue(vtkIdType id, const char *value);
161 
163 
165  virtual void SetNumberOfTuples(vtkIdType number)
166  { this->SetNumberOfValues(this->NumberOfComponents* number); }
168 
172  void SetNumberOfValues(vtkIdType number);
173 
174  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
175 
176  int GetNumberOfElementComponents() { return 0; }
177  int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
178 
179 //BTX
181 
182  void InsertValue(vtkIdType id, vtkStdString f);
183 //ETX
184  void InsertValue(vtkIdType id, const char *val);
186 
190 
191 //BTX
193 
195  vtkIdType InsertNextValue(vtkStdString f);
196 //ETX
197  vtkIdType InsertNextValue(const char *f);
199 
200 //BTX
202 
205  vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
206 //ETX
208 
209 //BTX
211 
213  vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
214  void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
215 //ETX
217 
220  void DeepCopy( vtkAbstractArray* aa );
221 
222 
223 //BTX
225 
234  void SetArray(vtkStdString* array, vtkIdType size, int save);
235  virtual void SetVoidArray(void* array, vtkIdType size, int save)
236  { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
237 //ETX
239 
247  unsigned long GetActualMemorySize();
248 
250  virtual vtkArrayIterator* NewIterator();
251 
256  virtual vtkIdType GetDataSize();
257 
259 
261  virtual void LookupValue(vtkVariant value, vtkIdList* ids);
262 //BTX
265 //ETX
266  vtkIdType LookupValue(const char* value);
267  void LookupValue(const char* value, vtkIdList* ids);
269 
276  virtual void DataChanged();
277 
281  virtual void DataElementChanged(vtkIdType id);
282 
286  virtual void ClearLookup();
287 
288 protected:
289  vtkStringArray();
290  ~vtkStringArray();
291 
292  vtkStdString* Array; // pointer to data
293  vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data
294 
296 
297 private:
298  vtkStringArray(const vtkStringArray&); // Not implemented.
299  void operator=(const vtkStringArray&); // Not implemented.
300 
301  //BTX
302  vtkStringArrayLookup* Lookup;
303  void UpdateLookup();
304  //ETX
305 };
306 
307 
308 
309 #endif
void PrintSelf(ostream &os, vtkIndent indent)
vtkIdType GetNumberOfValues()
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
virtual void DataChanged()=0
vtkStdString * GetPointer(vtkIdType id)
virtual void DeepCopy(vtkAbstractArray *da)
Abstract superclass for all arrays.
virtual vtkIdType LookupValue(vtkVariant value)=0
virtual int GetDataTypeSize()=0
vtkStdString * Array
#define VTKCOMMONCORE_EXPORT
virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
a vtkAbstractArray subclass for strings
virtual void SetVoidArray(void *array, vtkIdType size, int save)
int vtkIdType
Definition: vtkType.h:275
virtual void Initialize()=0
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
void SetValue(vtkIdType id, vtkStdString value)
#define VTK_STRING
Definition: vtkType.h:41
virtual vtkIdType GetDataSize()
virtual int Allocate(vtkIdType sz, vtkIdType ext=1000)=0
virtual void ClearLookup()=0
a simple class to control print indentation
Definition: vtkIndent.h:38
list of point or cell ids
Definition: vtkIdList.h:35
virtual void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)=0
virtual int Resize(vtkIdType numTuples)=0
virtual vtkArrayIterator * NewIterator()=0
virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output)
Abstract superclass to iterate over elements in an vtkAbstractArray.
void save(Archiver &ar, const vtkUnicodeString &str, const unsigned int vtkNotUsed(version))
virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, vtkAbstractArray *source, double *weights)=0
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
virtual void SetNumberOfTuples(vtkIdType number)
virtual vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source)=0
StdString::value_type value_type
Definition: vtkStdString.h:51
void * GetVoidPointer(vtkIdType id)
virtual unsigned long GetActualMemorySize()=0
virtual void SetVariantValue(vtkIdType idx, vtkVariant value)=0
static vtkObject * New()
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source)=0
int GetElementComponentSize()
int GetNumberOfElementComponents()