I have been trying to include string attributes into the CellData of a StructuredGrid cell using vtk's XML format. I want to include an attribute named "Container" with value "AoS" for the cell defined using following xml code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<VTKFile byte_order="LittleEndian" type="StructuredGrid" version="0.1">
<StructuredGrid WholeExtent="0 1 0 1 0 1">
<Piece Extent="0 1 0 1 0 1">
<PointData/>
<CellData Scalars="DomainId" Fields="Container">
<DataArray type="Int32" Name="DomainId" format="ascii">
0
</DataArray>
<DataArray type="String" Name="Container" format="ascii">
AoS
</DataArray>
</CellData>
<Points>
<DataArray type="Float32" NumberOfComponents="3" format="ascii">
0 0 0
2 0 0
0 4 0
2 4 0
0 0 3
2 0 3
0 4 3
2 4 3
</DataArray>
</Points>
</Piece>
</StructuredGrid>
</VTKFile>
When trying to display this cell in Paraview, I am getting following error: Cannot read cell data array "Container" from PointData in piece 0. The data array in the element is too short
The CellData attribute "Fields" I used in the xml code was just a wild guess and may not even exist. Moving the Container to "Scalars" does not work and I could not find another appropriate CellData attribute to put it in.
What I want to see in Paraviews SpreadsheetView is something like this: Example created using legacy vtk format
I have tried to solve this for several hours. What I don't know is, which CellData attribute is designated for strings, if DataArray is the right object to use and if yes, which attributes it requires. Alternatively I tried using StringArray instead of DataArray but could not make it work either.
I also tried to use FieldData to include the string attributes but again without any success.
Thanks for any help in advance!
You should write your string as a null-terminated list of ascii char:
<CellData>
<Array type="String" Name="Container" format="ascii">
65 111 83 0
</Array>
</CellData>