-//=======================================================================
-//function : GetProjectPoint
-//purpose :
-//=======================================================================
- Standard_Boolean BOPTools_AlgoTools::GetProjectPoint(const TopoDS_Face& aF,
- const gp_Pnt& aPF,
- const TopoDS_Face& aF1,
- gp_Pnt& aPF1,
- gp_Dir& aDNF1,
- Handle(BOPInt_Context)& aContext)
-{
- Standard_Boolean bRet = Standard_False;
- Handle(Geom_Surface) aS, aS1;
- GeomAbs_SurfaceType aTS, aTS1;
- Handle(Geom_CylindricalSurface) aCS, aCS1;
- Standard_Real aR, aR1, dR, aU, aV, aDMin;
- //
- aS = BRep_Tool::Surface(aF);
- aS1 = BRep_Tool::Surface(aF1);
- GeomAdaptor_Surface aGAS(aS), aGAS1(aS1);
- //
- aTS = aGAS.GetType();
- aTS1 = aGAS1.GetType();
- //
- if (!(aTS == GeomAbs_Cylinder && aTS1 == GeomAbs_Cylinder)) {
- return bRet;
- }
- //
- aCS = Handle(Geom_CylindricalSurface)::DownCast(aS);
- aCS1 = Handle(Geom_CylindricalSurface)::DownCast(aS1);
- //
- if (aCS.IsNull() || aCS1.IsNull()) {
- return bRet;
- }
- //
- if (!aCS->Axis().IsParallel(aCS1->Axis(), Precision::Angular())) {
- return bRet;
- }
- //
- aR = aCS->Radius();
- aR1 = aCS1->Radius();
- dR = fabs(aR - aR1);
- //
- if (dR < Precision::Angular()) {
- return bRet;
- }
-
- gp_Lin aL(aCS->Axis()), aL1(aCS1->Axis());
- if (Abs(aL.Distance(aL1) - dR) < Precision::Confusion()) {
- GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF1);
- aProjector.Perform(aPF);
- if (!aProjector.IsDone()) {
- return bRet;
- }
- aDMin = aProjector.LowerDistance();
- if (aDMin > dR) {
- return bRet;
- }
- aProjector.LowerDistanceParameters(aU, aV);
- Handle(Geom_Surface) aS = BRep_Tool::Surface(aF1);
- BOPTools_AlgoTools3D::GetNormalToSurface (aS, aU, aV, aDNF1);
- aS->D0(aU, aV, aPF1);
- bRet = !bRet;
- }
- return bRet;
-}
-