Fix boolean operations (#17119)
* add BRepAlgoAPI wrapper files to CMakeList * introduce wrapper for BRepAlgoAPI_BooleanOperation and derivatives, set sensible default Fuzzyness for boolean operations * allow default fuzzyness to be set in settings - including off * backwards compatibility with OCCT 7.3.3 - removed newer paramateres from wrapper * added missing header * reverted src/Mod/Part/App/OpenCascadeAll.h to original state * implement some changes suggested by @wwmayer * removed unneeded destructor definitions * moved getDefaultFuzzyValue into its own helper class * removed unneeded references to base class default constructor * default to SetRunParallel(Standard_True) as suggested by @FlachyJoe * fixed license header as requested * Added new method to autocalculate fuzzyness to BooleanOperation base class and use it for those parts that do not call the obsolete constructor but also do not set precision * implemented static variable solution as suggested by @wwmayer * added helix for test case * Refactoring FCRepAlgoAPI to FCBRepAlgoAPI * Added Test Case (fuse cylinder with helix with different working and non-working Fuzzy values) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * increased default value of FuzzyBoolean and made tests more robust for compatibility with OCCT 7.3 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixes for FREECAD_USE_PCH - allow testing of FREECAD_USE_PCH on linux with cmake switch (default OFF) * removed surplus line - wasn't needed after all * included precompiled as instructed * set anti-corruption flag in boolean operations, ensures source shape is not damaged in OCCT 7.1 and higher * fix #17085 * disable subtests that were too specific for now * fixed all CLI tests - see comments in Pull Request https://github.com/FreeCAD/FreeCAD/pull/17119#issuecomment-2420772452 * Update src/Mod/PartDesign/PartDesignTests/TestTopologicalNamingProblem.py suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp suggested updated test by CalligaroV Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * Update tests/src/Mod/Part/App/TopoShapeExpansion.cpp Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com> * remove surplus tests from github suggestion interface bug * hide the BooleanFuzzy variable - can now be only set by manually editing the config file i in FCParamGroup "Boolean" <FCFloat Name="BooleanFuzzy" Value="10.000000000000"/> * Suggestion by @FlachyJoe - add validity checks to the base and tool shape in any direct boolean op --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Vincenzo Calligaro <vincenzo.calligaro@gmail.com>
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Cut.h>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
@@ -206,7 +206,7 @@ TopoDS_Shape DrawBrokenView::apply1Break(const App::DocumentObject& breakObj, co
|
||||
moveDir0.Normalize();
|
||||
moveDir0 = DU::closestBasisOriented(moveDir0);
|
||||
auto halfSpace0 = makeHalfSpace(breakPoints.first, moveDir0, breakPoints.second);
|
||||
BRepAlgoAPI_Cut mkCut0(inShape, halfSpace0);
|
||||
FCBRepAlgoAPI_Cut mkCut0(inShape, halfSpace0);
|
||||
if (!mkCut0.IsDone()) {
|
||||
Base::Console().Message("DBV::apply1Break - cut0 failed\n");
|
||||
}
|
||||
@@ -218,7 +218,7 @@ TopoDS_Shape DrawBrokenView::apply1Break(const App::DocumentObject& breakObj, co
|
||||
moveDir1.Normalize();
|
||||
moveDir1 = DU::closestBasisOriented(moveDir1);
|
||||
auto halfSpace1 = makeHalfSpace(breakPoints.second, moveDir1, breakPoints.first);
|
||||
BRepAlgoAPI_Cut mkCut1(inShape, halfSpace1);
|
||||
FCBRepAlgoAPI_Cut mkCut1(inShape, halfSpace1);
|
||||
if (!mkCut1.IsDone()) {
|
||||
Base::Console().Message("DBV::apply1Break - cut1 failed\n");
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@
|
||||
#ifndef _PreComp_
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Common.h>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Cut.h>
|
||||
#include <BRepAlgo_NormalProjection.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
@@ -1176,7 +1176,7 @@ bool DrawComplexSection::boxesIntersect(TopoDS_Face& face, TopoDS_Shape& shape)
|
||||
TopoDS_Shape DrawComplexSection::shapeShapeIntersect(const TopoDS_Shape& shape0,
|
||||
const TopoDS_Shape& shape1)
|
||||
{
|
||||
BRepAlgoAPI_Common anOp;
|
||||
FCBRepAlgoAPI_Common anOp;
|
||||
anOp.SetFuzzyValue(EWTOLERANCE);
|
||||
TopTools_ListOfShape anArg1, anArg2;
|
||||
anArg1.Append(shape0);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Common.h>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
@@ -345,7 +345,7 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
|
||||
grid = mkTransTranslate.Shape();
|
||||
|
||||
//Common(Compound, Face)
|
||||
BRepAlgoAPI_Common mkCommon(face, grid);
|
||||
FCBRepAlgoAPI_Common mkCommon(face, grid);
|
||||
if (!mkCommon.IsDone() ||
|
||||
mkCommon.Shape().IsNull()) {
|
||||
return result;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Common.h>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Fuse.h>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
@@ -645,7 +645,7 @@ int DrawProjectSplit::isSubset(const TopoDS_Edge &edge0, const TopoDS_Edge &edge
|
||||
}
|
||||
|
||||
//bboxes of edges intersect
|
||||
BRepAlgoAPI_Common anOp;
|
||||
FCBRepAlgoAPI_Common anOp;
|
||||
anOp.SetFuzzyValue (FUZZYADJUST * EWTOLERANCE);
|
||||
TopTools_ListOfShape anArg1, anArg2;
|
||||
anArg1.Append (edge0);
|
||||
@@ -683,7 +683,7 @@ int DrawProjectSplit::isSubset(const TopoDS_Edge &edge0, const TopoDS_Edge &edge
|
||||
std::vector<TopoDS_Edge> DrawProjectSplit::fuseEdges(const TopoDS_Edge &edge0, const TopoDS_Edge &edge1)
|
||||
{
|
||||
std::vector<TopoDS_Edge> edgeList;
|
||||
BRepAlgoAPI_Fuse anOp;
|
||||
FCBRepAlgoAPI_Fuse anOp;
|
||||
anOp.SetFuzzyValue (FUZZYADJUST * EWTOLERANCE);
|
||||
TopTools_ListOfShape anArg1, anArg2;
|
||||
anArg1.Append (edge0);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Common.h>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
@@ -294,7 +294,7 @@ void DrawViewDetail::makeDetailShape(const TopoDS_Shape& shape3d, DrawViewPart*
|
||||
TopExp_Explorer expl1(copyShape, TopAbs_SOLID);
|
||||
for (; expl1.More(); expl1.Next()) {
|
||||
const TopoDS_Solid& s = TopoDS::Solid(expl1.Current());
|
||||
BRepAlgoAPI_Common mkCommon(s, tool);
|
||||
FCBRepAlgoAPI_Common mkCommon(s, tool);
|
||||
if (!mkCommon.IsDone()) {
|
||||
continue;
|
||||
}
|
||||
@@ -313,7 +313,7 @@ void DrawViewDetail::makeDetailShape(const TopoDS_Shape& shape3d, DrawViewPart*
|
||||
TopExp_Explorer expl2(copyShape, TopAbs_SHELL, TopAbs_SOLID);
|
||||
for (; expl2.More(); expl2.Next()) {
|
||||
const TopoDS_Shell& s = TopoDS::Shell(expl2.Current());
|
||||
BRepAlgoAPI_Common mkCommon(s, tool);
|
||||
FCBRepAlgoAPI_Common mkCommon(s, tool);
|
||||
if (!mkCommon.IsDone()) {
|
||||
continue;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ void DrawViewDetail::makeDetailShape(const TopoDS_Shape& shape3d, DrawViewPart*
|
||||
TopExp_Explorer expl3(copyShape, TopAbs_EDGE, TopAbs_FACE);
|
||||
for (; expl3.More(); expl3.Next()) {
|
||||
const TopoDS_Edge& e = TopoDS::Edge(expl3.Current());
|
||||
BRepAlgoAPI_Common mkCommon(e, tool);
|
||||
FCBRepAlgoAPI_Common mkCommon(e, tool);
|
||||
if (!mkCommon.IsDone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <Mod/Part/App/FCBRepAlgoAPI_Cut.h>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
@@ -510,7 +510,7 @@ void DrawViewSection::makeSectionCut(const TopoDS_Shape& baseShape)
|
||||
TopExp_Explorer expl(myShape, TopAbs_SOLID);
|
||||
for (; expl.More(); expl.Next()) {
|
||||
const TopoDS_Solid& s = TopoDS::Solid(expl.Current());
|
||||
BRepAlgoAPI_Cut mkCut(s, m_cuttingTool);
|
||||
FCBRepAlgoAPI_Cut mkCut(s, m_cuttingTool);
|
||||
if (!mkCut.IsDone()) {
|
||||
Base::Console().Warning("DVS: Section cut has failed in %s\n", getNameInDocument());
|
||||
continue;
|
||||
@@ -527,7 +527,7 @@ void DrawViewSection::makeSectionCut(const TopoDS_Shape& baseShape)
|
||||
// second cut if requested. Sometimes the first cut includes extra uncut
|
||||
// pieces.
|
||||
if (trimAfterCut()) {
|
||||
BRepAlgoAPI_Cut mkCut2(cutPieces, m_cuttingTool);
|
||||
FCBRepAlgoAPI_Cut mkCut2(cutPieces, m_cuttingTool);
|
||||
if (mkCut2.IsDone()) {
|
||||
m_cutPieces = mkCut2.Shape();
|
||||
if (debugSection()) {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# include <Approx_Curve3d.hxx>
|
||||
# include <BRep_Tool.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
# include <BRepAlgoAPI_Section.hxx>
|
||||
# include <Mod/Part/App/FCBRepAlgoAPI_Section.h>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
@@ -615,7 +615,7 @@ std::vector<Base::Vector3d> BaseGeom::intersection(TechDraw::BaseGeomPtr geom2)
|
||||
return interPoints;
|
||||
}
|
||||
|
||||
BRepAlgoAPI_Section sectionOp(edge1, edge2);
|
||||
FCBRepAlgoAPI_Section sectionOp(edge1, edge2);
|
||||
sectionOp.SetFuzzyValue(FUZZYADJUST*EWTOLERANCE);
|
||||
sectionOp.SetNonDestructive(true);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepAlgoAPI_Fuse.hxx>
|
||||
# include <Mod/Part/App/FCBRepAlgoAPI_Fuse.h>
|
||||
# include <BRepTools.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Iterator.hxx>
|
||||
@@ -354,7 +354,7 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObjec
|
||||
it.Next();
|
||||
for (; it.More(); it.Next()) {
|
||||
const TopoDS_Shape& aChild = it.Value();
|
||||
BRepAlgoAPI_Fuse mkFuse(fusedShape, aChild);
|
||||
FCBRepAlgoAPI_Fuse mkFuse(fusedShape, aChild);
|
||||
// Let's check if the fusion has been successful
|
||||
if (!mkFuse.IsDone()) {
|
||||
Base::Console().Error("SE - Fusion failed\n");
|
||||
|
||||
Reference in New Issue
Block a user