Made Pocket, Revolution and Groove aware of the SketchBased::BaseFeature property
This commit is contained in:
parent
c93d425393
commit
7d84c7e6f0
|
@ -87,15 +87,32 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
angle *= (-1.0);
|
||||
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
TopoDS_Shape support;
|
||||
try {
|
||||
wires = getSketchWires();
|
||||
support = getSupportShape();
|
||||
} catch (const Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
// update Axis from ReferenceAxis
|
||||
// Get the sketch support
|
||||
TopoDS_Shape support;
|
||||
try {
|
||||
support = getSupportShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// ignore, because support isn't mandatory any more
|
||||
support = TopoDS_Shape();
|
||||
}
|
||||
|
||||
// Get the base shape
|
||||
TopoDS_Shape base;
|
||||
try {
|
||||
base = getBaseShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// fall back to support (for legacy features)
|
||||
base = support;
|
||||
if (base.IsNull())
|
||||
return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the groove!");
|
||||
}
|
||||
|
||||
updateAxis();
|
||||
|
||||
// get revolve axis
|
||||
|
@ -122,6 +139,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
pnt.Transform(invObjLoc.Transformation());
|
||||
dir.Transform(invObjLoc.Transformation());
|
||||
support.Move(invObjLoc);
|
||||
base.Move(invObjLoc);
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||
|
@ -138,10 +156,10 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
|||
this->SubShape.setValue(result);
|
||||
|
||||
// cut out groove to get one result object
|
||||
BRepAlgoAPI_Cut mkCut(support, result);
|
||||
BRepAlgoAPI_Cut mkCut(base, result);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkCut.IsDone())
|
||||
throw Base::Exception("Cut out of support failed");
|
||||
throw Base::Exception("Cut out of base feature failed");
|
||||
|
||||
// we have to get the solids (fuse sometimes creates compounds)
|
||||
TopoDS_Shape solRes = this->getSolid(mkCut.Shape());
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include <Base/Reader.h>
|
||||
#include <App/Document.h>
|
||||
|
||||
#include "Body.h"
|
||||
//#include "Body.h"
|
||||
#include "FeaturePad.h"
|
||||
|
||||
|
||||
|
@ -175,6 +175,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
|||
BRep_Builder builder;
|
||||
builder.MakeCompound(comp);
|
||||
|
||||
// FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results
|
||||
for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) {
|
||||
BRepFeat_MakePrism PrismMaker;
|
||||
PrismMaker.Init(support, xp.Current(), supportface, dir, 2, 1);
|
||||
|
|
|
@ -89,15 +89,33 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
|||
|
||||
Part::Part2DObject* sketch = 0;
|
||||
std::vector<TopoDS_Wire> wires;
|
||||
TopoDS_Shape support;
|
||||
try {
|
||||
sketch = getVerifiedSketch();
|
||||
wires = getSketchWires();
|
||||
support = getSupportShape();
|
||||
} catch (const Base::Exception& e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
}
|
||||
|
||||
// Get the sketch support
|
||||
TopoDS_Shape support;
|
||||
try {
|
||||
support = getSupportShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// ignore, because support isn't mandatory any more
|
||||
support = TopoDS_Shape();
|
||||
}
|
||||
|
||||
// Get the base shape
|
||||
TopoDS_Shape base;
|
||||
try {
|
||||
base = getBaseShape();
|
||||
} catch (const Base::Exception&) {
|
||||
// fall back to support (for legacy features)
|
||||
base = support;
|
||||
if (base.IsNull())
|
||||
return new App::DocumentObjectExecReturn("No sketch support and no base shape: Please tell me where to remove the material of the pocket!");
|
||||
}
|
||||
|
||||
// get the Sketch plane
|
||||
Base::Placement SketchPos = sketch->Placement.getValue();
|
||||
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||
|
@ -112,6 +130,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
|||
|
||||
try {
|
||||
support.Move(invObjLoc);
|
||||
base.Move(invObjLoc);
|
||||
|
||||
gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||
dir.Transform(invObjLoc.Transformation());
|
||||
|
@ -140,6 +159,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
|||
for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) {
|
||||
// Special treatment because often the created stand-alone prism is invalid (empty) because
|
||||
// BRepFeat_MakePrism(..., 2, 1) is buggy
|
||||
// FIXME: If the support shape is not the previous solid in the tree, then there will be unexpected results
|
||||
BRepFeat_MakePrism PrismMaker;
|
||||
PrismMaker.Init(prism, xp.Current(), supportface, dir, 0, 1);
|
||||
PrismMaker.Perform(upToFace);
|
||||
|
@ -170,10 +190,10 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
|||
prism = refineShapeIfActive(prism);
|
||||
this->SubShape.setValue(prism);
|
||||
|
||||
// Cut the SubShape out of the support
|
||||
BRepAlgoAPI_Cut mkCut(support, prism);
|
||||
// Cut the SubShape out of the base feature
|
||||
BRepAlgoAPI_Cut mkCut(base, prism);
|
||||
if (!mkCut.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Pocket: Cut out of support failed");
|
||||
return new App::DocumentObjectExecReturn("Pocket: Cut out of base feature failed");
|
||||
TopoDS_Shape result = mkCut.Shape();
|
||||
// we have to get the solids (fuse sometimes creates compounds)
|
||||
TopoDS_Shape solRes = this->getSolid(result);
|
||||
|
|
|
@ -143,13 +143,22 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
|
|||
// set the additive shape property for later usage in e.g. pattern
|
||||
this->AddShape.setValue(result);
|
||||
|
||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
||||
if (!support.IsNull()) {
|
||||
// if the Base property has a valid shape, fuse the AddShape into it
|
||||
TopoDS_Shape base;
|
||||
try {
|
||||
base = getBaseShape();
|
||||
base.Move(invObjLoc);
|
||||
} catch (const Base::Exception&) {
|
||||
// fall back to support (for legacy features)
|
||||
base = support;
|
||||
}
|
||||
|
||||
if (!base.IsNull()) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
BRepAlgoAPI_Fuse mkFuse(support, result);
|
||||
BRepAlgoAPI_Fuse mkFuse(base, result);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone())
|
||||
throw Base::Exception("Fusion with support failed");
|
||||
throw Base::Exception("Fusion with base feature failed");
|
||||
result = mkFuse.Shape();
|
||||
result = refineShapeIfActive(result);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user