consistency check and new test

This commit is contained in:
Martin Diehl 2020-03-19 17:34:31 +01:00
parent 2aea6df678
commit 892b7eee98
2 changed files with 6 additions and 4 deletions

@ -1 +1 @@
Subproject commit c5683e828c9a761ad046926e26d6cc6cc10c355c Subproject commit 05ac971ce58fc399dd99be9151b7d61d049aec42

View File

@ -158,7 +158,6 @@ class VTK:
return VTK(geom) return VTK(geom)
# ToDo: If extension is given, check for consistency.
def write(self,fname): def write(self,fname):
""" """
Write to file. Write to file.
@ -176,8 +175,11 @@ class VTK:
elif(isinstance(self.geom,vtk.vtkPolyData)): elif(isinstance(self.geom,vtk.vtkPolyData)):
writer = vtk.vtkXMLPolyDataWriter() writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName('{}.{}'.format(os.path.splitext(fname)[0], default_ext = writer.GetDefaultFileExtension()
writer.GetDefaultFileExtension())) name, ext = os.path.splitext(fname)
if ext and ext != default_ext:
raise ValueError('Given extension {} is not {}'.format(ext,default_ext))
writer.SetFileName('{}.{}'.format(name,default_ext))
writer.SetCompressorTypeToZLib() writer.SetCompressorTypeToZLib()
writer.SetDataModeToBinary() writer.SetDataModeToBinary()
writer.SetInputData(self.geom) writer.SetInputData(self.geom)