#include <Standard_Failure.hxx>
#include <gp_Pnt2d.hxx>
+#include <Extrema_GenLocateExtPS.hxx>
+
//==================================================================================
// function : IntWalk_PWalking::IntWalk_PWalking
// purpose :
close(Standard_False),
fleche(Deflection),
tolconf(Epsilon),
-sensCheminement(1),
+sensCheminement(1),
myIntersectionOn2S(Caro1,Caro2,TolTangency),
STATIC_BLOCAGE_SUR_PAS_TROP_GRAND(0),
STATIC_PRECEDENT_INFLEXION(0)
{
Perform(ParDep,Um1,Vm1,Um2,Vm2,UM1,VM1,UM2,VM2);
}
+
+//=======================================================================
+//function : SQDistPointSurface
+//purpose : Returns square distance between thePnt and theSurf.
+// (theU0, theV0) is initial point for extrema
+//=======================================================================
+static Standard_Real SQDistPointSurface(const gp_Pnt &thePnt,
+ const Adaptor3d_Surface& theSurf,
+ const Standard_Real theU0,
+ const Standard_Real theV0)
+{
+ const Extrema_GenLocateExtPS aExtPS(thePnt, theSurf, theU0, theV0,
+ Precision::PConfusion(), Precision::PConfusion());
+ if(!aExtPS.IsDone())
+ return RealLast();
+
+ return aExtPS.SquareDistance();
+}
+
+//==================================================================================
+// function : IsTangentExtCheck
+// purpose : Additional check if the surfaces are tangent.
+// Checks if any point in one surface lie in another surface
+// (with given tolerance)
+//==================================================================================
+static Standard_Boolean IsTangentExtCheck(const Handle(Adaptor3d_HSurface)& theSurf1,
+ const Handle(Adaptor3d_HSurface)& theSurf2,
+ const Standard_Real theU10,
+ const Standard_Real theV10,
+ const Standard_Real theU20,
+ const Standard_Real theV20,
+ const Standard_Real theArrStep[])
+{
+ {
+ gp_Pnt aPt;
+ gp_Vec aDu1, aDv1, aDu2, aDv2;
+ theSurf1->D1(theU10, theV10, aPt, aDu1, aDv1);
+ theSurf2->D1(theU20, theV20, aPt, aDu2, aDv2);
+
+ const gp_Vec aN1(aDu1.Crossed(aDv1)),
+ aN2(aDu2.Crossed(aDv2));
+ const Standard_Real aDP = aN1.Dot(aN2),
+ aSQ1 = aN1.SquareMagnitude(),
+ aSQ2 = aN2.SquareMagnitude();
+
+ if((aSQ1 < RealSmall()) || (aSQ2 < RealSmall()))
+ return Standard_True; //Tangent
+
+ if(aDP*aDP < 0.9998*aSQ1*aSQ2)
+ {//cos(ang N1<->N2) < 0.9999
+ return Standard_False; //Not tangent
+ }
+ }
+
+ const Standard_Real aSQToler = 4.0e-14;
+ const Standard_Integer aNbItems = 4;
+ const Standard_Real aParUS1[aNbItems] = { theU10 + theArrStep[0],
+ theU10 - theArrStep[0],
+ theU10, theU10};
+ const Standard_Real aParVS1[aNbItems] = { theV10, theV10,
+ theV10 + theArrStep[1],
+ theV10 - theArrStep[1]};
+ const Standard_Real aParUS2[aNbItems] = { theU20 + theArrStep[2],
+ theU20 - theArrStep[2],
+ theU20, theU20};
+ const Standard_Real aParVS2[aNbItems] = { theV20, theV20,
+ theV20 + theArrStep[3],
+ theV20 - theArrStep[3]};
+
+ for(Standard_Integer i = 0; i < aNbItems; i++)
+ {
+ gp_Pnt aP(theSurf1->Value(aParUS1[i], aParVS1[i]));
+ const Standard_Real aSqDist = SQDistPointSurface(aP, theSurf2->Surface(), theU20, theV20);
+ if(aSqDist > aSQToler)
+ return Standard_False;
+ }
+
+ for(Standard_Integer i = 0; i < aNbItems; i++)
+ {
+ gp_Pnt aP(theSurf2->Value(aParUS2[i], aParVS2[i]));
+ const Standard_Real aSqDist = SQDistPointSurface(aP, theSurf1->Surface(), theU10, theV10);
+ if(aSqDist > aSQToler)
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
+
//==================================================================================
// function : Perform
// purpose :
Standard_Boolean bTestFirstPoint = Standard_True;
previousPoint.Parameters(Param(1),Param(2),Param(3),Param(4));
+
+ if(IsTangentExtCheck(Caro1, Caro2, Param(1), Param(2), Param(3), Param(4), pasuv))
+ return;
+
AddAPoint(line,previousPoint);
//
IntWalk_StatusDeflection Status = IntWalk_OK;