Binary 如何理解vtk二进制文件格式中的base64编码

Binary 如何理解vtk二进制文件格式中的base64编码,binary,base64,vtk,Binary,Base64,Vtk,我对如何理解二进制DataArray有一个问题。这个问题是因为base64编码 手册上说,如果数据数组的格式是二进制 The data are encoded in base64 and listed contiguously inside the DataArray element. Data may also be compressed before encoding in base64. The byte- order of the data matches that specified

我对如何理解二进制
DataArray
有一个问题。这个问题是因为base64编码

手册上说,如果
数据数组
的格式是
二进制

The data are encoded in base64 and listed contiguously inside the
DataArray element. Data may also be compressed before encoding in base64. The byte-
order of the data matches that specified by the byte_order attribute of the VTKFile element.
我不能完全理解这一点,所以我得到了ascii文件和相同型号的二进制文件

ASCII文件 有人能给我解释一下如何转换吗? 另一个相关主题可参见


谢谢您的时间。

可以在Discussion中找到解决方案

https://discourse.vtk.org/t/how-to-understand-binary-dataarray-in-xml-vtk-output/4489
长的额外数据来自压缩机收割台

<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
  <UnstructuredGrid>
    <Piece NumberOfPoints="4" NumberOfCells="1">
      <PointData>
      </PointData>
      <CellData>
      </CellData>
      <Points>
        <DataArray type="Float32" Name="Points" NumberOfComponents="3" format="binary" RangeMin="0" RangeMax="1.4142135624">
          AQAAAACAAAAwAAAAEQAAAA==eJxjYEAGDfaobEw+ADwjA7w=
        </DataArray>
      </Points>
      <Cells>
        <DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="3">
          AQAAAACAAAAgAAAAEwAAAA==eJxjYIAARijNBKWZoTQAAHAABw==
        </DataArray>
        <DataArray type="Int64" Name="offsets" format="binary" RangeMin="4" RangeMax="4">
          AQAAAACAAAAIAAAACwAAAA==eJxjYYAAAAAoAAU=
        </DataArray>
        <DataArray type="UInt8" Name="types" format="binary" RangeMin="10" RangeMax="10">
          AQAAAACAAAABAAAACQAAAA==eJzjAgAACwAL
        </DataArray>
      </Cells>
    </Piece>
  </UnstructuredGrid>
</VTKFile>
#include "base64.h" // https://github.com/superwills/NibbleAndAHalf/blob/master/NibbleAndAHalf/base64.h
#include <iostream>
int main()
{
    int x = 10;
    int len;

    // first arg: binary buffer
    // second arg: length of binary buffer
    // third arg: length of ascii buffer
    char *ascii = base64((char *)&x, sizeof(int), &len);
    
    std::cout << ascii << std::endl;
    std::cout << len << std::endl;
    free(ascii);
    return 0;
}
https://discourse.vtk.org/t/how-to-understand-binary-dataarray-in-xml-vtk-output/4489