Skip to content

Commit

Permalink
0000684: Check Shape after boolean before refine
Browse files Browse the repository at this point in the history
  • Loading branch information
5263 authored and wwmayer committed Jun 16, 2012
1 parent 9ae9608 commit 107b784
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Mod/Part/App/FeaturePartBoolean.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAlgoAPI_BooleanOperation.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <memory>
#endif

Expand Down Expand Up @@ -82,13 +83,20 @@ App::DocumentObjectExecReturn *Boolean::execute(void)
if (resShape.IsNull()) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");

if (hGrp->GetBool("CheckModel", false)) {
BRepCheck_Analyzer aChecker(resShape);
if (! aChecker.IsValid() ) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
}

std::vector<ShapeHistory> history;
history.push_back(buildHistory(*mkBool.get(), TopAbs_FACE, resShape, BaseShape));
history.push_back(buildHistory(*mkBool.get(), TopAbs_FACE, resShape, ToolShape));

Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");
if (hGrp->GetBool("RefineModel", false)) {
TopoDS_Shape oldShape = resShape;
BRepBuilderAPI_RefineModel mkRefine(oldShape);
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/Part/App/FeaturePartCommon.cpp
Expand Up @@ -25,6 +25,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAlgoAPI_Common.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <Standard_Failure.hxx>
#endif

Expand Down Expand Up @@ -112,6 +113,12 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)

Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");
if (hGrp->GetBool("CheckModel", false)) {
BRepCheck_Analyzer aChecker(resShape);
if (! aChecker.IsValid() ) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
}
if (hGrp->GetBool("RefineModel", false)) {
TopoDS_Shape oldShape = resShape;
BRepBuilderAPI_RefineModel mkRefine(oldShape);
Expand Down
7 changes: 7 additions & 0 deletions src/Mod/Part/App/FeaturePartFuse.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAlgoAPI_Fuse.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <Standard_Failure.hxx>
#endif

Expand Down Expand Up @@ -111,6 +112,12 @@ App::DocumentObjectExecReturn *MultiFuse::execute(void)

Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");
if (hGrp->GetBool("CheckModel", false)) {
BRepCheck_Analyzer aChecker(resShape);
if (! aChecker.IsValid() ) {
return new App::DocumentObjectExecReturn("Resulting shape is invalid");
}
}
if (hGrp->GetBool("RefineModel", false)) {
TopoDS_Shape oldShape = resShape;
BRepBuilderAPI_RefineModel mkRefine(oldShape);
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/Gui/DlgSettingsGeneral.cpp
Expand Up @@ -70,6 +70,7 @@ void DlgSettingsGeneral::saveSettings()
break;
}
ui->checkBooleanRefine->onSave();
ui->checkBooleanCheck->onSave();
}

void DlgSettingsGeneral::loadSettings()
Expand All @@ -79,6 +80,7 @@ void DlgSettingsGeneral::loadSettings()
int unit = hGrp->GetInt("Unit", 0);
ui->comboBoxUnits->setCurrentIndex(unit);
ui->checkBooleanRefine->onRestore();
ui->checkBooleanCheck->onRestore();
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/Part/Gui/DlgSettingsGeneral.ui
Expand Up @@ -87,6 +87,19 @@
</property>
</widget>
</item>
<item row="1" 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>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 107b784

Please sign in to comment.