# import des different composants necessaires
from vtk import *

# ------------------------------------------------
# Lecture de fichier Legacy
# ------------------------------------------------

def readVTK(fileName):
   reader = vtkDataSetReader()
   reader.SetFileName(fileName)
   reader.Update()
   reader.CloseVTKFile()
   return reader.GetOutput()

def readUnstructuredXML(fileName):
   reader = vtkXMLUnstructuredGridReader()
   reader.SetFileName(fileName)
   reader.Update()
   return reader.GetOutput()
   
def convertLegacy(legacy,xml):
	writer = vtkXMLDataSetWriter()
	writer.SetFileName(xml)
	writer.SetInput( readeVTK(legacy) )
	writer.Update();

def writeASCII(dataset, fileName):
	writer = vtkDataSetWriter()
	writer.SetFileName(fileName)
	writer.SetFileTypeToASCII()
	writer.SetInput(dataset)
	writer.Update();