+ Add option to refine solid on sketch-based features

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

View File

@ -180,7 +180,7 @@ GeomAbs_OtherSurface
}; };
*/ */
namespace Part { namespace Part {
class BRepBuilderAPI_RefineModel : public BRepBuilderAPI_MakeShape class PartExport BRepBuilderAPI_RefineModel : public BRepBuilderAPI_MakeShape
{ {
public: public:
BRepBuilderAPI_RefineModel(const TopoDS_Shape&); BRepBuilderAPI_RefineModel(const TopoDS_Shape&);

View File

@ -69,8 +69,9 @@ void DlgSettingsGeneral::saveSettings()
Interface_Static::SetCVal("write.step.unit","MM"); Interface_Static::SetCVal("write.step.unit","MM");
break; break;
} }
ui->checkBooleanRefine->onSave();
ui->checkBooleanCheck->onSave(); ui->checkBooleanCheck->onSave();
ui->checkBooleanRefine->onSave();
ui->checkSketchBaseRefine->onSave();
} }
void DlgSettingsGeneral::loadSettings() void DlgSettingsGeneral::loadSettings()
@ -79,8 +80,9 @@ void DlgSettingsGeneral::loadSettings()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
int unit = hGrp->GetInt("Unit", 0); int unit = hGrp->GetInt("Unit", 0);
ui->comboBoxUnits->setCurrentIndex(unit); ui->comboBoxUnits->setCurrentIndex(unit);
ui->checkBooleanRefine->onRestore();
ui->checkBooleanCheck->onRestore(); ui->checkBooleanCheck->onRestore();
ui->checkBooleanRefine->onRestore();
ui->checkSketchBaseRefine->onRestore();
} }
/** /**

View File

@ -75,6 +75,19 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <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"> <widget class="Gui::PrefCheckBox" name="checkBooleanRefine">
<property name="text"> <property name="text">
<string>Automatically refine model after boolean operation</string> <string>Automatically refine model after boolean operation</string>
@ -87,16 +100,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="checkBooleanCheck"> <widget class="Gui::PrefCheckBox" name="checkSketchBaseRefine">
<property name="text"> <property name="text">
<string>Automatically check model after boolean operation</string> <string>Automatically refine model after sketch-based operation</string>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>CheckModel</cstring> <cstring>RefineModel</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>Mod/Part/Boolean</cstring> <cstring>Mod/PartDesign</cstring>
</property> </property>
</widget> </widget>
</item> </item>

View File

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

View File

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

View File

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

View File

@ -139,6 +139,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
if (RevolMaker.IsDone()) { if (RevolMaker.IsDone()) {
TopoDS_Shape result = RevolMaker.Shape(); TopoDS_Shape result = RevolMaker.Shape();
result = refineShapeIfActive(result);
// 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);
@ -150,6 +151,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
if (!mkFuse.IsDone()) if (!mkFuse.IsDone())
throw Base::Exception("Fusion with support failed"); throw Base::Exception("Fusion with support failed");
result = mkFuse.Shape(); result = mkFuse.Shape();
result = refineShapeIfActive(result);
} }
this->Shape.setValue(result); this->Shape.setValue(result);

View File

@ -66,6 +66,9 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Base/Exception.h> #include <Base/Exception.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <Mod/Part/App/modelRefine.h>
#include "FeatureSketchBased.h" #include "FeatureSketchBased.h"
using namespace PartDesign; using namespace PartDesign;
@ -924,3 +927,16 @@ bool SketchBased::isParallelPlane(const TopoDS_Shape& s1, const TopoDS_Shape& s2
return false; 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 isEqualGeometry(const TopoDS_Shape&, const TopoDS_Shape&) const;
bool isQuasiEqual(const TopoDS_Shape&, const TopoDS_Shape&) const; bool isQuasiEqual(const TopoDS_Shape&, const TopoDS_Shape&) const;
void remapSupportShape(const TopoDS_Shape&); void remapSupportShape(const TopoDS_Shape&);
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
/// Extract a face from a given LinkSub /// Extract a face from a given LinkSub
static void getUpToFaceFromLinkSub(TopoDS_Face& upToFace, static void getUpToFaceFromLinkSub(TopoDS_Face& upToFace,

View File

@ -43,6 +43,9 @@
#include <Base/Console.h> #include <Base/Console.h>
#include <Base/Exception.h> #include <Base/Exception.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <Mod/Part/App/modelRefine.h>
using namespace PartDesign; using namespace PartDesign;
@ -262,11 +265,13 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
// lets check if the result is a solid // lets check if the result is a solid
if (result.IsNull()) if (result.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid", *o); return new App::DocumentObjectExecReturn("Resulting shape is not a solid", *o);
result = refineShapeIfActive(result);
} else { } else {
BRepAlgoAPI_Cut mkCut(support, transformedShapes); BRepAlgoAPI_Cut mkCut(support, transformedShapes);
if (!mkCut.IsDone()) if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Cut out of support failed", *o); return new App::DocumentObjectExecReturn("Cut out of support failed", *o);
result = mkCut.Shape(); result = mkCut.Shape();
result = refineShapeIfActive(result);
} }
support = result; // Use result of this operation for fuse/cut of next original 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; 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: protected:
virtual void positionBySupport(void); virtual void positionBySupport(void);
TopoDS_Shape refineShapeIfActive(const TopoDS_Shape&) const;
std::list<gp_Trsf> rejected; std::list<gp_Trsf> rejected;
}; };