Differences in BRepTools serialization/deserialization from 7.5 -> 7.6

In my application I use BRepTools.Write() and BRepTools.Read() to serialize TopoDS_Shape instances to file.

I have found some differences in the behavior of this method when upgrading from OpenCASCADE 7.5 to 7.6. I would expect that if I use BRepTools.Write/Read to serialize and deserialize objects to string as follows:

shape_1 -> string_1 -> shape_2 -> string_2

then string_1 and string_2 would be equal.

With OCCT 7.6, this fails on some shapes where OCCT 7.5 would pass.

As an example, here is a snippet using the OCP bindings in Python.

import io
from OCP import BRepPrimAPI, gp, BRepTools, TopoDS, BRep


def dump(shape):
    b = io.BytesIO()
    BRepTools.BRepTools.Write_s(shape, b)
    return b.getvalue().decode('utf-8')


def load(s):
    shape = TopoDS.TopoDS_Shape()
    builder = BRep.BRep_Builder()
    b = io.BytesIO(bytes(s, 'utf-8'))
    BRepTools.BRepTools.Read_s(shape, b, builder)
    return shape


pnt = gp.gp_Pnt(1, 0, 0)
shape_1 = BRepPrimAPI.BRepPrimAPI_MakeSphere(pnt, 1.0).Shape()

# serialize
ser_1 = dump(shape_1)

# deserialize
shape_2 = load(ser_1)

# serialize again
ser_2 = dump(shape_2)

with open('ser_1-7.5.3.txt', 'w') as f:
    f.write(ser_1)

with open('ser_2-7.5.3.txt', 'w') as f:
    f.write(ser_2)

# make sure serialization is the same
assert ser_1 == ser_2

With OCCT 7.5.3, ser_1 == ser_2, while with OCCT 7.6.3 ser_1 != ser_2.

The difference is small - the "checked" bit of the shell entity is flipped.

Is this expected? What is the significance of the "checked" bit?

I also experience the same issue with BinTools, although it is harder to read the output.

gkv311 n's picture

BREP file format has been slightly improved within OCCT 7.6 release, but described behavior with Checked flag of saved TopoDS_Face looks like a regression to me.

Dmitrii Pasukhin's picture

Hello.

Thank you for your investigation.
Yes, it looks like a regression. We will analyze it.

Best regards, Dmitrii.

Phillip Chiu's picture

Thanks very much @gkv311 and Dmitrii !