VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
44 class VTKCOMMONCORE_EXPORT vtkStringArray : public vtkAbstractArray
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 
96 
98 
102  virtual void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
103  vtkAbstractArray* source, double* weights);
105 
107 
112  virtual void InterpolateTuple(vtkIdType i,
113  vtkIdType id1, vtkAbstractArray* source1,
114  vtkIdType id2, vtkAbstractArray* source2, double t);
116 
121  virtual void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output);
122 
127  virtual void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output);
128 
131  int Allocate( vtkIdType sz, vtkIdType ext=1000 );
132 
134  vtkStdString &GetValue(vtkIdType id);
135 
136 //BTX
138 
141  { this->Array[id] = value; this->DataChanged(); }
142 //ETX
143  void SetValue(vtkIdType id, const char *value);
145 
147 
149  virtual void SetNumberOfTuples(vtkIdType number)
150  { this->SetNumberOfValues(this->NumberOfComponents* number); }
152 
156  void SetNumberOfValues(vtkIdType number);
157 
158  vtkIdType GetNumberOfValues() { return this->MaxId + 1; }
159 
160  int GetNumberOfElementComponents() { return 0; }
161  int GetElementComponentSize() { return static_cast<int>(sizeof(vtkStdString::value_type)); }
162 
163 //BTX
165 
166  void InsertValue(vtkIdType id, vtkStdString f);
167 //ETX
168  void InsertValue(vtkIdType id, const char *val);
170 
173  void SetVariantValue(vtkIdType idx, vtkVariant value);
174 
175 //BTX
177 
179  vtkIdType InsertNextValue(vtkStdString f);
180 //ETX
181  vtkIdType InsertNextValue(const char *f);
183 
184 //BTX
186 
189  vtkStdString* WritePointer(vtkIdType id, vtkIdType number);
190 //ETX
192 
193 //BTX
195 
197  vtkStdString* GetPointer(vtkIdType id) { return this->Array + id; }
198  void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
199 //ETX
201 
204  void DeepCopy( vtkAbstractArray* aa );
205 
206 
207 //BTX
209 
218  void SetArray(vtkStdString* array, vtkIdType size, int save);
219  virtual void SetVoidArray(void* array, vtkIdType size, int save)
220  { this->SetArray(static_cast<vtkStdString*>(array), size, save); }
221 //ETX
223 
231  unsigned long GetActualMemorySize();
232 
234  virtual vtkArrayIterator* NewIterator();
235 
240  virtual vtkIdType GetDataSize();
241 
243 
244  virtual vtkIdType LookupValue(vtkVariant value);
245  virtual void LookupValue(vtkVariant value, vtkIdList* ids);
246 //BTX
248  void LookupValue(vtkStdString value, vtkIdList* ids);
249 //ETX
250  vtkIdType LookupValue(const char* value);
251  void LookupValue(const char* value, vtkIdList* ids);
253 
260  virtual void DataChanged();
261 
265  virtual void DataElementChanged(vtkIdType id);
266 
270  virtual void ClearLookup();
271 
272 protected:
273  vtkStringArray(vtkIdType numComp=1);
274  ~vtkStringArray();
275 
276  vtkStdString* Array; // pointer to data
277  vtkStdString* ResizeAndExtend(vtkIdType sz); // function to resize data
278 
280 
281 private:
282  vtkStringArray(const vtkStringArray&); // Not implemented.
283  void operator=(const vtkStringArray&); // Not implemented.
284 
285  //BTX
286  vtkStringArrayLookup* Lookup;
287  void UpdateLookup();
288  //ETX
289 };
290 
291 
292 
293 #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
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:268
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()
int GetElementComponentSize()
int GetNumberOfElementComponents()