PD: Migrate onlyHasToRefine
This was a later addition that got missed when merging.
This commit is contained in:
@@ -40,11 +40,6 @@ public:
|
||||
Subtractive
|
||||
};
|
||||
|
||||
enum class RefineErrorPolicy {
|
||||
Raise = 0,
|
||||
Warn
|
||||
};
|
||||
|
||||
FeatureAddSub();
|
||||
|
||||
Type getAddSubType();
|
||||
|
||||
@@ -50,12 +50,40 @@ FeatureRefine::FeatureRefine()
|
||||
this->Refine.setValue(hGrp->GetBool("RefineModel", true));
|
||||
}
|
||||
|
||||
TopoShape FeatureRefine::refineShapeIfActive(const TopoShape& oldShape) const
|
||||
bool FeatureRefine::onlyHasToRefine() const
|
||||
{
|
||||
if( ! Refine.isTouched()){
|
||||
return false;
|
||||
}
|
||||
if (rawShape.isNull()){
|
||||
return false;
|
||||
}
|
||||
std::vector<App::Property*> propList;
|
||||
getPropertyList(propList);
|
||||
for (auto prop : propList){
|
||||
if (prop != &Refine
|
||||
/*&& prop != &SuppressedShape*/
|
||||
&& prop->isTouched()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TopoShape FeatureRefine::refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError) const
|
||||
{
|
||||
if (this->Refine.getValue()) {
|
||||
TopoShape shape(oldShape);
|
||||
// Potentially also "fixShape" to repair it ( as a workaround to OCCT bugs? )
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -35,12 +35,22 @@ class PartDesignExport FeatureRefine : public PartDesign::Feature
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(PartDesign::FeatureRefine);
|
||||
|
||||
public:
|
||||
|
||||
enum class RefineErrorPolicy {
|
||||
Raise = 0,
|
||||
Warn
|
||||
};
|
||||
|
||||
FeatureRefine();
|
||||
|
||||
App::PropertyBool Refine;
|
||||
|
||||
protected:
|
||||
TopoShape refineShapeIfActive(const TopoShape&) const;
|
||||
//store the shape before refinement
|
||||
TopoShape rawShape;
|
||||
|
||||
bool onlyHasToRefine() const;
|
||||
TopoShape refineShapeIfActive(const TopoShape& oldShape, const RefineErrorPolicy onError = RefineErrorPolicy::Raise) const;
|
||||
};
|
||||
|
||||
using FeatureRefinePython = App::FeaturePythonT<FeatureRefine>;
|
||||
|
||||
Reference in New Issue
Block a user