Part: Feature Offset2D fix #22563

This commit is contained in:
tomate44
2025-07-22 18:09:32 +02:00
committed by Chris Hennes
parent 8d1c60bb44
commit 4614e6b4f6
2 changed files with 7 additions and 7 deletions

View File

@@ -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<JoinType>(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;
}

View File

@@ -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)