Wed, 01/11/2023 - 07:58
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.
Wed, 01/11/2023 - 20:00
BREP file format has been slightly improved within OCCT 7.6 release, but described behavior with
Checked
flag of savedTopoDS_Face
looks like a regression to me.Wed, 01/11/2023 - 20:40
Hello.
Thank you for your investigation.
Yes, it looks like a regression. We will analyze it.
Best regards, Dmitrii.
Thu, 01/12/2023 - 23:31
Thanks very much @gkv311 and Dmitrii !