diff --git a/README.md b/README.md index 097456527..35ba61605 100644 --- a/README.md +++ b/README.md @@ -171,10 +171,11 @@ with meshio.xdmf.TimeSeriesReader(filename) as reader: If you have downloaded a binary version of ParaView, you may proceed as follows. -- Install meshio for the Python major version that ParaView uses (check `pvpython --version`) +- Install `meshio` and `rich` modules for the Python major version that ParaView uses (check `pvpython --version` from `paraview/bin`). +Then copy `meshio` and `rich` directories from your Python directory `PYTHONPATH/Lib/site-packages/meshio` to `paraview/bin/Lib/site-packages`. - Open ParaView - Find the file `paraview-meshio-plugin.py` of your meshio installation (on Linux: - `~/.local/share/paraview-5.9/plugins/`) and load it under _Tools / Manage Plugins / Load New_ + `~/.local/share/paraview-5.9/plugins/`, on Windows: `PYTHONPATH\share\paraview-5.9\plugins\`) and load it under _Tools / Manage Plugins / Load New_ - _Optional:_ Activate _Auto Load_ You can now open all meshio-supported files in ParaView. diff --git a/tools/paraview-meshio-plugin.py b/tools/paraview-meshio-plugin.py index a4f2813f8..1bf2a34ea 100644 --- a/tools/paraview-meshio-plugin.py +++ b/tools/paraview-meshio-plugin.py @@ -71,7 +71,7 @@ def RequestData(self, request, inInfoVec, outInfoVec): # Use meshio to read the mesh mesh = meshio.read(self._filename, self._file_format) - points, cells = mesh.points, mesh.cells + points, cells, cells_dict = mesh.points, mesh.cells, mesh.cells_dict # Points if points.shape[1] == 2: @@ -82,16 +82,17 @@ def RequestData(self, request, inInfoVec, outInfoVec): cell_types = np.array([], dtype=np.ubyte) cell_offsets = np.array([], dtype=int) cell_conn = np.array([], dtype=int) - for meshio_type, data in cells: + for meshio_type in cells_dict.keys(): # loop over cell types vtk_type = meshio_to_vtk_type[meshio_type] - ncells, npoints = data.shape + ncells = cells_dict[meshio_type].shape[0] + npoints = cells_dict[meshio_type][0].size # for one cell cell_types = np.hstack( [cell_types, np.full(ncells, vtk_type, dtype=np.ubyte)] ) offsets = len(cell_conn) + (1 + npoints) * np.arange(ncells, dtype=int) cell_offsets = np.hstack([cell_offsets, offsets]) conn = np.hstack( - [npoints * np.ones((ncells, 1), dtype=int), data] + [npoints * np.ones((ncells, 1), dtype=int), cells_dict[meshio_type]] ).flatten() cell_conn = np.hstack([cell_conn, conn]) output.SetCells(cell_types, cell_offsets, cell_conn)