From 370101f340b73710130bb24f0ad83adcd1243b97 Mon Sep 17 00:00:00 2001 From: nbv Date: Tue, 28 Feb 2017 10:45:51 +0300 Subject: [PATCH] 0028491: Incomplete section curve The main idea of the fix is to forbid check if intersection curve lies in the some face (with input tolerance) if we have 2D-intersection curve on this face (we consider that necessary tolerance has been computed in intersection algorithm honestly). If we do not have 2D-curve on this face then we need check as before. New algorithm is implemented in IntTools_Context::IsValidBlockForFaces(...) method. ------ src\Extrema\Extrema_GenExtPS.cxx No principled changes have been made. --- src/Extrema/Extrema_GenExtPS.cxx | 36 +++++++++++++------ src/IntTools/IntTools_Context.cxx | 59 ++++++++++++++++--------------- tests/bugs/modalg_6/bug24094 | 24 +++++++++++++ tests/bugs/modalg_6/bug28491 | 26 ++++++++++++++ 4 files changed, 106 insertions(+), 39 deletions(-) create mode 100644 tests/bugs/modalg_6/bug24094 create mode 100644 tests/bugs/modalg_6/bug28491 diff --git a/src/Extrema/Extrema_GenExtPS.cxx b/src/Extrema/Extrema_GenExtPS.cxx index 5165bab4df..029e15c97f 100644 --- a/src/Extrema/Extrema_GenExtPS.cxx +++ b/src/Extrema/Extrema_GenExtPS.cxx @@ -896,17 +896,31 @@ void Extrema_GenExtPS::Perform(const gp_Pnt& P) { Standard_Real Dist; - for (NoU = 1; NoU <= myusample; NoU++) { - for (NoV = 1; NoV <= myvsample; NoV++) { - Dist = myPoints->Value(NoU, NoV).GetSqrDistance(); - if ((myPoints->Value(NoU-1,NoV-1).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU-1,NoV ).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU-1,NoV+1).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU ,NoV-1).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU ,NoV+1).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU+1,NoV-1).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU+1,NoV ).GetSqrDistance() <= Dist) && - (myPoints->Value(NoU+1,NoV+1).GetSqrDistance() <= Dist)) { + for (NoU = 1; NoU <= myusample; NoU++) + { + for (NoV = 1; NoV <= myvsample; NoV++) + { + const Extrema_POnSurfParams &aParamMain = myPoints->Value(NoU, NoV); + const Extrema_POnSurfParams &aParam1 = myPoints->Value(NoU - 1, NoV - 1); + const Extrema_POnSurfParams &aParam2 = myPoints->Value(NoU - 1, NoV); + const Extrema_POnSurfParams &aParam3 = myPoints->Value(NoU - 1, NoV + 1); + const Extrema_POnSurfParams &aParam4 = myPoints->Value(NoU, NoV - 1); + const Extrema_POnSurfParams &aParam5 = myPoints->Value(NoU, NoV + 1); + const Extrema_POnSurfParams &aParam6 = myPoints->Value(NoU + 1, NoV - 1); + const Extrema_POnSurfParams &aParam7 = myPoints->Value(NoU + 1, NoV); + const Extrema_POnSurfParams &aParam8 = myPoints->Value(NoU + 1, NoV + 1); + + Dist = aParamMain.GetSqrDistance(); + + if ((aParam1.GetSqrDistance() <= Dist) && + (aParam2.GetSqrDistance() <= Dist) && + (aParam3.GetSqrDistance() <= Dist) && + (aParam4.GetSqrDistance() <= Dist) && + (aParam5.GetSqrDistance() <= Dist) && + (aParam6.GetSqrDistance() <= Dist) && + (aParam7.GetSqrDistance() <= Dist) && + (aParam8.GetSqrDistance() <= Dist)) + { // Find maximum. FindSolution(P, myPoints->Value(NoU, NoV)); } diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx index 9809fbf594..0ba725b007 100644 --- a/src/IntTools/IntTools_Context.cxx +++ b/src/IntTools/IntTools_Context.cxx @@ -803,41 +803,44 @@ Standard_Boolean IntTools_Context::IsValidBlockForFace //function : IsValidBlockForFaces //purpose : //======================================================================= -Standard_Boolean IntTools_Context::IsValidBlockForFaces - (const Standard_Real aT1, - const Standard_Real aT2, - const IntTools_Curve& aC, - const TopoDS_Face& aF1, - const TopoDS_Face& aF2, - const Standard_Real aTol) +Standard_Boolean IntTools_Context::IsValidBlockForFaces(const Standard_Real theT1, + const Standard_Real theT2, + const IntTools_Curve& theC, + const TopoDS_Face& theF1, + const TopoDS_Face& theF2, + const Standard_Real theTol) { - Standard_Boolean bFlag1, bFlag2; - // - Handle(Geom2d_Curve) aPC1 = aC.FirstCurve2d(); - Handle(Geom2d_Curve) aPC2 = aC.SecondCurve2d(); - if( !aPC1.IsNull() && !aPC2.IsNull() ) { - Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(aT1, aT2); - gp_Pnt2d aPnt2D; + const Standard_Integer aNbElem = 2; + const Handle(Geom2d_Curve) &aPC1 = theC.FirstCurve2d(); + const Handle(Geom2d_Curve) &aPC2 = theC.SecondCurve2d(); + const Handle(Geom_Curve) &aC3D = theC.Curve(); + + const Handle(Geom2d_Curve)* anArrPC[aNbElem] = { &aPC1, &aPC2 }; + const TopoDS_Face* anArrF[aNbElem] = { &theF1, &theF2 }; + const Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(theT1, theT2); + const gp_Pnt aP(aC3D->Value(aMidPar)); - aPC1->D0(aMidPar, aPnt2D); - bFlag1 = IsPointInOnFace(aF1, aPnt2D); + Standard_Boolean bFlag = Standard_True; + gp_Pnt2d aPnt2D; - if( !bFlag1 ) - return bFlag1; + for (Standard_Integer i = 0; (i < 2) && bFlag; ++i) + { + const Handle(Geom2d_Curve) &aPC = *anArrPC[i]; + const TopoDS_Face &aF = *anArrF[i]; - aPC2->D0(aMidPar, aPnt2D); - bFlag2 = IsPointInOnFace(aF2, aPnt2D); - return bFlag2; + if (!aPC.IsNull()) + { + aPC->D0(aMidPar, aPnt2D); + bFlag = IsPointInOnFace(aF, aPnt2D); + } + else + { + bFlag = IsValidPointForFace(aP, aF, theTol); + } } - // - bFlag1=IsValidBlockForFace (aT1, aT2, aC, aF1, aTol); - if (!bFlag1) { - return bFlag1; - } - bFlag2=IsValidBlockForFace (aT1, aT2, aC, aF2, aTol); - return bFlag2; + return bFlag; } //======================================================================= //function : IsVertexOnLine diff --git a/tests/bugs/modalg_6/bug24094 b/tests/bugs/modalg_6/bug24094 new file mode 100644 index 0000000000..4ec6c34daa --- /dev/null +++ b/tests/bugs/modalg_6/bug24094 @@ -0,0 +1,24 @@ +puts "========" +puts "OCC24094" +puts "========" +puts "" +########################################## +## Issure by option of BRepAlgoAPI_Section +########################################## + + +restore [locate_data_file bug24094_face.brep] a +plane p 183.6 0 0 1 0 0 0 1 0 +mkface f p + +bsection r1 a f +bsection r2 a f -na +bsection r3 a f -n2d2 +bsection r4 a f -n2d +bsection r5 a f -n2d -na + +checknbshapes r1 -vertex 2 -edge 1 -t +checknbshapes r2 -vertex 2 -edge 1 -t +checknbshapes r3 -vertex 2 -edge 1 -t +checknbshapes r4 -vertex 2 -edge 1 -t +checknbshapes r5 -vertex 2 -edge 1 -t diff --git a/tests/bugs/modalg_6/bug28491 b/tests/bugs/modalg_6/bug28491 new file mode 100644 index 0000000000..0bc054e510 --- /dev/null +++ b/tests/bugs/modalg_6/bug28491 @@ -0,0 +1,26 @@ +puts "========" +puts "OCC28491" +puts "========" +puts "" +########################################## +## Incomplete section curve +########################################## + +set GoodLength 4.617 + +restore [locate_data_file bug28491_H0.brep] h0 +restore [locate_data_file bug28491_Prism.brep] s1 +explode h0 f + +bsection r1 h0_57 s1 +bsection result h0_57 s1 -n2d2 + +checkprops r1 -l $GoodLength +checkprops result -l $GoodLength + +smallview +don h0_57 +fit +display result s1 + +checkview -screenshot -2d -path ${imagedir}/${test_image}.png