小编Man*_*bit的帖子

从原始 VTK (.vtu) 文件中读取数据

我想使用 Python VTK 模块从 .vtu 文件中提取数据数组。文件看起来像这样(文件末尾的原始数据被省略):

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian">
  <UnstructuredGrid>
    <Piece NumberOfPoints="10471" NumberOfCells="64892">
      <PointData>
        <DataArray type="Float64" Name="potential" NumberOfComponents="1" format="appended" offset="0"/>
        <DataArray type="Float64" Name="electric field" NumberOfComponents="3" format="appended" offset="83772"/>
      </PointData>
      <CellData>
        <DataArray type="Int32" Name="GeometryIds" format="appended" offset="335080"/>
      </CellData>
      <Points>
        <DataArray type="Float64" NumberOfComponents="3" format="appended" offset="594652"/>
      </Points>
      <Cells>
        <DataArray type="Int32" Name="connectivity" format="appended" offset="845960"/>
        <DataArray type="Int32" Name="offsets" format="appended" offset="1865068"/>
        <DataArray type="Int32" Name="types" format="appended" offset="2124640"/>
      </Cells>
    </Piece>
  </UnstructuredGrid>
<AppendedData encoding="raw">
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下 python 代码提取数据:

import numpy
from vtk import vtkUnstructuredGridReader
from vtk.util import numpy_support as …
Run Code Online (Sandbox Code Playgroud)

numpy vtk python-3.x

1
推荐指数
2
解决办法
5274
查看次数

标签 统计

numpy ×1

python-3.x ×1

vtk ×1