From 8018f2640d2edbfc7c7d20ca61cfc4136dc66b28 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 4 Aug 2018 08:13:31 +0800 Subject: [PATCH] PropertyPartShape: add parameter to disable copy on save By default PropertyPartShape uses BRepBuilderAPI_Copy to copy the shape on saving, to get rid of the triangulation. However, OCCT seems to perform a deep copy and shape sharing information is lost. A new parameter, BaseApp/Preferences/Mod/Part/General/CopyShapeOnSave, is added to disable this. --- src/Mod/Part/App/PropertyTopoShape.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index 726e0a69e5..133812f0cb 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -272,9 +272,15 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const return; // NOTE: Cleaning the triangulation may cause problems on some algorithms like BOP // Before writing to the project we clean all triangulation data to save memory - BRepBuilderAPI_Copy copy(_Shape.getShape()); - const TopoDS_Shape& myShape = copy.Shape(); - BRepTools::Clean(myShape); // remove triangulation + TopoDS_Shape myShape; + auto hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Part/General"); + if(hGrp->GetBool("CopyShapeOnSave",true)) { + BRepBuilderAPI_Copy copy(_Shape.getShape()); + myShape = copy.Shape(); + BRepTools::Clean(myShape); // remove triangulation + }else + myShape = _Shape.getShape(); if (writer.getMode("BinaryBrep")) { TopoShape shape; @@ -282,8 +288,7 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const shape.exportBinary(writer.Stream()); } else { - bool direct = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/Mod/Part/General")->GetBool("DirectAccess", true); + bool direct = hGrp->GetBool("DirectAccess", true); if (!direct) { // create a temporary file and copy the content to the zip stream // once the tmp. filename is known use always the same because otherwise