Code extracted from: https://github.com/Kitware/MetaIO.git at commit 4c85a18eb668d6426e36a974472b07c0cb7ce3f7.