Allow Pad and Pocket up to a face with sketch located on datum plane

This commit is contained in:
jrheinlaender 2013-05-23 10:49:27 +04:30 committed by Stefan Tröger
parent 02ba800430
commit a8e4f0f1ca
3 changed files with 19 additions and 5 deletions

View File

@ -157,7 +157,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
TopoDS_Shape prism;
std::string method(Type.getValueAsString());
if (method == "UpToFirst" || method == "UpToLast" || method == "UpToFace") {
// Note: This will throw an exception if the sketch is located on a datum plane
// Note: This will return an unlimited planar face if support is a datum plane
TopoDS_Face supportface = getSupportFace();
supportface.Move(invObjLoc);
@ -180,6 +180,10 @@ App::DocumentObjectExecReturn *Pad::execute(void)
// Note: Multiple independent wires are not supported, we should check for that and
// warn the user
// FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results
// Check supportface for limits, otherwise Perform() throws an exception
TopExp_Explorer Ex(supportface,TopAbs_WIRE);
if (!Ex.More())
supportface = TopoDS_Face();
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(base, sketchshape, supportface, dir, 2, 1);
PrismMaker.Perform(upToFace);

View File

@ -134,7 +134,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
std::string method(Type.getValueAsString());
if (method == "UpToFirst" || method == "UpToFace") {
// Note: This will throw an exception if the sketch is located on a datum plane
// Note: This will return an unlimited planar face if support is a datum plane
TopoDS_Face supportface = getSupportFace();
supportface.Move(invObjLoc);
@ -151,6 +151,10 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
// Special treatment because often the created stand-alone prism is invalid (empty) because
// BRepFeat_MakePrism(..., 2, 1) is buggy
// Check supportface for limits, otherwise Perform() throws an exception
TopExp_Explorer Ex(supportface,TopAbs_WIRE);
if (!Ex.More())
supportface = TopoDS_Face();
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(base, sketchshape, supportface, dir, 0, 1);
PrismMaker.Perform(upToFace);

View File

@ -190,9 +190,15 @@ std::vector<TopoDS_Wire> SketchBased::getSketchWires() const {
const TopoDS_Face SketchBased::getSupportFace() const {
const App::PropertyLinkSub& Support = static_cast<Part::Part2DObject*>(Sketch.getValue())->Support;
App::DocumentObject* ref = Support.getValue();
if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) ||
ref->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()))
throw Base::Exception("Sketch must be located on a face of a solid for this feature to work");
if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
TopoDS_Shape plane = Feature::makeShapeFromPlane(ref);
return TopoDS::Face(plane);
} else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(ref);
return TopoDS::Face(plane->getShape());
}
Part::Feature *part = static_cast<Part::Feature*>(Support.getValue());
if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("No support in sketch");