protected void writeData(XMLStreamWriter writer, Grid<?> s) throws XMLStreamException {
		writer.writeStartDocument();
		writer.writeStartElement("VTKFile");
		writer.writeAttribute("type", "ImageData");
		writer.writeStartElement("ImageData");
		writer.writeAttribute("WholeExtent", "0 " + (s.getRange(0)) + " 0 " + (s.getRange(1)) + " 0 1");
		writer.writeAttribute("Origin", "0 0 0");
		writer.writeAttribute("Spacing", "1 1 1");
		writer.writeStartElement("Piece");
		writer.writeAttribute("Extent", "0 " + (s.getRange(0)) + " 0 " + (s.getRange(1)) + " 0 1");
		writer.writeStartElement("PointData");
		writer.writeEndElement();
		writer.writeStartElement("CellData");
		writer.writeStartElement("DataArray");
		writer.writeAttribute("Name", "CellState");
		writer.writeAttribute("type", "Int8");
		writer.writeAttribute("name", "cells");
		writer.writeAttribute("format", "ascii");
		for (int i = 0; i < s.getRange(1); i++) {
			for (int j = 0; j < s.getRange(0); j++) {
				if (s.getCell(new CellPos(j, i)) instanceof DiscreteCell<?>) {
					writer.writeCharacters((((DiscreteCell<?>) (s.getCell(new CellPos(j, i)))).get()+1) + " ");
				}
				else if (s.getCell(new CellPos(j, i)) instanceof RealCell<?>) {
					writer.writeCharacters((((RealCell<?>) (s.getCell(new CellPos(j, i)))).get()+1) + " ");
				}
			}
			writer.writeCharacters("\n");
		}			
		writer.writeEndDocument();
	}