vtkStringArray Class Reference

#include <vtkStringArray.h>

Inheritance diagram for vtkStringArray:

Inheritance graph
[legend]
Collaboration diagram for vtkStringArray:

Collaboration graph
[legend]
List of all members.

Detailed Description

Subclass of vtkAbstractArray that holds vtkStdStrings.

Date
2005/11/08 16:08:45
Revision
1.3.6.1

Points and cells may sometimes have associated data that are stored as strings, e.g. many information visualization projects. This class provides a reasonably clean way to store and access those.

Warning:
Wrapping support for the Set/Get/Insert methods is a little strange. The Tcl/Python/Java wrappers treat vtkStdString as const char * right now instead of dealing with native strings. This is why there are two versions of every Set method: one (which you should use in C++ code) taking a vtkStdString argument and one (used by the wrapper) taking a const char * argument.

If you'd like to look into modifying the wrappers to handle this properly, go right ahead...

Thanks:
Andy Wilson (atwilso@sandia.gov) wrote this class.
Tests:
vtkStringArray (Tests)

Definition at line 54 of file vtkStringArray.h.

Public Types

typedef vtkAbstractArray Superclass

Public Member Functions

virtual const char * GetClassName ()
virtual int IsA (const char *type)
void PrintSelf (ostream &os, vtkIndent indent)
bool IsNumeric ()
void Initialize ()
int GetDataTypeSize ()
void Squeeze ()
int Resize (vtkIdType numTuples)
void GetValues (vtkIdList *ptIds, vtkAbstractArray *output)
void GetValues (vtkIdType p1, vtkIdType p2, vtkAbstractArray *output)
void CopyValue (int toIndex, int fromIndex, vtkAbstractArray *sourceArray)
int Allocate (vtkIdType sz, vtkIdType ext=1000)
vtkStdStringGetValue (vtkIdType id)
void SetValue (vtkIdType id, const char *value)
void SetNumberOfValues (vtkIdType number)
int GetNumberOfValues ()
int GetNumberOfElementComponents ()
int GetElementComponentSize ()
void InsertValue (vtkIdType id, vtkStdString f)
void InsertValue (vtkIdType id, const char *val)
vtkIdType InsertNextValue (vtkStdString f)
vtkIdType InsertNextValue (const char *f)
vtkStdStringWritePointer (vtkIdType id, vtkIdType number)
void DeepCopy (vtkAbstractArray *aa)
unsigned long GetActualMemorySize ()
void ConvertToContiguous (vtkDataArray **Data, vtkIdTypeArray **Offsets)
void ConvertFromContiguous (vtkDataArray *Data, vtkIdTypeArray *Offsets)
int GetDataType ()
void SetValue (vtkIdType id, vtkStdString value)
vtkStdStringGetPointer (vtkIdType id)
void * GetVoidPointer (vtkIdType id)
void SetArray (vtkStdString *array, vtkIdType size, int save)
void SetVoidArray (void *array, vtkIdType size, int save)

Static Public Member Functions

static vtkStringArrayNew ()
static int IsTypeOf (const char *type)
static vtkStringArraySafeDownCast (vtkObject *o)

Protected Member Functions

 vtkStringArray (vtkIdType numComp=1)
 ~vtkStringArray ()
vtkStdStringResizeAndExtend (vtkIdType sz)

Protected Attributes

vtkStdStringArray
int SaveUserArray


Member Typedef Documentation

typedef vtkAbstractArray vtkStringArray::Superclass

Reimplemented from vtkAbstractArray.

Definition at line 58 of file vtkStringArray.h.


Constructor & Destructor Documentation

vtkStringArray::vtkStringArray ( vtkIdType  numComp = 1  )  [protected]

vtkStringArray::~vtkStringArray (  )  [protected]


Member Function Documentation

static vtkStringArray* vtkStringArray::New (  )  [static]

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

virtual const char* vtkStringArray::GetClassName (  )  [virtual]

Reimplemented from vtkAbstractArray.

static int vtkStringArray::IsTypeOf ( const char *  type  )  [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkAbstractArray.

virtual int vtkStringArray::IsA ( const char *  type  )  [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeRevisionMacro found in vtkSetGet.h.

Reimplemented from vtkAbstractArray.

static vtkStringArray* vtkStringArray::SafeDownCast ( vtkObject o  )  [static]

Reimplemented from vtkAbstractArray.

void vtkStringArray::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkAbstractArray.

int vtkStringArray::GetDataType (  )  [inline, virtual]

Get the data type.

Implements vtkAbstractArray.

Definition at line 69 of file vtkStringArray.h.

References VTK_STRING.

bool vtkStringArray::IsNumeric (  )  [inline, virtual]

This method is here to make backward compatibility easier. It must return true if and only if an array contains numeric data.

Implements vtkAbstractArray.

Definition at line 73 of file vtkStringArray.h.

void vtkStringArray::Initialize (  )  [virtual]

Release storage and reset array to initial state.

Implements vtkAbstractArray.

int vtkStringArray::GetDataTypeSize (  )  [virtual]

Return the size of the data type. WARNING: This may not mean what you expect with strings. It will return sizeof(vtkstd::string) and not take into account the data included in any particular string.

Implements vtkAbstractArray.

void vtkStringArray::Squeeze (  )  [inline, virtual]

Free any unnecessary memory. Resize object to just fit data requirement. Reclaims extra memory.

Implements vtkAbstractArray.

Definition at line 85 of file vtkStringArray.h.

int vtkStringArray::Resize ( vtkIdType  numTuples  )  [virtual]

Resize the array while conserving the data.

Implements vtkAbstractArray.

void vtkStringArray::GetValues ( vtkIdList ptIds,
vtkAbstractArray output 
) [virtual]

Given a list of indices, return an array of values. You must insure that the output array has been previously allocated with enough space to hold the data and that the types match sufficiently to allow conversion (if necessary).

Implements vtkAbstractArray.

void vtkStringArray::GetValues ( vtkIdType  p1,
vtkIdType  p2,
vtkAbstractArray output 
) [virtual]

Get the values for the range of indices specified (i.e., p1->p2 inclusive). You must insure that the output array has been previously allocated with enough space to hold the data and that the type of the output array is compatible with the type of this array.

Implements vtkAbstractArray.

void vtkStringArray::CopyValue ( int  toIndex,
int  fromIndex,
vtkAbstractArray sourceArray 
) [virtual]

Copy a value from a given source array into this array.

Implements vtkAbstractArray.

int vtkStringArray::Allocate ( vtkIdType  sz,
vtkIdType  ext = 1000 
) [virtual]

Allocate memory for this array. Delete old storage only if necessary. Note that ext is no longer used.

Implements vtkAbstractArray.

vtkStdString& vtkStringArray::GetValue ( vtkIdType  id  ) 

Get the data at a particular index.

void vtkStringArray::SetValue ( vtkIdType  id,
vtkStdString  value 
) [inline]

Set the data at a particular index. Does not do range checking. Make sure you use the method SetNumberOfValues() before inserting data. BTX

Definition at line 116 of file vtkStringArray.h.

void vtkStringArray::SetValue ( vtkIdType  id,
const char *  value 
)

void vtkStringArray::SetNumberOfValues ( vtkIdType  number  ) 

Specify the number of values for this object to hold. Does an allocation as well as setting the MaxId ivar. Used in conjunction with SetValue() method for fast insertion.

int vtkStringArray::GetNumberOfValues (  )  [inline]

Definition at line 127 of file vtkStringArray.h.

int vtkStringArray::GetNumberOfElementComponents (  )  [inline, virtual]

Return the number of components in a single element of the array. For vtkDataArray and its subclasses, this is the number of components in a tuple. Arrays with variable-length elements (such as vtkStringArray and vtkCellArray) should return 0.

Implements vtkAbstractArray.

Definition at line 129 of file vtkStringArray.h.

int vtkStringArray::GetElementComponentSize (  )  [inline, virtual]

Return the size, in bytes, of the lowest-level element of an array. For vtkDataArray and subclasses this is the size of the data type. For vtkStringArray, this is sizeof(vtkStdString::value_type), which winds up being sizeof(char).

Implements vtkAbstractArray.

Definition at line 130 of file vtkStringArray.h.

void vtkStringArray::InsertValue ( vtkIdType  id,
vtkStdString  f 
)

Insert data at a specified position in the array. BTX

void vtkStringArray::InsertValue ( vtkIdType  id,
const char *  val 
)

vtkIdType vtkStringArray::InsertNextValue ( vtkStdString  f  ) 

Insert data at the end of the array. Return its location in the array. BTX

vtkIdType vtkStringArray::InsertNextValue ( const char *  f  ) 

vtkStdString* vtkStringArray::WritePointer ( vtkIdType  id,
vtkIdType  number 
)

Get the address of a particular data index. Make sure data is allocated for the number of items requested. Set MaxId according to the number of data values requested.

vtkStdString* vtkStringArray::GetPointer ( vtkIdType  id  )  [inline]

Get the address of a particular data index. Performs no checks to verify that the memory has been allocated etc.

Definition at line 154 of file vtkStringArray.h.

void* vtkStringArray::GetVoidPointer ( vtkIdType  id  )  [inline, virtual]

Get the address of a particular data index. Performs no checks to verify that the memory has been allocated etc.

Implements vtkAbstractArray.

Definition at line 155 of file vtkStringArray.h.

void vtkStringArray::DeepCopy ( vtkAbstractArray aa  )  [virtual]

Deep copy of another string array. Will complain and change nothing if the array passed in is not a vtkStringArray.

Implements vtkAbstractArray.

void vtkStringArray::SetArray ( vtkStdString array,
vtkIdType  size,
int  save 
)

This method lets the user specify data to be held by the array. The array argument is a pointer to the data. size is the size of the array supplied by the user. Set save to 1 to keep the class from deleting the array when it cleans up or reallocates memory. The class uses the actual array provided; it does not copy the data from the suppled array.

void vtkStringArray::SetVoidArray ( void *  array,
vtkIdType  size,
int  save 
) [inline]

This method lets the user specify data to be held by the array. The array argument is a pointer to the data. size is the size of the array supplied by the user. Set save to 1 to keep the class from deleting the array when it cleans up or reallocates memory. The class uses the actual array provided; it does not copy the data from the suppled array.

Definition at line 173 of file vtkStringArray.h.

unsigned long vtkStringArray::GetActualMemorySize (  )  [virtual]

Return the memory in kilobytes consumed by this data array. Used to support streaming and reading/writing data. The value returned is guaranteed to be greater than or equal to the memory required to actually represent the data represented by this object. The information returned is valid only after the pipeline has been updated. This function takes into account the size of the contents of the strings as well as the string containers themselves.

Implements vtkAbstractArray.

void vtkStringArray::ConvertToContiguous ( vtkDataArray **  Data,
vtkIdTypeArray **  Offsets 
) [virtual]

Flatten an arbitrary array into two separate numeric arrays. The first contains all the data in the source array; the second, the index of the end of each element. This function is meant to assist reading and writing arrays with variable-length elements such as vtkStringArray and vtkCellArray. The arrays will be created within the method body: the caller is responsible for deleting them when no longer needed.

For example, a string array with the elements "This" "Is" "A" "Test" would be converted into the following two arrays: Data: (unsigned char array) ThisIsATest Offsets: 3 5 6 10 vtkDataArray also implements this method, although in practice you shouldn't need it. It ignores the offsets array and takes its tuple-size information from the data array.

Implements vtkAbstractArray.

void vtkStringArray::ConvertFromContiguous ( vtkDataArray Data,
vtkIdTypeArray Offsets 
) [virtual]

This is the inverse of ConvertToContiguous(), above.

Implements vtkAbstractArray.

vtkStdString* vtkStringArray::ResizeAndExtend ( vtkIdType  sz  )  [protected]


Member Data Documentation

vtkStdString* vtkStringArray::Array [protected]

Definition at line 194 of file vtkStringArray.h.

int vtkStringArray::SaveUserArray [protected]

Definition at line 197 of file vtkStringArray.h.


The documentation for this class was generated from the following file:
Generated on Tue Nov 14 00:28:38 2006 for VTK by  doxygen 1.5.1