Skip to content

Commit

Permalink
revised triangle magic (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdiers authored Aug 30, 2024
1 parent 7b4a905 commit 3f1d94e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lapy/_read_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ def _fread3(fobj):
A 3 byte int
"""
b1, b2, b3 = np.fromfile(fobj, ">u1", 3)
return (b1 << 16) + (b2 << 8) + b3
# the bit-shifting operator does not return
# identical results on all platforms, therefore
# we disable it and return / compare the first
# three bytes separately
# return (b1 << 16) + (b2 << 8) + b3
return b1, b2, b3


def _read_volume_info(fobj):
Expand Down Expand Up @@ -141,7 +146,10 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
"""
volume_info = OrderedDict()

TRIANGLE_MAGIC = 16777214
# See comment in _fread3() on why we have changed the
# comparison
# TRIANGLE_MAGIC = 16777214
TRIANGLE_MAGIC = (np.uint8(255), np.uint8(255), np.uint8(254))

with open(filepath, "rb") as fobj:
magic = _fread3(fobj)
Expand Down

0 comments on commit 3f1d94e

Please sign in to comment.