- gp_Vec aVec(aHypr.Location(),Point);
- Standard_Real X = aVec.Dot(aHypr.XAxis().Direction());
- Standard_Real Y = aVec.Dot(aHypr.YAxis().Direction());
- Standard_Real Z = aVec.Dot(aHypr.Axis().Direction());
- Standard_Real AA = aHypr.MajorRadius()*aHypr.MajorRadius();
- Standard_Real BB = aHypr.MinorRadius()*aHypr.MinorRadius();
- Standard_Real tY1 = Sqrt( Abs( (X*X/AA - 1.)*BB ) );
- Standard_Real tY2 = Sqrt( (X*X/AA + 1.)*BB );
- Delta = Max( Abs(Z), Min( Abs( tY1 - Y ), Abs( tY2 - Y ) ) );
- }
- else return Standard_False;
- return Standard_True;
-}
-
-
-//=======================================================================
-//function : Parameter
-//purpose : Get parameter on curve of given point
-// return FALSE if point is far from curve than tolerance
-// or computation fails
-//=======================================================================
-
-Standard_Boolean GeomLib_Tool::Parameter(const Handle(Geom_Curve)& Curve,
- const gp_Pnt& Point,
- const Standard_Real Tolerance,
- Standard_Real& U)
-{
- U = 0.;
- if( Curve.IsNull() ) return Standard_False;
- Handle(Standard_Type) KindOfCurve = Curve->DynamicType();
-
- // process analitical curves
- if( KindOfCurve == STANDARD_TYPE (Geom_Line) ||
- KindOfCurve == STANDARD_TYPE (Geom_Circle) ||
- KindOfCurve == STANDARD_TYPE (Geom_Ellipse) ||
- KindOfCurve == STANDARD_TYPE (Geom_Parabola) ||
- KindOfCurve == STANDARD_TYPE (Geom_Hyperbola) )
- {
- Standard_Real aTol = (Tolerance < MAXTOLERANCEGEOM) ? Tolerance : MAXTOLERANCEGEOM;
- Standard_Real D = 0.;
- Standard_Boolean isOk = ProcessAnalyticalCurves(Curve,Point,D);
- if( !isOk ) return Standard_False;
- if( Abs(D) > aTol ) return Standard_False;
-
- if( KindOfCurve == STANDARD_TYPE (Geom_Line) )
- {
- Handle(Geom_Line) aGL = Handle(Geom_Line)::DownCast(Curve);
- gp_Lin aLin = aGL->Lin();
- U = ElCLib::Parameter(aLin,Point);
- }
- else if( KindOfCurve == STANDARD_TYPE (Geom_Circle) )
- {
- Handle(Geom_Circle) aGC = Handle(Geom_Circle)::DownCast(Curve);
- gp_Circ aCirc = aGC->Circ();
- U = ElCLib::Parameter(aCirc,Point);
- }
- else if( KindOfCurve == STANDARD_TYPE (Geom_Ellipse) )
- {
- Handle(Geom_Ellipse) aGE = Handle(Geom_Ellipse)::DownCast(Curve);
- gp_Elips anElips = aGE->Elips();
- U = ElCLib::Parameter(anElips,Point);
- }
- else if( KindOfCurve == STANDARD_TYPE (Geom_Parabola) )
- {
- Handle(Geom_Parabola) aGP = Handle(Geom_Parabola)::DownCast(Curve);
- gp_Parab aParab = aGP->Parab();
- U = ElCLib::Parameter(aParab,Point);
- }
- else if( KindOfCurve == STANDARD_TYPE (Geom_Hyperbola) )
- {
- Handle(Geom_Hyperbola) aGH = Handle(Geom_Hyperbola)::DownCast(Curve);
- gp_Hypr aHypr = aGH->Hypr();
- U = ElCLib::Parameter(aHypr,Point);
- }