PD: Fix regression about single-solid check

For several PD features the single-solid check fails. The regression
is caused by PR 13960 and reported as issue 19002. The reason for the
failure is that the first solid of the output shape is retrieved and
then checked for a single solid. This test will always pass, of course.

The single-solid is fixed for these features:
* Pad
* Pocket (never worked there)
* Fillet
* Chamfer
* Groove (never worked there)
* Revolution (never worked there)
* Loft

Fixes: 17ad40b2c9f0 ("PartDesign: Refactor single-solid rule enforcement")
This commit is contained in:
wmayer
2025-01-27 22:08:11 +01:00
committed by Ladislav Michl
parent f7beb3e41b
commit 25e73289ae
6 changed files with 21 additions and 29 deletions

View File

@@ -159,7 +159,6 @@ App::DocumentObjectExecReturn *Chamfer::execute()
TopTools_ListOfShape aLarg;
aLarg.Append(TopShape.getShape());
bool failed = false;
if (!BRepAlgo::IsValid(aLarg, shape.getShape(), Standard_False, Standard_False)) {
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(shape.getShape(),
@@ -167,21 +166,16 @@ App::DocumentObjectExecReturn *Chamfer::execute()
Precision::Confusion(),
TopAbs_SHAPE);
}
if (!failed) {
// store shape before refinement
this->rawShape = shape;
shape = refineShapeIfActive(shape);
shape = getSolid(shape);
}
// store shape before refinement
this->rawShape = shape;
shape = refineShapeIfActive(shape);
if (!isSingleSolidRuleSatisfied(shape.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
shape = getSolid(shape);
this->Shape.setValue(shape);
if (failed) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Resulting shape is invalid"));
}
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure& e) {

View File

@@ -809,7 +809,7 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt
// store shape before refinement
this->rawShape = result;
solRes = refineShapeIfActive(solRes);
solRes = refineShapeIfActive(result);
if (!isSingleSolidRuleSatisfied(solRes.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
@@ -824,10 +824,10 @@ App::DocumentObjectExecReturn* FeatureExtrude::buildExtrusion(ExtrudeOptions opt
// store shape before refinement
this->rawShape = prism;
prism = refineShapeIfActive(prism);
prism = getSolid(prism);
if (!isSingleSolidRuleSatisfied(prism.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
prism = getSolid(prism);
this->Shape.setValue(prism);
}
else {

View File

@@ -104,7 +104,6 @@ App::DocumentObjectExecReturn *Fillet::execute()
TopTools_ListOfShape aLarg;
aLarg.Append(baseShape.getShape());
bool failed = false;
if (!BRepAlgo::IsValid(aLarg, shape.getShape(), Standard_False, Standard_False)) {
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(shape.getShape(),
@@ -113,20 +112,15 @@ App::DocumentObjectExecReturn *Fillet::execute()
TopAbs_SHAPE);
}
if (!failed) {
// store shape before refinement
this->rawShape = shape;
shape = refineShapeIfActive(shape);
shape = getSolid(shape);
}
// store shape before refinement
this->rawShape = shape;
shape = refineShapeIfActive(shape);
if (!isSingleSolidRuleSatisfied(shape.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
this->Shape.setValue(shape);
if (failed) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
shape = getSolid(shape);
this->Shape.setValue(shape);
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure& e) {

View File

@@ -185,17 +185,17 @@ App::DocumentObjectExecReturn *Groove::execute()
}catch(Standard_Failure &) {
return new App::DocumentObjectExecReturn("Failed to cut base feature");
}
boolOp = this->getSolid(boolOp);
if (boolOp.isNull())
TopoShape solid = this->getSolid(boolOp);
if (solid.isNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
// store shape before refinement
this->rawShape = boolOp;
boolOp = refineShapeIfActive(boolOp);
boolOp = getSolid(boolOp);
if (!isSingleSolidRuleSatisfied(boolOp.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
boolOp = getSolid(boolOp);
Shape.setValue(boolOp);
return App::DocumentObject::StdReturn;
}

View File

@@ -266,10 +266,10 @@ App::DocumentObjectExecReturn *Loft::execute()
// store shape before refinement
this->rawShape = boolOp;
boolOp = refineShapeIfActive(boolOp);
boolOp = getSolid(boolOp);
if (!isSingleSolidRuleSatisfied(boolOp.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
boolOp = getSolid(boolOp);
Shape.setValue(boolOp);
return App::DocumentObject::StdReturn;
}

View File

@@ -228,7 +228,11 @@ App::DocumentObjectExecReturn* Revolution::execute()
this->rawShape = result;
result = refineShapeIfActive(result);
}
this->Shape.setValue(getSolid(result));
if (!isSingleSolidRuleSatisfied(result.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
}
result = getSolid(result);
this->Shape.setValue(result);
}
else {
return new App::DocumentObjectExecReturn(