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 
32 #ifndef vtkStringArray_h
33 #define vtkStringArray_h
34 
35 #include "vtkCommonCoreModule.h" // For export macro
36 #include "vtkAbstractArray.h"
37 #include "vtkStdString.h" // needed for vtkStdString definition
38 
39 class vtkStringArrayLookup;
40 
42 {
43 public:
44  static vtkStringArray* New();
46  void PrintSelf(ostream& os, vtkIndent indent);
47 
48  //
49  //
50  // Functions required by vtkAbstractArray
51  //
52  //
53 
55 
57  { return VTK_STRING; }
59 
60  int IsNumeric() { return 0; }
61 
63  void Initialize();
64 
68  int GetDataTypeSize();
69 
72  void Squeeze() { this->ResizeAndExtend (this->MaxId+1); }
73 
75  int Resize(vtkIdType numTuples);
76 
82  virtual void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source);
83 
88 
90 
93  virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
96 
98 
101  virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
104 
109 
111 
115  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
116  vtkAbstractArray* source, double* weights);
118 
120 
125  virtual void InterpolateTuple(vtkIdType i,
126  vtkIdType id1, vtkAbstractArray* source1,
127  vtkIdType id2, vtkAbstractArray* source2, double t);
129 
134  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
135 
140  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
141 
144  int Allocate( vtkIdType sz, vtkIdType ext=1000 );
145 
147  vtkStdString &GetValue(vtkIdType id);
148 
149 //BTX
151 
154  { this->Array[id] = value; this->DataChanged(); }
155 //ETX
156  void SetValue(vtkIdType id, const char *value);
158 
160 
162  virtual void SetNumberOfTuples(vtkIdType number)
163  { this->SetNumberOfValues(this->NumberOfComponents* number); }
165 
169  void SetNumberOfValues(vtkIdType number);
170 
171  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
172 
173  int GetNumberOfElementComponents() { return 0; }
174  int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
175 
176 //BTX
178 
179  void InsertValue(vtkIdType id, vtkStdString f);
180 //ETX
181  void InsertValue(vtkIdType id, const char *val);
183 
187 
191 
192 //BTX
194 
196  vtkIdType InsertNextValue(vtkStdString f);
197 //ETX
198  vtkIdType InsertNextValue(const char *f);
200 
201 //BTX
203 
206  vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
207 //ETX
209 
210 //BTX
212 
214  vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
215  void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
216 //ETX
218 
221  void DeepCopy( vtkAbstractArray* aa );
222 
223 
224 //BTX
226 
235  void SetArray(vtkStdString* array, vtkIdType size, int save);
236  virtual void SetVoidArray(void* array, vtkIdType size, int save)
237  { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
238 //ETX
240 
248  unsigned long GetActualMemorySize();
249 
251  virtual vtkArrayIterator* NewIterator();
252 
257  virtual vtkIdType GetDataSize();
258 
260 
262  virtual void LookupValue(vtkVariant value, vtkIdList* ids);
263 //BTX
266 //ETX
267  vtkIdType LookupValue(const char* value);
268  void LookupValue(const char* value, vtkIdList* ids);
270 
277  virtual void DataChanged();
278 
282  virtual void DataElementChanged(vtkIdType id);
283 
287  virtual void ClearLookup();
288 
289 protected:
290  vtkStringArray();
291  ~vtkStringArray();
292 
293  vtkStdString* Array; // pointer to data
294  vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data
295 
297 
298 private:
299  vtkStringArray(const vtkStringArray&); // Not implemented.
300  void operator=(const vtkStringArray&); // Not implemented.
301 
302  //BTX
303  vtkStringArrayLookup* Lookup;
304  void UpdateLookup();
305  //ETX
306 };
307 
308 
309 
310 #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)
virtual void InsertVariantValue(vtkIdType idx, vtkVariant value)=0
int vtkIdType
Definition: vtkType.h:247
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()