[vtk-developers] Re: String Array Support in VTK -- update

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri Jan 6 14:46:29 EST 2006


Just a side note:

If you are having trouble compiling code that uses vtkDataArray (since
the StringArray related commits), try including vtkDataArray.h if it's
not already included. Earlier, vtkFieldData.h included vtkDataArray.h --
 which is not the case anymore.

Utkarsh.

Utkarsh Ayachit wrote:
> Update on String Array support.
> 
> I've checked in the code to intergrate vtkStringArrays with the
> vtkDataArrays. The only change from my earlier email to this regard is
> that the methods from vtkFieldData, that were claimed to be removed, are
> now flagged as legacy and will be removed following the next release.
> 
> Utkarsh.
> 
> Utkarsh Ayachit wrote:
> 
>>Hey folks,
>>
>>Currently, Sandia and Kitware are working on intergrating the support
>>for string arrays with the main stream data arrays, so that string
>>arrays can be passed around are field/point/cell data and used by
>>filters etc. This email summarizes the changes that we are making to the
>>present data array/field data/readers/writes. The changes will be
>>committed to the main CVS trunk by this weekend. Your
>>suggestions/objections are welcome, as always.
>>
>>* vtkDataArray now has a new superclass: vtkAbstractArray.
>>vtkAbstractArray provides type-agnostic API to access array elements.
>>vtkDataArray provides a double API to access values -- such an API is
>>deliberately missing from vtkAbstractArray, since arrays like string
>>arrays are not castable to doubles.
>>
>>* vtkAbstractArray has the notion of components/tuples, but does not
>>make any assumptions about the arragment of these. It's up to the
>>concrete subclasses how the data is represented in memory.
>>
>>* vtkFieldData used to provide tuple API to get/set values from data
>>arrays contained in it. However, now that FieldData can have arrays that
>>are not vtkDataArrays, this API is not longer valid. The following are
>>the methods that are no longer available:
>>  double* GetTuple(const vtkIdType);
>>  void SetTuple(const vtkIdType i, const double* tuple);
>>  void GetTuple(const vtkIdType i, double* tuple);
>>  void InsertTuple(const vtkIdType i, const double* tuple);
>>  void InsertNextTuple(cons double*);
>>  double GetComponent(const vtkIdType i, const int j);
>>  void SetComponent(const vtkIdType i, const int j, const double c);
>>  void InsertComponent(const vtkIdType i, const int j, const double c);
>>However, new API is provided to copy tuples arround from one field data
>>to another using:
>>  void SetTuple(const vtkIdType i, const vtkIdType j, vtkFieldData* source);
>>  void InsertTuple(const vtkIdType i, const vtkIdType j, vtkFieldData*
>>source);
>>  vtkIdType InsertNextTuple(const vtkIdType j, vtkFieldData* source);
>>
>>* vtkFieldData provide a vtkDataArray* GetArray(int index) to retrieve
>>arrays in the field data. This function can will now return a NULL if
>>the array at the given index is not a data array. It provides
>>  vtkAbstractArray* GetAbstractArray(int index);
>>to retrieve an array even if it isn't a vtkDataArray.
>>
>>* Since vtkFieldData can contain arrays that aren't subclasses of
>>vtkDataArray, so can vtkDataSetAttributes. However, an attribute can
>>only be a vtkDataArray subclass i.e. one cannot set a vtkStringArray as
>>the SCALARS array for a Point Data, for example.
>>
>>* String Array IO is only supported in XML file formats. If deemed
>>important, support may be added for lecacy file formats.
>>
>>*** Array Iterators ***
>>
>>Another addition to the VTK Arrays, is the notion of Array Iterator. A
>>vtkArrayIterator subclass is be provided for every vtkAbstractArray
>>subclass. The iterator is a random access iterator. The iterators are
>>not available in any of the wrapped languages, however, in C++ they can
>>be used to write templatized code to processes the array values without
>>any implicit type conversion and consequent loss of precision.
>>vtkArrayIteratorTemplateMacro is provided to simply switching between
>>different types of the arrays. Examples of use of this macro and the
>>iterators can be found in vtkXMLWriter.cxx / vtkXMLDataReader.cxx /
>>vtkXMLStructuredDataReader.cxx.
>>
>>Utkarsh.
>>
> 
> 
> 




More information about the vtk-developers mailing list