Fix segfault in occ (use Handle when creating new Geom_Plane)

This commit is contained in:
Matthias Hochsteger 2025-04-15 18:39:06 +02:00
parent 6ea09e1151
commit 1fc382867d

View File

@ -1964,21 +1964,21 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
}) })
.def("Edge", [](Handle(Geom2d_Curve) curve) { .def("Edge", [](Handle(Geom2d_Curve) curve) {
// static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ???
static auto surf = new Geom_Plane{gp_Ax3()}; static auto surf = Handle(Geom_Plane)(new Geom_Plane{gp_Ax3()});
auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge();
BRepLib::BuildCurves3d(edge); BRepLib::BuildCurves3d(edge);
return edge; return edge;
}) })
.def("Wire", [](Handle(Geom2d_Curve) curve) { .def("Wire", [](Handle(Geom2d_Curve) curve) {
// static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ???
static auto surf = new Geom_Plane{gp_Ax3()}; static auto surf = Handle(Geom_Plane)(new Geom_Plane{gp_Ax3()});
auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge();
BRepLib::BuildCurves3d(edge); BRepLib::BuildCurves3d(edge);
return BRepBuilderAPI_MakeWire(edge).Wire(); return BRepBuilderAPI_MakeWire(edge).Wire();
}) })
.def("Face", [](Handle(Geom2d_Curve) curve) { .def("Face", [](Handle(Geom2d_Curve) curve) {
// static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ??? // static Geom_Plane surf{gp_Ax3()}; // crashes in nbconvert ???
static auto surf = new Geom_Plane{gp_Ax3()}; static auto surf = Handle(Geom_Plane)(new Geom_Plane{gp_Ax3()});
auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge(); auto edge = BRepBuilderAPI_MakeEdge(curve, surf).Edge();
BRepLib::BuildCurves3d(edge); BRepLib::BuildCurves3d(edge);
auto wire = BRepBuilderAPI_MakeWire(edge).Wire(); auto wire = BRepBuilderAPI_MakeWire(edge).Wire();