#!/usr/bin/env python3 """Dump the three sub-geometries of each PUNCH patch separately: chunk1 (dmg_set mask), chunk2 (undmg2enbl DRAWN), chunk3 (dmg_clear). Check: are chunk2 and chunk3 identical? bbox/plane relationships chunk1 vs chunk2.""" import struct, sys import numpy as np VSTRIDE = {0x80:12, 0x81:24, 0x82:28, 0x88:20, 0x89:32, 0x8A:36} CONTAINERS = {0x40,0x41,0x42,0x46,0x48,0x70,0x10,0x20,0x30,0x3} def parse(path): d = open(path,"rb").read() patches = [] def read_chunk(p, end): if p+2 > end: return None tw = struct.unpack_from(" end: return None if lw==1: ln = d[p+2] elif lw==2: ln = struct.unpack_from("= hi1-1e-4)), bool(np.all(lo1 <= lo0+1e-4) and np.all(hi1 >= hi0-1e-4))))