+ Add option to refine solid on sketch-based features
This commit is contained in:
parent
86bea1ef22
commit
3cc032c11e
|
@ -180,7 +180,7 @@ GeomAbs_OtherSurface
|
|||
};
|
||||
*/
|
||||
namespace Part {
|
||||
class BRepBuilderAPI_RefineModel : public BRepBuilderAPI_MakeShape
|
||||
class PartExport BRepBuilderAPI_RefineModel : public BRepBuilderAPI_MakeShape
|
||||
{
|
||||
public:
|
||||
BRepBuilderAPI_RefineModel(const TopoDS_Shape&);
|
||||
|
|
|
@ -69,8 +69,9 @@ void DlgSettingsGeneral::saveSettings()
|
|||
Interface_Static::SetCVal("write.step.unit","MM");
|
||||
break;
|
||||
}
|
||||
ui->checkBooleanRefine->onSave();
|
||||
ui->checkBooleanCheck->onSave();
|
||||
ui->checkBooleanRefine->onSave();
|
||||
ui->checkSketchBaseRefine->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsGeneral::loadSettings()
|
||||
|
@ -79,8 +80,9 @@ void DlgSettingsGeneral::loadSettings()
|
|||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
|
||||
int unit = hGrp->GetInt("Unit", 0);
|
||||
ui->comboBoxUnits->setCurrentIndex(unit);
|
||||
ui->checkBooleanRefine->onRestore();
|
||||
ui->checkBooleanCheck->onRestore();
|
||||
ui->checkBooleanRefine->onRestore();
|
||||
ui->checkSketchBaseRefine->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,6 +75,19 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBooleanCheck">
|
||||
<property name="text">
|
||||
<string>Automatically check model after boolean operation</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CheckModel</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Part/Boolean</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBooleanRefine">
|
||||
<property name="text">
|
||||
<string>Automatically refine model after boolean operation</string>
|
||||
|
@ -87,16 +100,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkBooleanCheck">
|
||||
<item row="2" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="checkSketchBaseRefine">
|
||||
<property name="text">
|
||||
<string>Automatically check model after boolean operation</string>
|
||||
<string>Automatically refine model after sketch-based operation</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CheckModel</cstring>
|
||||
<cstring>RefineModel</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Part/Boolean</cstring>
|
||||
<cstring>Mod/PartDesign</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void positionBySupport(void);
|
||||
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
|
||||
|
||||
std::list<gp_Trsf> rejected;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user