fix for cell data in vtu
@@ -22,10 +22,7 @@ import zlib
import numpy
from .__about__ import __version__
-from .vtk_io import (
- vtk_to_meshio_type, meshio_to_vtk_type, cell_data_from_raw,
- raw_from_cell_data
- )
+from .vtk_io import vtk_to_meshio_type, meshio_to_vtk_type, raw_from_cell_data
from .gmsh_io import num_nodes_per_cell
@@ -35,7 +32,7 @@ def num_bytes_to_num_base64_chars(num_bytes):
return -(-num_bytes // 3) * 4
-def _cells_from_data(connectivity, offsets, types):
+def _cells_from_data(connectivity, offsets, types, cell_data_raw):
# Translate it into the cells dictionary.
# `connectivity` is a one-dimensional vector with
# (p0, p1, ... ,pk, p10, p11, ..., p1k, ...
@@ -49,6 +46,7 @@ def _cells_from_data(connectivity, offsets, types):
assert len(offsets) == len(types)
cells = {}
+ cell_data = {}
for tpe, b in bins.items():
meshio_type = vtk_to_meshio_type[tpe]
n = num_nodes_per_cell[meshio_type]
@@ -57,8 +55,10 @@ def _cells_from_data(connectivity, offsets, types):
numpy.arange(n) + o - n for o in offsets[b]
])
cells[meshio_type] = connectivity[indices]
+ cell_data[meshio_type] = \
+ {key: value[b] for key, value in cell_data_raw.items()}
- return cells
+ return cells, cell_data
vtu_to_numpy_type = {
@@ -192,13 +192,11 @@ class VtuReader(object):
assert 'offsets' in cells
assert 'types' in cells
- cells = _cells_from_data(
- cells['connectivity'], cells['offsets'], cells['types']
+ cells, cell_data = _cells_from_data(
+ cells['connectivity'], cells['offsets'], cells['types'],
+ cell_data_raw
)
- # get cell data in shape
- cell_data = cell_data_from_raw(cells, cell_data_raw)
-
self.points = points
self.cells = cells
self.point_data = point_data
