PartDesign: fix DressUp base shape checking

This commit is contained in:
Zheng, Lei
2020-02-23 06:47:17 +08:00
committed by wwmayer
parent b97f37cf9a
commit 2fee0c3b0c
3 changed files with 26 additions and 13 deletions

View File

@@ -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;
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");
}
}
const Part::TopoShape& result = BaseObject->Shape.getShape();
if (result.getShape().IsNull())
throw Base::ValueError("Base feature's TopoShape is invalid");
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;
}

View File

@@ -72,7 +72,7 @@ public:
/// 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);

View File

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