目录
offsets array is not long enough
types array is not long enough
错误说明
报错原因:<cell>元素填写不对
offsets array is not long enough
ERROR: In C:\glr\builds\paraview\paraview-ci\build\superbuild\paraview\src\VTK\IO\XML\vtkXMLUnstructuredDataReader.cxx, line 647
vtkXMLUnstructuredGridReader (000001FAC8C7BA40): Cannot read cell offsets from Cells in piece 0 because the “offsets” array is not long enough.
报错代码位于: int vtkXMLUnstructuredDataReader::ReadCellArray(vtkIdType numberOfCells,
vtkIdType vtkNotUsed(totalNumberOfCells), vtkXMLDataElement* eCells, vtkCellArray* outCells)中:
int vtkXMLUnstructuredDataReader::ReadCellArray(vtkIdType numberOfCells,
vtkIdType vtkNotUsed(totalNumberOfCells), vtkXMLDataElement* eCells, vtkCellArray* outCells)
types array is not long enough
ERROR: In D:\pv\ParaView\VTK\IO\XML\vtkXMLUnstructuredGridReader.cxx, line 293
vtkXMLUnstructuredGridReader (000001EBA1A74270): Cannot read cell types from Cells in piece 0 because the “types” array is not long enough.
一个例子说明UnstructuredData的<cell>元素填充规则
《
paraview数据文件格式PVD 和VTK数据文件格式
》中对cell元素的说明如下:
文档中并没有说明<cell>中三个<DataArray>如何填充,尤其是offsets如何填充。
但是我们在
ParaView – KitwarePublic
发现paraview包含
Generating data
功能,可以把现有的vtk文件保存为vtu文件,从而得到规则。
vtk文件根据《
paraview数据文件格式PVD 和VTK数据文件格式
》中的例子三,自己设计。
vtk文件
下面以一个demo尝试去理解paraview中<CELL>三个<DataArray>填充规则:
test.vtk文件如下:
# vtk DataFile Version 2.0
Unstructured Grid Example
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 12 float
0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1
0 1 1 1 1 1 2 0 0 2 1 0 2 0 1 2 1 1
CELLS 2 18
8 0 1 2 3 4 5 6 7
8 1 8 3 9 5 10 7 11
CELL_TYPES 2
11
11
POINT_DATA 12
SCALARS scalars float 1
LOOKUP_TABLE default
0.0 1.0 2.0 3.0 4.0 5.0
6.0 7.0 8.0 9.0 10.0 11.0
paraview中显示test.vtk:
保存vtk为vtu文件
paraview 保存test.vtk为test.vtu文件:
【file】–》【save data]–》修改file of types为vtu,并且输入文件名称–》点击【ok】按钮后弹出,configure writer对话框,修改【Data Mode】为Ascii:
得到的test.vtu文件如下:
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="12" NumberOfCells="2">
<PointData Scalars="scalars">
<DataArray type="Float32" Name="scalars" format="ascii" RangeMin="0" RangeMax="11">
0 1 2 3 4 5
6 7 8 9 10 11
</DataArray>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="ascii" RangeMin="0" RangeMax="2.449489742783178">
0 0 0 1 0 0
0 1 0 1 1 0
0 0 1 1 0 1
0 1 1 1 1 1
2 0 0 2 1 0
2 0 1 2 1 1
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
2.4494897428
</Value>
</InformationKey>
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
2.4494897428
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="11">
0 1 2 3 4 5
6 7 1 8 3 9
5 10 7 11
</DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="8" RangeMax="16">
8 16
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" RangeMin="11" RangeMax="11">
11 11
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
paraview打开test.vtu文件,显示效果跟test.vtk完全一样。
简化vtu文件
删除《
paraview数据文件格式PVD 和VTK数据文件格式
》没有介绍的一些字段和属性。
下面做一些实验:
删掉其中的<InformationKey>元素和删除<DataArray>中的RangeMin和RangeMax属性。得到1.vtu文件如下:
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="12" NumberOfCells="2">
<PointData Scalars="scalars">
<DataArray type="Float32" Name="scalars" format="ascii" >
0 1 2 3 4 5
6 7 8 9 10 11
</DataArray>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="ascii" >
0 0 0 1 0 0
0 1 0 1 1 0
0 0 1 1 0 1
0 1 1 1 1 1
2 0 0 2 1 0
2 0 1 2 1 1
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" >
0 1 2 3 4 5
6 7 1 8 3 9
5 10 7 11
</DataArray>
<DataArray type="Int64" Name="offsets" format="ascii">
8 16
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" >
11 11
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
paraview显示效果同test.vtu和test.vtk.
下面再看看报错的vtk文件:
<?xml version="1.0"?>
<VTKFile version="0.1" type="UnstructuredGrid" byte_order="BigEndian">
<UnstructuredGrid>
<Piece NumberOfPoints="12" NumberOfCells="2">
<PointData Scalars="Temperature">
<DataArray Name="Temperature" type="Float32" format="ascii">0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0</DataArray>
</PointData>
<Points>
<DataArray NumberOfComponents="3" format="ascii" type="Float32">0 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 1 1 2 0 0 2 1 0 2 0 1 2 1 1</DataArray>
</Points>
<Cells>
<DataArray Name="connectivity" type="Int32" format="ascii">0 1 2 3 4 5 6 7</DataArray>
<DataArray Name="offsets" type="Int32" format="ascii">0 0 </DataArray>
<DataArray Name="types" type="UInt8" format="ascii">11</DataArray>
</Cells>
<Cells>
<DataArray Name="connectivity" type="Int32" format="ascii">1 8 3 9 5 10 7 11</DataArray>
<DataArray Name="offsets" type="Int32" format="ascii">0 0</DataArray>
<DataArray Name="types" type="UInt8" format="ascii">11</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
理解正确的vtu文件就可以了,不要被误导