Bos #16182. Use OCCT algo UnifySameDomain. Fix for compatibility with old OCCT versions.

This commit is contained in:
jfa 2021-09-08 12:03:03 +03:00
parent 8db1e932e3
commit 6a0d013cc0
2 changed files with 22 additions and 5 deletions

View File

@ -36,6 +36,8 @@
#include <Precision.hxx> #include <Precision.hxx>
#include <Basics_OCCTVersion.hxx>
IMPLEMENT_STANDARD_RTTIEXT(BlockFix_BlockFixAPI, Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(BlockFix_BlockFixAPI, Standard_Transient)
//======================================================================= //=======================================================================
@ -70,6 +72,12 @@ void BlockFix_BlockFixAPI::Perform()
// faces unification // faces unification
TopoDS_Shape aResult = myShape; TopoDS_Shape aResult = myShape;
#if OCC_VERSION_LARGE < 0x07050301
BlockFix_UnionFaces aFaceUnifier;
aFaceUnifier.GetTolerance() = myTolerance;
aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
aResult = aFaceUnifier.Perform(aResult);
#else
if (myOptimumNbFaces > 1) { if (myOptimumNbFaces > 1) {
// use old algo BlockFix_UnionFaces for exactly given resulting number of faces // use old algo BlockFix_UnionFaces for exactly given resulting number of faces
BlockFix_UnionFaces aFaceUnifier; BlockFix_UnionFaces aFaceUnifier;
@ -94,6 +102,7 @@ void BlockFix_BlockFixAPI::Perform()
else { else {
// myOptimumNbFaces == -1 means do not union faces // myOptimumNbFaces == -1 means do not union faces
} }
#endif
// avoid problem with degenerated edges appearance // avoid problem with degenerated edges appearance
// due to shape quality regress // due to shape quality regress
@ -102,8 +111,10 @@ void BlockFix_BlockFixAPI::Perform()
aResult = RemLoc.GetResult(); aResult = RemLoc.GetResult();
// edges unification // edges unification
//BlockFix_UnionEdges anEdgeUnifier; #if OCC_VERSION_LARGE < 0x07050301
//myShape = anEdgeUnifier.Perform(aResult,myTolerance); BlockFix_UnionEdges anEdgeUnifier;
myShape = anEdgeUnifier.Perform(aResult,myTolerance);
#else
ShapeUpgrade_UnifySameDomain Unifier; ShapeUpgrade_UnifySameDomain Unifier;
Standard_Boolean isUnifyEdges = Standard_True; Standard_Boolean isUnifyEdges = Standard_True;
Standard_Boolean isUnifyFaces = Standard_False; //only edges Standard_Boolean isUnifyFaces = Standard_False; //only edges
@ -112,6 +123,7 @@ void BlockFix_BlockFixAPI::Perform()
Unifier.SetLinearTolerance(myTolerance); Unifier.SetLinearTolerance(myTolerance);
Unifier.Build(); Unifier.Build();
myShape = Unifier.Shape(); myShape = Unifier.Shape();
#endif
TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
myShape = aRes; myShape = aRes;

View File

@ -102,6 +102,8 @@
#include <Standard_TypeMismatch.hxx> #include <Standard_TypeMismatch.hxx>
#include <Standard_ConstructionError.hxx> #include <Standard_ConstructionError.hxx>
#include <Basics_OCCTVersion.hxx>
//======================================================================= //=======================================================================
//function : GetID //function : GetID
//purpose : //purpose :
@ -744,9 +746,11 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(Handle(TFunction_Logbook)& log) c
Standard_NullObject::Raise("Null Shape given"); Standard_NullObject::Raise("Null Shape given");
} }
//BlockFix_UnionFaces aFaceUnifier; #if OCC_VERSION_LARGE < 0x07050301
//aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces. BlockFix_UnionFaces aFaceUnifier;
//aShape = aFaceUnifier.Perform(aBlockOrComp); aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
aShape = aFaceUnifier.Perform(aBlockOrComp);
#else
// Use OCCT algo ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces: // Use OCCT algo ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces:
Standard_Boolean isUnifyEdges = Standard_False; Standard_Boolean isUnifyEdges = Standard_False;
Standard_Boolean isUnifyFaces = Standard_True; Standard_Boolean isUnifyFaces = Standard_True;
@ -757,6 +761,7 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(Handle(TFunction_Logbook)& log) c
aUnifier.SetAngularTolerance(Precision::Confusion()); aUnifier.SetAngularTolerance(Precision::Confusion());
aUnifier.Build(); aUnifier.Build();
aShape = aUnifier.Shape(); aShape = aUnifier.Shape();
#endif
} else { // unknown function type } else { // unknown function type
return 0; return 0;
} }