From 312cd1f500afe8541652cab2d6edada5cd1f20d7 Mon Sep 17 00:00:00 2001 From: jgv Date: Fri, 20 Jul 2012 17:12:28 +0400 Subject: [PATCH] 0023244: Bug of BRepClass_FaceClassifier: it does not take into account the tolerance --- src/BOPTools/BOPTools_Tools2D.cxx | 3 ++ src/BRepClass/BRepClass_Intersector.cxx | 43 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/BOPTools/BOPTools_Tools2D.cxx b/src/BOPTools/BOPTools_Tools2D.cxx index 5c62345868..6ea6565995 100755 --- a/src/BOPTools/BOPTools_Tools2D.cxx +++ b/src/BOPTools/BOPTools_Tools2D.cxx @@ -704,6 +704,9 @@ static Standard_Real aT, aT1, aT2; Handle(Geom_Curve)aC1=BRep_Tool::Curve(aE, aT1, aT2); + if (aC1.IsNull()) + BRep_Tool::Range(aE, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); return aT; } diff --git a/src/BRepClass/BRepClass_Intersector.cxx b/src/BRepClass/BRepClass_Intersector.cxx index a339f8331a..f984049971 100755 --- a/src/BRepClass/BRepClass_Intersector.cxx +++ b/src/BRepClass/BRepClass_Intersector.cxx @@ -36,6 +36,10 @@ #include +#include +#include +#include + //======================================================================= //function : BRepClass_Intersector //purpose : @@ -73,6 +77,45 @@ void BRepClass_Intersector::Perform(const gp_Lin2d& L, TopExp::Vertices(EE, Vdeb, Vfin); BRepAdaptor_Curve2d C(EE,F); Standard_Real deb = C.FirstParameter(), fin = C.LastParameter(); + + // Case of "ON": direct check of belonging to edge + // taking into account the tolerance + Extrema_ExtPC2d theExtPC2d(L.Location(), C); + Standard_Real MinDist = RealLast(), aDist; + Standard_Integer MinInd = 0, i; + if (theExtPC2d.IsDone()) + { + for (i = 1; i <= theExtPC2d.NbExt(); i++) + { + aDist = theExtPC2d.SquareDistance(i); + if (aDist < MinDist) + { + MinDist = aDist; + MinInd = i; + } + } + } + if (MinInd) + MinDist = sqrt(MinDist); + if (MinDist <= Tol) + { + gp_Pnt2d pnt_exact = (theExtPC2d.Point(MinInd)).Value(); + Standard_Real par = (theExtPC2d.Point(MinInd)).Parameter(); + IntRes2d_Transition tr_on_lin(IntRes2d_Head); + IntRes2d_Position pos_on_curve = IntRes2d_Middle; + if (Abs(par - deb) <= Precision::Confusion()) + pos_on_curve = IntRes2d_Head; + else if (Abs(par - fin) <= Precision::Confusion()) + pos_on_curve = IntRes2d_End; + IntRes2d_Transition tr_on_curve(pos_on_curve); + IntRes2d_IntersectionPoint pnt_inter(pnt_exact, 0., par, + tr_on_lin, tr_on_curve, Standard_False); + this->Append(pnt_inter); + done = Standard_True; + return; + } + /////////////// + gp_Pnt2d pdeb,pfin; C.D0(deb,pdeb); C.D0(fin,pfin); -- 2.20.1