From: jfa Date: Mon, 6 Sep 2021 12:03:21 +0000 (+0300) Subject: Usage of ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces and BlockFix_Uni... X-Git-Tag: V9_8_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8db1e932e38aeeebef835d9e87b1e8781f55f821;p=modules%2Fgeom.git Usage of ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces and BlockFix_UnionEdges. --- diff --git a/src/BlockFix/BlockFix_BlockFixAPI.cxx b/src/BlockFix/BlockFix_BlockFixAPI.cxx index 1701aaef5..1990d3ad0 100644 --- a/src/BlockFix/BlockFix_BlockFixAPI.cxx +++ b/src/BlockFix/BlockFix_BlockFixAPI.cxx @@ -31,6 +31,8 @@ #include #include +#include +#include #include @@ -67,10 +69,31 @@ void BlockFix_BlockFixAPI::Perform() myShape = BlockFix::RefillProblemFaces(myShape); // faces unification - BlockFix_UnionFaces aFaceUnifier; - aFaceUnifier.GetTolerance() = myTolerance; - aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; - TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); + TopoDS_Shape aResult = myShape; + if (myOptimumNbFaces > 1) { + // use old algo BlockFix_UnionFaces for exactly given resulting number of faces + BlockFix_UnionFaces aFaceUnifier; + aFaceUnifier.GetTolerance() = myTolerance; + aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; + aResult = aFaceUnifier.Perform(aResult); + } + else if (myOptimumNbFaces != -1) { + // use OCCT algo ShapeUpgrade_UnifySameDomain + ShapeUpgrade_UnifySameDomain Unifier; + //only faces + Standard_Boolean isUnifyEdges = Standard_False; + Standard_Boolean isUnifyFaces = Standard_True; + Standard_Boolean isConcatBSplines = Standard_True; + Unifier.Initialize(myShape, isUnifyEdges, isUnifyFaces, isConcatBSplines); + //Unifier.SetLinearTolerance(myTolerance); + Unifier.SetLinearTolerance(Precision::Confusion()); + Unifier.SetAngularTolerance(Precision::Confusion()); + Unifier.Build(); + aResult = Unifier.Shape(); + } + else { + // myOptimumNbFaces == -1 means do not union faces + } // avoid problem with degenerated edges appearance // due to shape quality regress @@ -79,8 +102,16 @@ void BlockFix_BlockFixAPI::Perform() aResult = RemLoc.GetResult(); // edges unification - BlockFix_UnionEdges anEdgeUnifier; - myShape = anEdgeUnifier.Perform(aResult,myTolerance); + //BlockFix_UnionEdges anEdgeUnifier; + //myShape = anEdgeUnifier.Perform(aResult,myTolerance); + ShapeUpgrade_UnifySameDomain Unifier; + Standard_Boolean isUnifyEdges = Standard_True; + Standard_Boolean isUnifyFaces = Standard_False; //only edges + Standard_Boolean isConcatBSplines = Standard_True; + Unifier.Initialize(aResult, isUnifyEdges, isUnifyFaces, isConcatBSplines); + Unifier.SetLinearTolerance(myTolerance); + Unifier.Build(); + myShape = Unifier.Shape(); TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); myShape = aRes; diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx index 22d2b0b52..92dbc1be2 100644 --- a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -63,6 +63,8 @@ #include #include +#include + #include #include #include @@ -742,10 +744,19 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(Handle(TFunction_Logbook)& log) c Standard_NullObject::Raise("Null Shape given"); } - BlockFix_UnionFaces aFaceUnifier; - - aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces. - aShape = aFaceUnifier.Perform(aBlockOrComp); + //BlockFix_UnionFaces aFaceUnifier; + //aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces. + //aShape = aFaceUnifier.Perform(aBlockOrComp); + // Use OCCT algo ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces: + Standard_Boolean isUnifyEdges = Standard_False; + Standard_Boolean isUnifyFaces = Standard_True; + Standard_Boolean isConcatBSplines = Standard_True; + ShapeUpgrade_UnifySameDomain aUnifier (aBlockOrComp, + isUnifyEdges, isUnifyFaces, isConcatBSplines); + aUnifier.SetLinearTolerance(Precision::Confusion()); + aUnifier.SetAngularTolerance(Precision::Confusion()); + aUnifier.Build(); + aShape = aUnifier.Shape(); } else { // unknown function type return 0; }