[PD Helix] allow refinement to fail
This commit is contained in:
committed by
Chris Hennes
parent
d1cdcd18bf
commit
8945971578
@@ -64,13 +64,21 @@ short FeatureAddSub::mustExecute() const
|
||||
return PartDesign::Feature::mustExecute();
|
||||
}
|
||||
|
||||
|
||||
TopoShape FeatureAddSub::refineShapeIfActive(const TopoShape& oldShape) const
|
||||
TopoShape FeatureAddSub::refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError) const
|
||||
{
|
||||
if (this->Refine.getValue()) {
|
||||
TopoShape shape(oldShape);
|
||||
// this->fixShape(shape); // Todo: Not clear that this is required
|
||||
return shape.makeElementRefine();
|
||||
try{
|
||||
return shape.makeElementRefine();
|
||||
}
|
||||
catch (Standard_Failure& err) {
|
||||
if(onError == RefineErrorPolicy::Warn){
|
||||
Base::Console().Warning((std::string("Refine failed: ") + err.GetMessageString()).c_str());
|
||||
} else {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
return oldShape;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ public:
|
||||
Subtractive
|
||||
};
|
||||
|
||||
enum class RefineErrorPolicy {
|
||||
Raise = 0,
|
||||
Warn
|
||||
};
|
||||
|
||||
FeatureAddSub();
|
||||
|
||||
Type getAddSubType();
|
||||
@@ -54,7 +59,7 @@ public:
|
||||
protected:
|
||||
Type addSubType{Additive};
|
||||
|
||||
TopoShape refineShapeIfActive(const TopoShape&) const;
|
||||
TopoShape refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError = RefineErrorPolicy::Raise) const;
|
||||
};
|
||||
|
||||
using FeatureAddSubPython = App::FeaturePythonT<FeatureAddSub>;
|
||||
|
||||
@@ -272,7 +272,7 @@ App::DocumentObjectExecReturn* Helix::execute()
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Error: Result has multiple solids"));
|
||||
}
|
||||
|
||||
boolOp = refineShapeIfActive(boolOp);
|
||||
boolOp = refineShapeIfActive(boolOp, RefineErrorPolicy::Warn);
|
||||
Shape.setValue(getSolid(boolOp));
|
||||
}
|
||||
else if (getAddSubType() == FeatureAddSub::Subtractive) {
|
||||
@@ -301,7 +301,7 @@ App::DocumentObjectExecReturn* Helix::execute()
|
||||
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Error: Result has multiple solids"));
|
||||
}
|
||||
|
||||
boolOp = refineShapeIfActive(boolOp);
|
||||
boolOp = refineShapeIfActive(boolOp, RefineErrorPolicy::Warn);
|
||||
Shape.setValue(getSolid(boolOp));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user