diff --git a/src/Mod/Part/App/FeaturePartFuse.cpp b/src/Mod/Part/App/FeaturePartFuse.cpp index e2ec36028c..bd9e760b94 100644 --- a/src/Mod/Part/App/FeaturePartFuse.cpp +++ b/src/Mod/Part/App/FeaturePartFuse.cpp @@ -251,10 +251,8 @@ App::DocumentObjectExecReturn *MultiFuse::execute() throw Base::RuntimeError("MultiFusion failed"); } - // TopoDS_Shape resShape = mkFuse.Shape(); TopoShape res(0); - res.makeShapeWithElementMap(mkFuse.Shape(), MapperMaker(mkFuse), shapes, OpCodes::Fuse); - + res = res.makeShapeWithElementMap(mkFuse.Shape(), MapperMaker(mkFuse), shapes, OpCodes::Fuse); for (const auto& it2 : shapes) { history.push_back( buildHistory(mkFuse, TopAbs_FACE, res.getShape(), it2.getShape())); @@ -276,7 +274,15 @@ App::DocumentObjectExecReturn *MultiFuse::execute() } if (this->Refine.getValue()) { try { - res = res.makeElementRefine(); + TopoDS_Shape oldShape = res.getShape(); + BRepBuilderAPI_RefineModel mkRefine(oldShape); + // We just built an element map above for the fuse, don't erase it for a refine. + res.setShape(mkRefine.Shape(), false); + ShapeHistory hist = + buildHistory(mkRefine, TopAbs_FACE, res.getShape(), oldShape); + for (auto& jt : history) { + jt = joinHistory(jt, hist); + } } catch (Standard_Failure&) { // do nothing diff --git a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py index 5e55272864..ec87ea61ed 100644 --- a/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py +++ b/src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py @@ -136,6 +136,34 @@ class TestTopologicalNamingProblem(unittest.TestCase): self.assertEqual(len(edges), 4) self.assertEqual(len(vertexes), 4) + + def testPartDesignBasicFusion(self): + """ Test that a basic fusion creates an element map, and refine retains it """ + # Arrange + doc = self.Doc + box1 = doc.addObject("Part::Box","Box") + if App.GuiUp: + mat = App.Material() + mat.AmbientColor = (128,0,0) + box1.ViewObject.ShapeAppearance = mat # Change color ( material ) for at least one + box2 = doc.addObject("Part::Box","Box001") + box3 = doc.addObject("Part::Box","Box002") + cyl1 = doc.addObject("Part::Cylinder","Cylinder") + fuse1 = doc.addObject("Part::MultiFuse","Fusion") + doc.Fusion.Shapes = [box1, box2] + fuse2 = doc.addObject("Part::MultiFuse","Fusion001") + doc.Fusion001.Shapes = [box3, cyl1] + doc.recompute() + # Assert + self.assertEqual(fuse1.Shape.ElementMapSize,26) + self.assertEqual(fuse2.Shape.ElementMapSize,44) + # Act + doc.Fusion.Refine = True # activate refinement + doc.Fusion001.Refine = True # activate refinement + doc.recompute() + self.assertEqual(fuse1.Shape.ElementMapSize,26) + self.assertEqual(fuse2.Shape.ElementMapSize,44) + def testPartDesignElementMapPad(self): """ Test that padding a sketch results in a correct element map. Note that comprehensive testing of the geometric functionality of the Pad is in TestPad.py """