+ Add option to refine solid on sketch-based features

This commit is contained in:
wmayer
2013-09-21 09:16:44 +02:00
parent 3c55434939
commit 79e9f108e6
11 changed files with 70 additions and 9 deletions

View File

@@ -134,6 +134,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
if (RevolMaker.IsDone()) {
TopoDS_Shape result = RevolMaker.Shape();
// set the subtractive shape property for later usage in e.g. pattern
result = refineShapeIfActive(result);
this->SubShape.setValue(result);
// cut out groove to get one result object
@@ -147,6 +148,7 @@ App::DocumentObjectExecReturn *Groove::execute(void)
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
solRes = refineShapeIfActive(solRes);
this->Shape.setValue(solRes);
}
else

View File

@@ -160,6 +160,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
return new App::DocumentObjectExecReturn("Pad: Resulting shape is empty");
// set the additive shape property for later usage in e.g. pattern
prism = refineShapeIfActive(prism);
this->AddShape.setValue(prism);
// if the sketch has a support fuse them to get one result object
@@ -175,6 +176,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
// lets check if the result is a solid
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Pad: Resulting shape is not a solid");
solRes = refineShapeIfActive(solRes);
this->Shape.setValue(solRes);
} else {
this->Shape.setValue(prism);

View File

@@ -143,13 +143,15 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
if (!PrismMaker.IsDone())
return new App::DocumentObjectExecReturn("Pocket: Up to face: Could not extrude the sketch!");
TopoDS_Shape prism = PrismMaker.Shape();
prism = refineShapeIfActive(prism);
// And the really expensive way to get the SubShape...
BRepAlgoAPI_Cut mkCut(support, prism);
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Pocket: Up to face: Could not get SubShape!");
// FIXME: In some cases this affects the Shape property: It is set to the same shape as the SubShape!!!!
this->SubShape.setValue(mkCut.Shape());
TopoDS_Shape result = refineShapeIfActive(mkCut.Shape());
this->SubShape.setValue(result);
this->Shape.setValue(prism);
} else {
TopoDS_Shape prism;
@@ -159,6 +161,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
return new App::DocumentObjectExecReturn("Pocket: Resulting shape is empty");
// set the subtractive shape property for later usage in e.g. pattern
prism = refineShapeIfActive(prism);
this->SubShape.setValue(prism);
// Cut the SubShape out of the support
@@ -170,6 +173,7 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
TopoDS_Shape solRes = this->getSolid(result);
if (solRes.IsNull())
return new App::DocumentObjectExecReturn("Pocket: Resulting shape is not a solid");
solRes = refineShapeIfActive(solRes);
remapSupportShape(solRes);
this->Shape.setValue(solRes);
}

View File

@@ -139,6 +139,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
if (RevolMaker.IsDone()) {
TopoDS_Shape result = RevolMaker.Shape();
result = refineShapeIfActive(result);
// set the additive shape property for later usage in e.g. pattern
this->AddShape.setValue(result);
@@ -150,6 +151,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
if (!mkFuse.IsDone())
throw Base::Exception("Fusion with support failed");
result = mkFuse.Shape();
result = refineShapeIfActive(result);
}
this->Shape.setValue(result);

View File

@@ -66,6 +66,9 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <Mod/Part/App/modelRefine.h>
#include "FeatureSketchBased.h"
using namespace PartDesign;
@@ -924,3 +927,16 @@ bool SketchBased::isParallelPlane(const TopoDS_Shape& s1, const TopoDS_Shape& s2
return false;
}
TopoDS_Shape SketchBased::refineShapeIfActive(const TopoDS_Shape& oldShape) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign");
if (hGrp->GetBool("RefineModel", false)) {
Part::BRepBuilderAPI_RefineModel mkRefine(oldShape);
TopoDS_Shape resShape = mkRefine.Shape();
return resShape;
}
return oldShape;
}

View File

@@ -86,6 +86,7 @@ protected:
bool isEqualGeometry(const TopoDS_Shape&, const TopoDS_Shape&) const;
bool isQuasiEqual(const TopoDS_Shape&, const TopoDS_Shape&) const;
void remapSupportShape(const TopoDS_Shape&);
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
/// Extract a face from a given LinkSub
static void getUpToFaceFromLinkSub(TopoDS_Face& upToFace,

View File

@@ -43,6 +43,9 @@
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <Mod/Part/App/modelRefine.h>
using namespace PartDesign;
@@ -262,11 +265,13 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
// lets check if the result is a solid
if (result.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid", *o);
result = refineShapeIfActive(result);
} else {
BRepAlgoAPI_Cut mkCut(support, transformedShapes);
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Cut out of support failed", *o);
result = mkCut.Shape();
result = refineShapeIfActive(result);
}
support = result; // Use result of this operation for fuse/cut of next original
@@ -292,4 +297,17 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
return App::DocumentObject::StdReturn;
}
TopoDS_Shape Transformed::refineShapeIfActive(const TopoDS_Shape& oldShape) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/PartDesign");
if (hGrp->GetBool("RefineModel", false)) {
Part::BRepBuilderAPI_RefineModel mkRefine(oldShape);
TopoDS_Shape resShape = mkRefine.Shape();
return resShape;
}
return oldShape;
}
}

View File

@@ -81,6 +81,7 @@ public:
protected:
virtual void positionBySupport(void);
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
std::list<gp_Trsf> rejected;
};