From b9588627f04d47319b6dd424d3a9d49d4fbfeff2 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 30 Aug 2021 22:00:58 +0200 Subject: [PATCH] use history in OCCT - fuse --- libsrc/csg/csgeom.cpp | 4 ++-- libsrc/occ/python_occ_shapes.cpp | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/libsrc/csg/csgeom.cpp b/libsrc/csg/csgeom.cpp index e1ada634..c1256a19 100644 --- a/libsrc/csg/csgeom.cpp +++ b/libsrc/csg/csgeom.cpp @@ -312,7 +312,7 @@ namespace netgen { // CSGeometry * geo = new CSGeometry; - char key[100], name[100], classname[100], sname[100]; + char key[100], name[100], classname[100], sname[150]; int ncoeff, i, j; NgArray coeff; @@ -622,7 +622,7 @@ namespace netgen { static int cntsurfs = 0; cntsurfs++; - char name[15]; + char name[20]; sprintf (name, "nnsurf%d", cntsurfs); AddSurface (name, surf); } diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 3f55f8a5..13ad6509 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -540,6 +540,7 @@ public: BRepBuilderAPI_MakeFace builder(surf, 1e-8); for (auto w : wires) builder.Add(w); + wires.clear(); return builder.Face(); } @@ -746,8 +747,24 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) { return shape.Located(loc); }) .def("__add__", [] (const TopoDS_Shape & shape1, const TopoDS_Shape & shape2) { - auto fused = BRepAlgoAPI_Fuse(shape1, shape2).Shape(); + // auto fused = BRepAlgoAPI_Fuse(shape1, shape2).Shape(); // return fused; + + BRepAlgoAPI_Fuse builder(shape1, shape2); +#ifdef OCC_HAVE_HISTORY + Handle(BRepTools_History) history = builder.History (); + + for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE }) + for (auto & s : { shape1, shape2 }) + for (TopExp_Explorer e(s, typ); e.More(); e.Next()) + { + auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; + for (auto mods : history->Modified(e.Current())) + OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); + } +#endif + auto fused = builder.Shape(); + // make one face when fusing in 2D // from https://gitlab.onelab.info/gmsh/gmsh/-/issues/627