Geom.to_vtk improvements

- should be integer
- should have a test
This commit is contained in:
Martin Diehl 2020-08-23 08:49:49 +02:00
parent a1f1b91c7f
commit b731b1e768
2 changed files with 11 additions and 2 deletions

View File

@ -358,7 +358,7 @@ class Geom:
"""
g = VTK.from_file(fname).geom
N_cells = g.GetNumberOfCells()
microstructure = np.zeros(N_cells)
microstructure = np.zeros(N_cells,'i')
grid = np.array(g.GetDimensions())-1
bbox = np.array(g.GetBounds()).reshape(3,2).T
size = bbox[1] - bbox[0]

View File

@ -1,3 +1,6 @@
import os
import time
import pytest
import numpy as np
@ -65,8 +68,14 @@ class TestGeom:
new = Geom.from_file(f)
assert geom_equal(new,default)
def test_export_vtk(self,default,tmpdir):
def test_read_write_vtk(self,default,tmpdir):
default.to_vtk(str(tmpdir.join('default')))
for _ in range(3):
if os.path.exists(tmpdir.join('default.vtr')): break
time.sleep(1)
new = Geom.from_vtk(str(tmpdir.join('default.vtr')))
assert geom_equal(new,default)
@pytest.mark.parametrize('pack',[True,False])
def test_pack(self,default,tmpdir,pack):