0000727: Keep faces colors on boolean operations

This commit is contained in:
wmayer
2012-06-04 11:43:20 +02:00
parent e277bca478
commit 33fb521137
7 changed files with 302 additions and 64 deletions

View File

@@ -30,7 +30,9 @@
#include "FeaturePartCommon.h"
#include "modelRefine.h"
#include <App/Application.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
using namespace Part;
@@ -84,17 +86,17 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
if (s.size() >= 2) {
try {
std::vector<ShapeHistory> history;
TopoDS_Shape res = s.front();
TopoDS_Shape resShape = s.front();
for (std::vector<TopoDS_Shape>::iterator it = s.begin()+1; it != s.end(); ++it) {
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Common mkCommon(res, *it);
BRepAlgoAPI_Common mkCommon(resShape, *it);
// Let's check if the fusion has been successful
if (!mkCommon.IsDone())
throw Base::Exception("Intersection failed");
res = mkCommon.Shape();
resShape = mkCommon.Shape();
ShapeHistory hist1 = buildHistory(mkCommon, TopAbs_FACE, res, mkCommon.Shape1());
ShapeHistory hist2 = buildHistory(mkCommon, TopAbs_FACE, res, mkCommon.Shape2());
ShapeHistory hist1 = buildHistory(mkCommon, TopAbs_FACE, resShape, mkCommon.Shape1());
ShapeHistory hist2 = buildHistory(mkCommon, TopAbs_FACE, resShape, mkCommon.Shape2());
if (history.empty()) {
history.push_back(hist1);
history.push_back(hist2);
@@ -105,9 +107,21 @@ App::DocumentObjectExecReturn *MultiCommon::execute(void)
history.push_back(hist2);
}
}
if (res.IsNull())
if (resShape.IsNull())
throw Base::Exception("Resulting shape is invalid");
this->Shape.setValue(res);
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);
resShape = mkRefine.Shape();
ShapeHistory hist = buildHistory(mkRefine, TopAbs_FACE, resShape, oldShape);
for (std::vector<ShapeHistory>::iterator jt = history.begin(); jt != history.end(); ++jt)
*jt = joinHistory(*jt, hist);
}
this->Shape.setValue(resShape);
this->History.setValues(history);
}
catch (Standard_Failure) {