pythonocc-core
pythonocc-core copied to clipboard
Crash on getting bounds of BSpline of BRepAdaptor_Surface
Hi,
using pythonocc-core 7.7.2 getting the bounds from a BRepAdaptor_Surface crashes on Windows and on Linux.
On Windows it crashes with: Windows fatal exception: code 0xc0000374
Which is consistent to #1218 and seems like a very related error.
But the workaround proposed there to not chain the methods but call everything seperately does not work here.
from OCC.Core.BRepAdaptor import BRepAdaptor_Surface
from OCC.Core.IGESCAFControl import IGESCAFControl_Reader
from OCC.Core.TDF import TDF_LabelSequence
from OCC.Core.TDocStd import TDocStd_Document
from OCC.Core.XCAFDoc import XCAFDoc_DocumentTool
def get_bounds(adaptor):
surface = adaptor.Surface()
bspline = surface.BSpline()
bounds = bspline.Bounds()
result = list(bounds)
return result
aReader = IGESCAFControl_Reader()
if aReader.ReadFile("testfile.igs") != 1:
raise ValueError("Can't open IGES file.")
aDoc = TDocStd_Document("iges")
if not aReader.Transfer(aDoc):
raise ValueError("Cannot transfer data from IGES file.")
shape_tool = XCAFDoc_DocumentTool.ShapeTool(aDoc.Main())
shp_labels = TDF_LabelSequence()
shape_tool.GetShapes(shp_labels)
shape_label = shp_labels.Value(1)
shape = shape_tool.GetShape(shape_label)
adaptor = BRepAdaptor_Surface(shape)
bounds = get_bounds(adaptor)
print(bounds)
print("done")
The crash always happens at the return statement of the get_bounds method even though I am returning a list of floats which I can print out while debugging just fine.
If I move the code outside of the method into the main script it actually works. But for me it is not feasible to not use methods in a larger piece of code.
I attached the testfile I used, which is just a random surface I created in CAD software. testfile.zip
PS: The code structure worked fine in version 7.4.1, after that those problems appeared.