+ fix placement of Pad and Pocket feature to the placement of the underlying sketch/support

+ do all geometry creation operations in the local coordinate system


git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5281 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
logari81 2011-12-12 18:14:44 +00:00
parent 0eb676e354
commit d1db47a43a
2 changed files with 19 additions and 9 deletions

View File

@ -60,7 +60,8 @@ Pad::Pad()
short Pad::mustExecute() const
{
if (Sketch.isTouched() ||
if (Placement.isTouched() ||
Sketch.isTouched() ||
Length.isTouched() ||
MirroredExtent.isTouched() ||
Reversed.isTouched())
@ -118,12 +119,16 @@ App::DocumentObjectExecReturn *Pad::execute(void)
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
// lengthen the vector
SketchOrientationVector *= L;
SketchOrientationVector *= Length.getValue();
this->positionBySketch();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
try {
// extrude the face to a solid
gp_Vec vec(SketchOrientationVector.x,SketchOrientationVector.y,SketchOrientationVector.z);
BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
vec.Transform(invObjLoc.Transformation());
BRepPrimAPI_MakePrism PrismMaker(aFace.Moved(invObjLoc),vec,0,1);
if (PrismMaker.IsDone()) {
// if the sketch has a support fuse them to get one result object (PAD!)
if (SupportObject) {
@ -144,9 +149,9 @@ App::DocumentObjectExecReturn *Pad::execute(void)
}
if (isSolid) {
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(support, result);
BRepAlgoAPI_Fuse mkFuse(support.Moved(invObjLoc), result);
// Let's check if the fusion has been successful
if (!mkFuse.IsDone())
if (!mkFuse.IsDone())
return new App::DocumentObjectExecReturn("Fusion with support failed");
result = mkFuse.Shape();
// we have to get the solids (fuse create seldomly compounds)

View File

@ -63,7 +63,8 @@ Pocket::Pocket()
short Pocket::mustExecute() const
{
if (Sketch.isTouched() ||
if (Placement.isTouched() ||
Sketch.isTouched() ||
Length.isTouched())
return 1;
return 0;
@ -130,9 +131,12 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
// turn around for pockets
SketchVector *= -1;
this->positionBySketch();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
// extrude the face to a solid
gp_Vec vec(SketchVector.x,SketchVector.y,SketchVector.z);
BRepPrimAPI_MakePrism PrismMaker(aFace,vec,0,1);
BRepPrimAPI_MakePrism PrismMaker(aFace.Moved(invObjLoc),vec,0,1);
if (PrismMaker.IsDone()) {
// if the sketch has a support fuse them to get one result object (PAD!)
if (SupportObject) {
@ -143,15 +147,16 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
if (!xp.More())
return new App::DocumentObjectExecReturn("Support shape is not a solid");
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Cut mkCut(support, PrismMaker.Shape());
BRepAlgoAPI_Cut mkCut(support.Moved(invObjLoc), PrismMaker.Shape());
// Let's check if the fusion has been successful
if (!mkCut.IsDone())
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Cut with support failed");
// we have to get the solids (fuse create seldomly compounds)
TopoDS_Shape solRes = this->getSolid(mkCut.Shape());
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
this->Shape.setValue(solRes);
}
else {