XML format for a file that only contains points?

This should be an incredibly simple question, but I can’t get this to work. What is wrong with the XML file below such that I can’t plot the the points as XYZ in ParaView?

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="8" NumberOfCells="0">
      <PointData>
      </PointData>
      <CellData>
      </CellData>
      <Points>
        <DataArray type="Float64" Name="Points" NumberOfComponents="3" format="ascii" RangeMin="0" RangeMax="1">
            0 0 0
			1 0 0
			1 1 0
			0 1 0
			0 0 1
			1 0 1
			1 1 1
			0 1 1
        </DataArray>
      </Points>
      <Cells>
      </Cells>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

Thanks!

the bare minimum you would need for a correct definition of the Cells element is the following:

    <Cells>
    <DataArray Name="connectivity"></DataArray>
    <DataArray Name="offsets"></DataArray>
    <DataArray Name="types"></DataArray>
  </Cells>

However, without cell elements, quite a few filters will not be able to operate on your data. The default view representation “Points” will also not work. “Point Gaussian” will work.
After reading your data, you may use a Glyph filter with “2D Glyph” and “Vertex” types to add cell elements.

1 Like

As @jfavre mentioned, you’ll typically also need some ‘cells’.
For the lightest format, you should be targeting a vtp output.
Generating offsets and connectivity is dead easy.

Eg,

<?xml version="1.0"?>
<VTKFile type='PolyData' version='0.1' byte_order='LittleEndian' header_type='UInt64'>
  <PolyData>
    <Piece NumberOfPoints='8' NumberOfVerts='8'>
      <Points>
        <DataArray type="Float64" Name="Points" NumberOfComponents="3" format="ascii">
           ...
        </DataArray>
      </Points>
      <Verts>
        <DataArray Name="offsets">
1 2 3 4 5 6 7 8
        </DataArray>
        <DataArray Name="connectivity">
0 1 2 3 4 5 6 7
        </DataArray>
      </Verts>
    </Piece>
  </PolyData>
</VTKFile>
1 Like

Thanks! Using the @jfavre and @olesenm’s advice I was able to get this to work. I have included the XML text below in case anyone else needs to do this. I needed to add ‘Type=’ to the ‘Vert’ data arrays and include a ‘PointData’ section to get the values associated with the point coordinates:

<?xml version="1.0"?>
<VTKFile type="PolyData" version="0.1" byte_order="LittleEndian" header_type="UInt64">
  <PolyData>
    <Piece NumberOfPoints="8" NumberOfVerts="8">
      <Points>
        <DataArray type="Float64" Name="Coordinate_of_points" NumberOfComponents="3" format="ascii">
            0 0 0
			1 0 0
			1 1 0
			0 1 0
			0 0 1
			1 0 1
			1 1 1
			0 1 1
        </DataArray>
      </Points>
	  <PointData>
		<DataArray type="Float64" Name="Value_at_point" NumberOfComponents="1" format="ascii">
            0.6
			1.1
			1.9
			0.1
			0.9
			1.2
			1.3
			0.3
        </DataArray>
	  </PointData>
      <Verts>
        <DataArray type="Int32" Name="offsets">
			1 2 3 4 5 6 7 8
        </DataArray>
        <DataArray type="Int32" Name="connectivity">
			0 1 2 3 4 5 6 7
        </DataArray>
      </Verts>
    </Piece>
  </PolyData>
</VTKFile>

I’ve marked this one as the solution since it has the working XML text, but credit to @jfavre and @olesenm!

@datathing
FWIW, I generally lump all of my geometry together (Points, Verts, etc) and have the PointData and CellData after. Makes it easier to stream data like that, if you have a writeGeometry() method and later various write field methods.

eg, OpenFOAM vtk lagrangian writer

1 Like