diff --git a/src/Mod/Part/App/FeatureOffset.cpp b/src/Mod/Part/App/FeatureOffset.cpp index 357344d902..3cffec03fd 100644 --- a/src/Mod/Part/App/FeatureOffset.cpp +++ b/src/Mod/Part/App/FeatureOffset.cpp @@ -132,18 +132,18 @@ App::DocumentObjectExecReturn *Offset2D::execute() if (!source) { return new App::DocumentObjectExecReturn("No source shape linked."); } - const TopoShape shape = Part::Feature::getTopoShape(source, ShapeOption::ResolveLink | ShapeOption::Transform); + auto shape = Feature::getTopoShape(source, ShapeOption::ResolveLink | ShapeOption::Transform); if (shape.isNull()) { return new App::DocumentObjectExecReturn("No source shape linked."); } double offset = Value.getValue(); short mode = (short)Mode.getValue(); - short join = (short)Join.getValue(); - bool fill = Fill.getValue(); - bool inter = Intersection.getValue(); + auto openresult = mode == 0 ? OpenResult::allowOpenResult : OpenResult::noOpenResult; if (mode == 2) return new App::DocumentObjectExecReturn("Mode 'Recto-Verso' is not supported for 2D offset."); - - this->Shape.setValue(shape.makeOffset2D(offset, join, fill, mode == 0, inter)); + auto join = static_cast(Join.getValue()); + auto fill = Fill.getValue() ? FillType::fill : FillType::noFill; + bool inter = Intersection.getValue(); + this->Shape.setValue(TopoShape(0).makeElementOffset2D(shape, offset, join, fill, openresult, inter)); return App::DocumentObject::StdReturn; } diff --git a/tests/src/Mod/Part/App/FeatureOffset.cpp b/tests/src/Mod/Part/App/FeatureOffset.cpp index 7642c16d41..5e85f3fa4e 100644 --- a/tests/src/Mod/Part/App/FeatureOffset.cpp +++ b/tests/src/Mod/Part/App/FeatureOffset.cpp @@ -91,7 +91,7 @@ TEST_F(FeatureOffsetTest, testOffset2D) EXPECT_EQ(getArea(_offset2->Shape.getShape().getShape()), 20); EXPECT_TRUE(boxesMatch(bb, Base::BoundBox3d(-1, -1, 0, 3, 4, 0))); // Assert correct element Map - EXPECT_EQ(_offset2->Shape.getShape().getElementMapSize(), 0); + EXPECT_EQ(_offset2->Shape.getShape().getElementMapSize(), 9); } // NOLINTEND(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers)