mikepound / opencubes

A community improved version of the polycubes project!
MIT License
45 stars 22 forks source link

OpenCubes file formats #48

Open JATothrim opened 1 year ago

JATothrim commented 1 year ago

There are few file formats around. It is however bit unclear what these formats actually are for. This issue is for discussion of the file formats used project wide + their documentation.

@bertie2 @datdenkikniet @nsch0e @NailLegProcessorDivide

Rust and python versions seem to implement an format that follows https://github.com/mikepound/opencubes/pull/17#issue-1809988894 so I think this is the export file format.

JATothrim commented 1 year ago

The C++ cubes outputs its data currently only in following format as cache-files:

struct Header {
    uint32_t magic = MAGIC;  // should be "PCUB" = 0x42554350
    uint32_t N;              // we will never need 32bit but it is nicely aligned
    uint32_t numShapes;      // defines length of the shapeTable
    uint64_t numPolycubes;   // total number of polycubes
}
header;
struct ShapeEntry {
    uint8_t dim0;      // offset by -1
    uint8_t dim1;      // offset by -1
    uint8_t dim2;      // offset by -1
    uint8_t reserved;  // for alignment, set to zero and ignored currently.
    uint64_t offset;   // from beginning of file
    uint64_t size;     // in bytes should be multiple of XYZ_SIZE that is currently 3
}
shapeTable[header.numShapes];
struct XYZ {
    int8_t x,y,z;
}
polycubes[header.N * header.numPolycubes];

Additional notes:

Then question(s): C++ cache-file format is different than what python and rust seem write. Should C++ version export the data in the .pcube format?

I have plans for using ShapeEntry::reserved as extensions to the cache-file format. I would like use it as format selector: