# File format for polyhedron unstructured grid data

**URL:** https://discourse.vtk.org/t/file-format-for-polyhedron-unstructured-grid-data/1914
**Category:** Support
**Tags:** file-formats
**Created:** [October 11, 2019, 7:53am UTC](https://discourse.vtk.org/t/file-format-for-polyhedron-unstructured-grid-data/1914 "2019-10-11T07:53:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tkeskita](https://discourse.vtk.org/user_avatar/discourse.vtk.org/tkeskita/32/1757_2.png) [@tkeskita](https://discourse.vtk.org/u/tkeskita)
#### Post date: [October 11, 2019, 7:53am UTC](https://discourse.vtk.org/t/file-format-for-polyhedron-unstructured-grid-data/1914/1 "2019-10-11T07:53:03Z")

</div>

Hello,

I’d like to write an exporter of 3D unstructured volume grids (cells composed of arbitrary shapes of polyhedrons, serial data format) to export the 3D grid to VTK. I guess my options include the XML Unstructured Grid format used by vtkXMLUnstructuredGridReader/Writer (.vtu format) or the legacy VTK file format (.vtk format)? I wonder which approach I should try to take. Looks like XML format supports arbitrary polyhedrons. I think the legacy VTK file format does not, so polyhedrons would need to be decomposed to supported cell types. Therefore XML format seems more promising. Thanks for VTK!

Is there some drawback/limitation for exporting all cell types (tetras, hexes, …) as Polyhedron cell type 42? That would make writing of export routine a bit easier.

---

<div class="post-metadata">

### Author: ![Paolo\_Lampitella](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paolo_lampitella/32/985_2.png) [@Paolo\_Lampitella](https://discourse.vtk.org/u/Paolo_Lampitella)
#### Post date: [November 14, 2019, 10:45am UTC](https://discourse.vtk.org/t/file-format-for-polyhedron-unstructured-grid-data/1914/2 "2019-11-14T10:45:37Z")

</div>

Hi, definitely not an expert here, but I wrote [this small example](https://discourse.vtk.org/uploads/short-url/nYEcx9dmnKyhdNQBRk2nWTMmucq.gz) (1.5 KB) to write down a simple hexaedral cell both as an xml unstrucutred grid and a legacy unstructured grid.

It shows that:

1. A vtk legacy file can have polyhedrons (and paraview will read it, if you try)
2. How to actually write a polyhedron in the legacy format, by inspecting the resulting file

Still, the xml format is probably the one to be chosen in general.
