Skip to content

Commit

Permalink
PartDesign: fix DressUp base shape checking
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Feb 23, 2020
1 parent 8832356 commit c6bb533
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
29 changes: 21 additions & 8 deletions src/Mod/PartDesign/App/Feature.cpp
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/PartDesign/App/Feature.h
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/App/FeatureDressUp.cpp
Expand Up @@ -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);
}
Expand Down

0 comments on commit c6bb533

Please sign in to comment.