@@ -54,7 +54,19 @@ def _cells_from_data(connectivity, offsets, types, cell_data_raw):
54
54
meshio_type = vtk_to_meshio_type [types [start ]]
55
55
except KeyError :
56
56
raise ReadError ("File contains cells that meshio cannot handle." )
57
- if meshio_type == "polygon" :
57
+
58
+ # cells with varying number of points
59
+ special_cells = [
60
+ "polygon" ,
61
+ "VTK_LAGRANGE_CURVE" ,
62
+ "VTK_LAGRANGE_TRIANGLE" ,
63
+ "VTK_LAGRANGE_QUADRILATERAL" ,
64
+ "VTK_LAGRANGE_TETRAHEDRON" ,
65
+ "VTK_LAGRANGE_HEXAHEDRON" ,
66
+ "VTK_LAGRANGE_WEDGE" ,
67
+ "VTK_LAGRANGE_PYRAMID" ,
68
+ ]
69
+ if meshio_type in special_cells :
58
70
# Polygons have unknown and varying number of nodes per cell.
59
71
# IMPLEMENTATION NOTE: While polygons are different from other cells
60
72
# they are much less different than polyhedral cells (for polygons,
@@ -893,10 +905,28 @@ def _polyhedron_face_cells(face_cells):
893
905
for k , v in mesh .cells :
894
906
# For polygon and polyhedron grids, the number of nodes is part of the cell
895
907
# type key. This part must be stripped away.
896
- if k [:7 ] == "polygon" :
897
- key_ = k [:7 ]
898
- elif k [:10 ] == "polyhedron" :
899
- key_ = k [:10 ]
908
+ special_cells = [
909
+ "polygon" ,
910
+ "polyhedron" ,
911
+ "VTK_LAGRANGE_CURVE" ,
912
+ "VTK_LAGRANGE_TRIANGLE" ,
913
+ "VTK_LAGRANGE_QUADRILATERAL" ,
914
+ "VTK_LAGRANGE_TETRAHEDRON" ,
915
+ "VTK_LAGRANGE_HEXAHEDRON" ,
916
+ "VTK_LAGRANGE_WEDGE" ,
917
+ "VTK_LAGRANGE_PYRAMID" ,
918
+ ]
919
+ key_ = None
920
+ for string in special_cells :
921
+ if k .startswith (string ):
922
+ key_ = string
923
+
924
+ if key_ is None :
925
+ # No special treatment
926
+ key_ = k
927
+
928
+ # further adaptions for polyhedron
929
+ if k .startswith ("polyhedron" ):
900
930
# Get face-cell relation on the vtu format. See comments in helper
901
931
# function for more information of how to specify this.
902
932
faces_loc , faceoffsets_loc = _polyhedron_face_cells (v )
@@ -908,9 +938,7 @@ def _polyhedron_face_cells(face_cells):
908
938
assert faces is not None
909
939
faces += faces_loc
910
940
faceoffsets += faceoffsets_loc
911
- else :
912
- # No special treatment
913
- key_ = k
941
+
914
942
types_array .append (np .full (len (v ), meshio_to_vtk_type [key_ ]))
915
943
916
944
types = np .concatenate (
0 commit comments