VTK 文件 (*.vtu) 未被正确读取

VTK file (*.vtu) not being correctly read

我创建的 VTK 文件没有被 ParaView 加载时遇到问题。该文件看起来不错,我看不到任何明显的错误,但 ParaView 在尝试查看数据时抛出以下警告。

ERROR: In C:\glr\builds\paraview\paraview-ci\build\superbuild\paraview\src\VTK\Common\Core\vtkPoints.cxx, line 166
vtkPoints (0000019324F41DF0): Number of components is different...can't set data

ERROR: In C:\glr\builds\paraview\paraview-ci\build\superbuild\paraview\src\VTK\IO\XML\vtkXMLReader.cxx, line 922
vtkXMLUnstructuredGridReader (0000019325100BE0): Array has 0 allocated elements, but 60 were requested to be read

ERROR: In C:\glr\builds\paraview\paraview-ci\build\superbuild\paraview\src\VTK\IO\XML\vtkXMLUnstructuredDataReader.cxx, line 504
vtkXMLUnstructuredGridReader (0000019325100BE0): Cannot read points array from Points in piece 0.  The data array in the element may be too short.

这是我的 unstructured grid 简单测试文件,包含 20 个点和一些相关标量。希望有人能发现问题。

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
  <UnstructuredGrid>
    <Piece NumberOfCells="20" NumberOfPoints="20">
      <Points>
        <DataArray Name="points" type="Float64" format="ascii" NumberofComponents="3">
          0.9191090317991818 0.4523130130592968 0.9191090317991818 0.6421955999238554 0.1757747380313244 0.6421955999238554
          0.7537122297291767 0.0493769993144870 0.7537122297291767 0.1393145681027350 0.2924753386949548 0.1393145681027350
          0.0873195479896001 0.0667991310914613 0.0873195479896001 0.7880020580364918 0.7511564859911245 0.7880020580364918
          0.3261509370344888 0.0637715240806562 0.3261509370344888 0.5410678214759677 0.4319083194117714 0.5410678214759677
          0.2402351758680060 0.3641724134430167 0.2402351758680060 0.5454229255759049 0.1519715256925609 0.5454229255759049
          0.4005545036798892 0.5467103397159158 0.4005545036798892 0.7151918872797569 0.4432930376023336 0.7151918872797569
          0.8366799410811948 0.0360613100029110 0.8366799410811948 0.5884811425466829 0.8228931912295053 0.5884811425466829
          0.2961545640333596 0.2732926831299841 0.2961545640333596 0.2810176906539642 0.1689852192728417 0.2810176906539642
          0.7055972446574292 0.6443697547109174 0.7055972446574292 0.4225964301897521 0.1075410788025926 0.4225964301897521
          0.0573159852472062 0.3532450981171027 0.0573159852472062 0.7470273067071216 0.3857036581156064 0.7470273067071216
        </DataArray>
      </Points>
      <Cells>
        <DataArray Name="connectivity" type="Int32" format="ascii" NumberofComponents="1">
          0 1 2 3 4 5
          6 7 8 9 10 11
          12 13 14 15 16 17
          18 19
        </DataArray>
        <DataArray Name="offsets" type="Int32" format="ascii" NumberofComponents="1">
          0 1 2 3 4 5
          6 7 8 9 10 11
          12 13 14 15 16 17
          18 19
        </DataArray>
        <DataArray Name="types" type="UInt8" format="ascii" NumberofComponents="1">
          1 1 1 1 1 1
          1 1 1 1 1 1
          1 1 1 1 1 1
          1 1
        </DataArray>
      </Cells>
      <PointData Scalars="1_temp">
        <DataArray Name="1_temp" type="Float64" format="ascii" NumberofComponents="1">
          0.4204270035661765 0.9490145030363609 0.7864711816566549 0.4815468959885630 0.0119215535827562 0.0597207807092479
          0.8257177483439162 0.4046369872739349 0.0531531123171690 0.2596390482071086 0.2811506610562717 0.9433030410624577
          0.8936293596271191 0.2022892694899581 0.1003608087345019 0.5730430655359530 0.7453773741488717 0.6007604785160442
          0.9092395428890321 0.9385777624120453
        </DataArray>
        <DataArray Name="2_pressure" type="Float64" format="ascii" NumberofComponents="1">
          0.5890720970505128 0.3268986086578718 0.1448144482177102 0.2576384903723663 0.8574458883976873 0.6839737520406283
          0.9986326035811655 0.3194556656082242 0.4534082266242594 0.8676221777748950 0.6385221808378060 0.3318923019829476
          0.5419776327479333 0.1123238088406830 0.8165234436255825 0.2209316463478144 0.5149742681090496 0.5260877679247680
          0.2770886884732112 0.9044206316605501
        </DataArray>
      </PointData>
    </Piece>
  </UnstructuredGrid>
</VTKFile>

对于可能遇到此问题的任何人来说,答案都是微不足道的 - <DataArray> attribute 应该是 NumberOfComponents注意大小写!