无法理解 .inr 文件格式

Troubles understanding .inr file format

我正在尝试为 cgal 库创建一个 gray-scale .inr 图像,但我遇到了文件格式问题。
This seems to be the best description of the format,但看起来并不完整,只谈header,不谈数据本身。
This seems to have a bit more information about the format,可惜是法语

我想做的是将 object 表示为一个填充布尔值的 3D 数组,因此如果位置在 object 内则值为 1,如果在 object 内则值为 0外部。

我现在所做的,基于第二个 link 如果我理解正确的话,是在 header 之后将每个 z 平面写在一条线上,下一个 z 平面在换行。
因此,我在代表第一行的行上有列的 x 值,然后在同一行上有第二行的 x 值,如此 y 次直到最后一行。然后我为新的 z 平面跳线并以相同的方式写入数据。

I have created the following .inr file,但是当我尝试对其进行网格化时,结果是一个立方体而不是圆柱体,就好像 cgal(我使用 mesh_optimization_lloyd_example)不关心布尔值而只是对整个体积进行网格划分。

我试着查看示例提供的 .inr 文件(如 skull_2.9.inr),但是虽然 header 非常清晰,但没有文本编辑器可以读取图像数据,这让我觉得可能不仅仅是写 0s 或 1s。

是不是 .inr 有问题?或者我用错了cgal?

我终于设法让它工作了,如果它对某人有帮助,这是需要的。

Header:必须是256字节的倍数,包括header结束后的回车return,这里举例。

#INRIMAGE-4#{ // format type
XDIM=150 // x dimension
YDIM=200 // y dimension
ZDIM=100 // z dimension
VDIM=1 // dimension of the data, here 1 for scalar or 3 for thing like RGB values
VX=5 // voxel size in x
VY=5 // voxel size in y
VZ=5 // voxel size in z
// a higher voxel size results in a more precise 3D mesh
TYPE=unsigned fixed // type of data written, can float, signed fixed or unsigned fixed, unclear if it makes a difference in my case
SCALE=2**0 // not used by most programs apparently
PIXSIZE=8 bits // size of a char, can be 8, 16, 32 or 64
CPU=pc // the type of cpu for little/big endianness, pc is little endian

// Fill with carriage returns until the header is a multiple of 256 bytes, including the end of the header (4 bytes including the line break)

##} // the line break is included in the header count

现在数据本身:
尽管文档似乎暗示了什么,但其中没有换行符,一切都是连续的。 数据必须以二进制而不是 ASCII 格式写入(因此在我的 C++ 中,这将是 static_cast(space[i][j][k])),将 char 替换为您使用的数据)。

最后一个怪癖,文件似乎是 column-major 顺序,所以如果你在 C 中有一个 3d 数组(row-major),你需要转置 (x,y)飞机在写之前。