PartDesign: fix DressUp base shape checking
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user