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);
|
angle *= (-1.0);
|
||||||
|
|
||||||
std::vector<TopoDS_Wire> wires;
|
std::vector<TopoDS_Wire> wires;
|
||||||
TopoDS_Shape support;
|
|
||||||
try {
|
try {
|
||||||
wires = getSketchWires();
|
wires = getSketchWires();
|
||||||
support = getSupportShape();
|
|
||||||
} catch (const Base::Exception& e) {
|
} catch (const Base::Exception& e) {
|
||||||
return new App::DocumentObjectExecReturn(e.what());
|
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();
|
updateAxis();
|
||||||
|
|
||||||
// get revolve axis
|
// get revolve axis
|
||||||
|
@ -122,6 +139,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||||
pnt.Transform(invObjLoc.Transformation());
|
pnt.Transform(invObjLoc.Transformation());
|
||||||
dir.Transform(invObjLoc.Transformation());
|
dir.Transform(invObjLoc.Transformation());
|
||||||
support.Move(invObjLoc);
|
support.Move(invObjLoc);
|
||||||
|
base.Move(invObjLoc);
|
||||||
sketchshape.Move(invObjLoc);
|
sketchshape.Move(invObjLoc);
|
||||||
|
|
||||||
// Check distance between sketchshape and axis - to avoid failures and crashes
|
// Check distance between sketchshape and axis - to avoid failures and crashes
|
||||||
|
@ -138,10 +156,10 @@ App::DocumentObjectExecReturn *Groove::execute(void)
|
||||||
this->SubShape.setValue(result);
|
this->SubShape.setValue(result);
|
||||||
|
|
||||||
// cut out groove to get one result object
|
// 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
|
// Let's check if the fusion has been successful
|
||||||
if (!mkCut.IsDone())
|
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)
|
// we have to get the solids (fuse sometimes creates compounds)
|
||||||
TopoDS_Shape solRes = this->getSolid(mkCut.Shape());
|
TopoDS_Shape solRes = this->getSolid(mkCut.Shape());
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include <Base/Reader.h>
|
#include <Base/Reader.h>
|
||||||
#include <App/Document.h>
|
#include <App/Document.h>
|
||||||
|
|
||||||
#include "Body.h"
|
//#include "Body.h"
|
||||||
#include "FeaturePad.h"
|
#include "FeaturePad.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
||||||
BRep_Builder builder;
|
BRep_Builder builder;
|
||||||
builder.MakeCompound(comp);
|
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()) {
|
for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) {
|
||||||
BRepFeat_MakePrism PrismMaker;
|
BRepFeat_MakePrism PrismMaker;
|
||||||
PrismMaker.Init(support, xp.Current(), supportface, dir, 2, 1);
|
PrismMaker.Init(support, xp.Current(), supportface, dir, 2, 1);
|
||||||
|
|
|
@ -89,15 +89,33 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
||||||
|
|
||||||
Part::Part2DObject* sketch = 0;
|
Part::Part2DObject* sketch = 0;
|
||||||
std::vector<TopoDS_Wire> wires;
|
std::vector<TopoDS_Wire> wires;
|
||||||
TopoDS_Shape support;
|
|
||||||
try {
|
try {
|
||||||
sketch = getVerifiedSketch();
|
sketch = getVerifiedSketch();
|
||||||
wires = getSketchWires();
|
wires = getSketchWires();
|
||||||
support = getSupportShape();
|
|
||||||
} catch (const Base::Exception& e) {
|
} catch (const Base::Exception& e) {
|
||||||
return new App::DocumentObjectExecReturn(e.what());
|
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
|
// get the Sketch plane
|
||||||
Base::Placement SketchPos = sketch->Placement.getValue();
|
Base::Placement SketchPos = sketch->Placement.getValue();
|
||||||
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
Base::Rotation SketchOrientation = SketchPos.getRotation();
|
||||||
|
@ -111,7 +129,8 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
||||||
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
TopLoc_Location invObjLoc = this->getLocation().Inverted();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
support.Move(invObjLoc);
|
support.Move(invObjLoc);
|
||||||
|
base.Move(invObjLoc);
|
||||||
|
|
||||||
gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z);
|
gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||||
dir.Transform(invObjLoc.Transformation());
|
dir.Transform(invObjLoc.Transformation());
|
||||||
|
@ -140,6 +159,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
||||||
for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) {
|
for (TopExp_Explorer xp(sketchshape, TopAbs_FACE); xp.More(); xp.Next()) {
|
||||||
// Special treatment because often the created stand-alone prism is invalid (empty) because
|
// Special treatment because often the created stand-alone prism is invalid (empty) because
|
||||||
// BRepFeat_MakePrism(..., 2, 1) is buggy
|
// 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;
|
BRepFeat_MakePrism PrismMaker;
|
||||||
PrismMaker.Init(prism, xp.Current(), supportface, dir, 0, 1);
|
PrismMaker.Init(prism, xp.Current(), supportface, dir, 0, 1);
|
||||||
PrismMaker.Perform(upToFace);
|
PrismMaker.Perform(upToFace);
|
||||||
|
@ -170,10 +190,10 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
|
||||||
prism = refineShapeIfActive(prism);
|
prism = refineShapeIfActive(prism);
|
||||||
this->SubShape.setValue(prism);
|
this->SubShape.setValue(prism);
|
||||||
|
|
||||||
// Cut the SubShape out of the support
|
// Cut the SubShape out of the base feature
|
||||||
BRepAlgoAPI_Cut mkCut(support, prism);
|
BRepAlgoAPI_Cut mkCut(base, prism);
|
||||||
if (!mkCut.IsDone())
|
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();
|
TopoDS_Shape result = mkCut.Shape();
|
||||||
// we have to get the solids (fuse sometimes creates compounds)
|
// we have to get the solids (fuse sometimes creates compounds)
|
||||||
TopoDS_Shape solRes = this->getSolid(result);
|
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
|
// set the additive shape property for later usage in e.g. pattern
|
||||||
this->AddShape.setValue(result);
|
this->AddShape.setValue(result);
|
||||||
|
|
||||||
// if the sketch has a support fuse them to get one result object (PAD!)
|
// if the Base property has a valid shape, fuse the AddShape into it
|
||||||
if (!support.IsNull()) {
|
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:
|
// 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
|
// Let's check if the fusion has been successful
|
||||||
if (!mkFuse.IsDone())
|
if (!mkFuse.IsDone())
|
||||||
throw Base::Exception("Fusion with support failed");
|
throw Base::Exception("Fusion with base feature failed");
|
||||||
result = mkFuse.Shape();
|
result = mkFuse.Shape();
|
||||||
result = refineShapeIfActive(result);
|
result = refineShapeIfActive(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user