From 02b258b41e6b81c5fa229734c05c49db352ae679 Mon Sep 17 00:00:00 2001 From: emv Date: Fri, 3 Aug 2018 11:11:06 +0300 Subject: [PATCH] BOPAlgo_PaveFiller::PerformEE - Consider the IsOnPave check satisfying for vertex creation and remove other checks. BOPTools_AlgoTools3D::PointInFace - Making the method more robust by checking more hatching lines. --- src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx | 41 +------------------ src/BOPTools/BOPTools_AlgoTools3D.cxx | 59 +++++++++++++++++++-------- 2 files changed, 43 insertions(+), 57 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index c9b4d013f0..4ffc8fdcd8 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -399,46 +399,7 @@ void BOPAlgo_PaveFiller::PerformEE() aTolVnew = aTolMin; } } - // <-LXBR - { - Standard_Integer nVS[2], iFound; - Standard_Real aTolVx, aD2, aDT2; - TColStd_MapOfInteger aMV; - gp_Pnt aPx; - // - iFound=0; - j=-1; - aMV.Add(nV[0]); - aMV.Add(nV[1]); - // - if (aMV.Contains(nV[2])) { - ++j; - nVS[j]=nV[2]; - } - if (aMV.Contains(nV[3])) { - ++j; - nVS[j]=nV[3]; - } - // - for (Standard_Integer k1=0; k1<=j; ++k1) { - const TopoDS_Vertex& aVx= *(TopoDS_Vertex*)&(myDS->Shape(nVS[k1])); - aTolVx=BRep_Tool::Tolerance(aVx); - aPx=BRep_Tool::Pnt(aVx); - aD2=aPnew.SquareDistance(aPx); - // - aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx); - // - if (aD2UVBounds(theF, aUMin, aUMax, aVMin, aVMax); - // - gp_Dir2d aD2D(0. , 1.); - aUx = IntTools_Tools::IntermediatePoint(aUMin, aUMax); - // - for (i = 0; i < 2; ++i) { - gp_Pnt2d aP2D(aUx, 0.); + + // Middle point of the 2d bounding box of the face + Standard_Real aUx = IntTools_Tools::IntermediatePoint(aUMin, aUMax), + aVx = IntTools_Tools::IntermediatePoint(aVMin, aVMax); + + for (Standard_Integer i = 0; i < 4; ++i) + { + // Point to start the hatching line + gp_Pnt2d aP2D(aUx, aVx); + // Direction for the hatching line + gp_Dir2d aD2D = (i < 2) ? gp::DY2d() : gp::DX2d(); Handle(Geom2d_Line) aL2D = new Geom2d_Line (aP2D, aD2D); iErr = BOPTools_AlgoTools3D::PointInFace (theF, aL2D, theP, theP2D, theContext); - if (iErr == 0) { + if (iErr == 0) // done - break; - } - else { - // possible reason - incorrect computation of the 2d box of the face. - // try to compute the point with the translated line. - aUx = aUMax - (aUx - aUMin); + return iErr; + else + { + // Possible reason - incorrect computation of the 2d box of the face. + // Try to compute the point with the translated line. + if (i < 2) + aUx = aUMax - (aUx - aUMin); + else + aVx = aVMax - (aVx - aVMin); } } - // + + // The tries to find the point using the hatching line passing through + // the middle of the bounding box of the face have failed. + // Try to start hatching line at the middle of the edges of the face. + TopExp_Explorer anExpE(theF, TopAbs_EDGE); + for (; anExpE.More(); anExpE.Next()) + { + const TopoDS_Edge& aE = TopoDS::Edge(anExpE.Current()); + Standard_Real aT1, aT2; + BRep_Tool::Range(aE, aT1, aT2); + iErr = BOPTools_AlgoTools3D::PointInFace + (theF, aE, 0.5 * (aT1 + aT2), 0.0, theP, theP2D, theContext); + if (iErr == 0) + return iErr; + } + return iErr; } //======================================================================= -- 2.39.5