Leggi il solido dei .prt ed esportalo in STEP senza Creo
- scripts/psb/brep.py: B-rep esatto da VisibGeom/ActDatums riscritto in STEP; coincide faccia per faccia con lo STEP di Creo su due campioni. - scripts/psb/mesh.py: STEP sfaccettato dalla mesh di SolidPrimdata, per i file Wildfire in cui VisibGeom e' cifrata. - psb.py: tabella dei double corretta (modi a 3/6 byte, prefissi con buchi, costanti 04 e 0d, tag ee); tabella dei float a 81 voci, i tag ignoti non ricevono piu' un valore inventato; struct dichiarate sotto due id. - tagfit.py, fltfit.py, stepread.py: verifica delle tabelle con vincoli geometrici e confronto con lo STEP di Creo. - docs: nuovo formato-prt-brep.md e lettura-prt-asm.md; correzioni in formato-psb.md (3.4) e formato-prt-geometria.md (assi di local_sys = colonne); history.md con regressioni e punti aperti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7754bea9d4
commit
3396df6be0
16 files changed
+1584
-15
No files matched your search
+49
-11
@@ -91,9 +91,27 @@ class P:
|
||||
return -1
|
||||
raise Err(f"int tag {b:02x} @{s.p - 1:x}")
|
||||
|
||||
CONST = {0x17: -6.283185307179586, 0x14: 4.71238898038469, 0x0d: -0.5, 0x11: 3.141592653589793, 0x15: -3.141592653589793, 0x12: 1.5707963267948966, 0x16: -1.5707963267948966, 0x13: 6.283185307179586, 0x18: 0.0, 0x0f: 1.0, 0x0e: 0.5, 0x10: -1.0, 0x0c: 0.1, 0x0a: 0.01, 0x07: 0.001}
|
||||
CONST = {0x04: 1.0, 0x0d: 0.25, 0x17: -6.283185307179586, 0x14: 4.71238898038469, 0x11: 3.141592653589793, 0x15: -3.141592653589793, 0x12: 1.5707963267948966, 0x16: -1.5707963267948966, 0x13: 6.283185307179586, 0x18: 0.0, 0x0f: 1.0, 0x0e: 0.5, 0x10: -1.0, 0x0c: 0.1, 0x0a: 0.01, 0x07: 0.001}
|
||||
|
||||
FBASE = 0x3f9d
|
||||
# tag 50-df dei float -> primi due byte (seguono 2 byte). Tabella sparsa, crescente in modulo
|
||||
# (50-a3 positivi, a4-df negativi), ricostruita da fltfit.py; un tag assente e' ignoto
|
||||
FKNOWN = {0x52: 0x3d2d, 0x53: 0x3d4c, 0x54: 0x3d56, 0x55: 0x3d57, 0x57: 0x3d78,
|
||||
0x58: 0x3d79, 0x59: 0x3d7f, 0x5a: 0x3d80, 0x5b: 0x3d83, 0x5c: 0x3d86,
|
||||
0x5d: 0x3d87, 0x5e: 0x3d89, 0x5f: 0x3d8a, 0x60: 0x3df1, 0x61: 0x3dff,
|
||||
0x62: 0x3e00, 0x63: 0x3e1d, 0x64: 0x3e20, 0x65: 0x3e21, 0x66: 0x3e3b,
|
||||
0x67: 0x3e46, 0x68: 0x3e80, 0x69: 0x3e84, 0x6a: 0x3ea6, 0x6b: 0x3eae,
|
||||
0x6c: 0x3ec6, 0x6d: 0x3f08, 0x6e: 0x3f0a, 0x6f: 0x3f0b, 0x70: 0x3f0c,
|
||||
0x71: 0x3f0d, 0x72: 0x3f0e, 0x73: 0x3f0f, 0x74: 0x3f10, 0x75: 0x3f17,
|
||||
0x76: 0x3f21, 0x77: 0x3f57, 0x82: 0x3fae, 0x8c: 0x3fca, 0x94: 0x4007,
|
||||
0x97: 0x401b, 0x99: 0x4023, 0xa7: 0xbd56, 0xa8: 0xbd57, 0xa9: 0xbd61,
|
||||
0xaa: 0xbd70, 0xab: 0xbd75, 0xac: 0xbd78, 0xae: 0xbd7f, 0xaf: 0xbd80,
|
||||
0xb0: 0xbd83, 0xb1: 0xbd86, 0xb2: 0xbd87, 0xb3: 0xbd89, 0xb4: 0xbd8a,
|
||||
0xb5: 0xbdff, 0xb6: 0xbe00, 0xb7: 0xbe16, 0xb8: 0xbe20, 0xb9: 0xbe46,
|
||||
0xba: 0xbe48, 0xbb: 0xbe72, 0xbc: 0xbe80, 0xbd: 0xbe84, 0xbe: 0xbeb2,
|
||||
0xbf: 0xbecf, 0xc0: 0xbee4, 0xc1: 0xbeea, 0xc2: 0xbeee, 0xc3: 0xbef5,
|
||||
0xc4: 0xbf0a, 0xc5: 0xbf1c, 0xc6: 0xbf20, 0xc7: 0xbf27, 0xc8: 0xbf32,
|
||||
0xc9: 0xbf46, 0xca: 0xbf60, 0xcb: 0xbf66, 0xcc: 0xbf7a, 0xd7: 0xbfb2,
|
||||
0xdd: 0xc01b}
|
||||
FCONST = {0x0b: 1.0, 0x28: -1.0}
|
||||
|
||||
def rflt(s):
|
||||
@@ -102,7 +120,9 @@ class P:
|
||||
T = (0x37 + t - 0x30) if t < 0x40 else (0xb7 + t - 0x40)
|
||||
raw = bytes([T]) + s.b[s.p:s.p + 3]
|
||||
s.p += 3
|
||||
elif t == 0xea:
|
||||
elif t in (0xea, 0xee):
|
||||
# ee: visto solo per rumore numerico attorno a zero (1e-14); che cosa lo distingua da ea
|
||||
# non e' noto, la lunghezza si' (76 file letti fino in fondo)
|
||||
raw = s.b[s.p:s.p + 3] + bytes(1)
|
||||
s.p += 3
|
||||
elif t == 0xeb:
|
||||
@@ -121,8 +141,11 @@ class P:
|
||||
elif t < 0x30:
|
||||
return Unk(t)
|
||||
elif 0x50 <= t <= 0xdf:
|
||||
raw = (s.FBASE + t).to_bytes(2, 'big') + s.b[s.p:s.p + 2]
|
||||
pl = s.b[s.p:s.p + 2]
|
||||
s.p += 2
|
||||
if t not in s.FKNOWN:
|
||||
return Unk(t) # lunghezza giusta, valore ignoto: mai inventarlo
|
||||
raw = s.FKNOWN[t].to_bytes(2, 'big') + pl
|
||||
else:
|
||||
raise Err(f"flt tag {t:02x} @{s.p - 1:x}")
|
||||
return struct.unpack('>f', raw)[0]
|
||||
@@ -133,8 +156,13 @@ class P:
|
||||
return s.u8()
|
||||
return b
|
||||
|
||||
# prefissi negativi a 16 bit dei tag a5-df: bfd0..c00d meno tre buchi (bfd2, bfdf, bffe)
|
||||
NEG = [x for x in range(0xbfd0, 0xc00e) if x not in (0xbfd2, 0xbfdf, 0xbffe)]
|
||||
# tag 4b-df -> primi due byte del double (seguono 6 byte). Non e' una formula: e' una tabella
|
||||
# con dei buchi. tagfit.py la verifica con il vincolo geometrico dei B-rep (formato-psb.md 3.2)
|
||||
POS = [0x3fb0, 0x3fb1, 0x3fb5] + [x for x in range(0x3fc0, 0x4019) if x not in (0x3fc6, 0x3fcb, 0x3fce)] # 4b-a3
|
||||
NEG = ([0xbfc0] + [x for x in range(0xbfd0, 0xc00b) if x not in (0xbfd2, 0xbfdf, 0xbffd)]
|
||||
+ [0xc00c, 0xc010, 0xc011]) # a4-df
|
||||
PFX = dict(zip(range(0x4b, 0xe0), POS + NEG))
|
||||
assert len(PFX) == 0xe0 - 0x4b == len(POS) + len(NEG)
|
||||
|
||||
def rdbl(s):
|
||||
t = s.u8()
|
||||
@@ -158,7 +186,7 @@ class P:
|
||||
v = struct.unpack('>d', s.b[s.p:s.p + 8])[0]
|
||||
s.p += 8
|
||||
return v
|
||||
if t == 0xea:
|
||||
if t in (0xea, 0xee): # ee: come nei float, rumore attorno a zero; 3 byte
|
||||
v = struct.unpack('>d', s.b[s.p:s.p + 3] + bytes(5))[0]
|
||||
s.p += 3
|
||||
return v
|
||||
@@ -166,13 +194,17 @@ class P:
|
||||
v = struct.unpack('>d', s.b[s.p:s.p + 7] + bytes(1))[0]
|
||||
s.p += 7
|
||||
return v
|
||||
if 0x19 <= t <= 0x48:
|
||||
if t <= 0x2f:
|
||||
if 0x19 <= t <= 0x4a:
|
||||
# cinque tag per byte alto T, nell'ordine: 7 byte, 2 byte + ripetizione, 2 byte,
|
||||
# 3 byte, 6 byte. Positivi 19-31 (T = 3c-40), negativi 32-4a (T = bc-c0).
|
||||
if t <= 0x31:
|
||||
T = 0x3c + (t - 0x17) // 5
|
||||
m = (t - 0x17) % 5
|
||||
else:
|
||||
T = 0xbc + (t - 0x30) // 5
|
||||
m = (t - 0x30) % 5
|
||||
if m < 2:
|
||||
T -= 1
|
||||
if m == 4:
|
||||
pl = s.b[s.p:s.p + 2]
|
||||
s.p += 2
|
||||
@@ -194,8 +226,8 @@ class P:
|
||||
s.p += 3
|
||||
raw = bytes([T]) + pl + bytes(4)
|
||||
return struct.unpack('>d', raw)[0]
|
||||
if 0x49 <= t <= 0xdf:
|
||||
hi = (0x3f75 + t) if t <= 0xa4 else s.NEG[t - 0xa5]
|
||||
if 0x4b <= t <= 0xdf:
|
||||
hi = s.PFX[t]
|
||||
pl = s.b[s.p:s.p + 6]
|
||||
s.p += 6
|
||||
return struct.unpack('>d', hi.to_bytes(2, 'big') + pl)[0]
|
||||
@@ -343,6 +375,12 @@ class P:
|
||||
f['own'].add(top['schema'])
|
||||
s.lenient += 1
|
||||
return 'field'
|
||||
if i is None and not jump and top is s.lastc and top['kind'] == 'struct' and s.last is not None and s.fields[s.last]['parent'] == par:
|
||||
# il campo precedente e' finito qui per la regola sopra (stessa struct C dichiarata sotto
|
||||
# due id diversi): i suoi fratelli posizionali lo seguono nello stesso contenitore
|
||||
f['own'].add(top['schema'])
|
||||
s.lenient += 1
|
||||
return 'field'
|
||||
fresh = top['kind'] == 'struct' and not top['node']
|
||||
if jump and fresh and i != len(s.stack) - 1:
|
||||
s.alias[top['field']] = par
|
||||
|
||||
Reference in new issue
Block a user