From c6bb5335415a3665c7e8c83b5769b117b647cef4 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sun, 23 Feb 2020 06:47:17 +0800 Subject: [PATCH] PartDesign: fix DressUp base shape checking --- src/Mod/PartDesign/App/Feature.cpp | 29 ++++++++++++++++------- src/Mod/PartDesign/App/Feature.h | 2 +- src/Mod/PartDesign/App/FeatureDressUp.cpp | 8 +++---- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 50568a396277..c9cba283245d 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -156,17 +156,30 @@ const TopoDS_Shape& Feature::getBaseShape() const { return result; } -const Part::TopoShape Feature::getBaseTopoShape() const { - const Part::Feature* BaseObject = getBaseObject(); +Part::TopoShape Feature::getBaseTopoShape(bool silent) const { + Part::TopoShape result; - if (BaseObject->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId())) { - throw Base::ValueError("Base shape of shape binder cannot be used"); - } + const Part::Feature* BaseObject = getBaseObject(silent); + if (!BaseObject) + return result; - const Part::TopoShape& result = BaseObject->Shape.getShape(); - if (result.getShape().IsNull()) - throw Base::ValueError("Base feature's TopoShape is invalid"); + if(BaseObject != BaseFeature.getValue()) { + if (BaseObject->isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) || + BaseObject->isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId())) + { + if(silent) + return result; + throw Base::ValueError("Base shape of shape binder cannot be used"); + } + } + result = BaseObject->Shape.getShape(); + if(!silent) { + if (result.isNull()) + throw Base::ValueError("Base feature's TopoShape is invalid"); + if (!result.hasSubShape(TopAbs_SOLID)) + throw Base::ValueError("Base feature's shape is not a solid"); + } return result; } diff --git a/src/Mod/PartDesign/App/Feature.h b/src/Mod/PartDesign/App/Feature.h index cccb5de69265..99c763d32503 100644 --- a/src/Mod/PartDesign/App/Feature.h +++ b/src/Mod/PartDesign/App/Feature.h @@ -72,7 +72,7 @@ class PartDesignExport Feature : public Part::Feature /// Returns the BaseFeature property's shape (if any) virtual const TopoDS_Shape& getBaseShape() const; /// Returns the BaseFeature property's TopoShape (if any) - const Part::TopoShape getBaseTopoShape() const; + Part::TopoShape getBaseTopoShape(bool silent=false) const; virtual PyObject* getPyObject(void); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 5bafab6420a3..59f748d4cc70 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -191,14 +191,14 @@ void DressUp::onChanged(const App::Property* prop) s = base->AddSubShape.getShape(); } else { addSubType = base->getAddSubType(); - auto baseBase = base->getBaseObject(true); - if(!baseBase) { + Part::TopoShape baseShape = base->getBaseTopoShape(true); + if (baseShape.isNull() || !baseShape.hasSubShape(TopAbs_SOLID)) { s = Shape.getShape(); addSubType = Additive; } else if (addSubType == Additive) - s = Shape.getShape().cut(base->getBaseTopoShape().getShape()); + s = Shape.getShape().cut(baseShape.getShape()); else - s = base->getBaseTopoShape().cut(Shape.getValue()); + s = baseShape.cut(Shape.getValue()); } AddSubShape.setValue(s); }