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