1 // File: Extrema_GenLocateExtCC.gxx
2 // Created: Tue Jul 18 17:43:58 1995
3 // Author: Modelistation
6 #include <StdFail_NotDone.hxx>
7 #include <math_FunctionSetRoot.hxx>
8 #include <math_Vector.hxx>
10 //=============================================================================
11 Extrema_GenLocateExtCC::Extrema_GenLocateExtCC (const Curve1& C1,
13 const Standard_Real U0, const Standard_Real V0,
14 const Standard_Real TolU, const Standard_Real TolV)
15 /*-----------------------------------------------------------------------------
17 Recherche du couple de valeurs de parametre (U,V) tel que:
18 - dist(C1(u),C2(v)) passe par un extremum,
19 - (U,V) soit la solution la plus proche de (U0,V0).
22 Si (u,v) est solution, alors:
23 { F1(u,v)=(C1(u)-C2(v)).dC1/du(u) = 0.
24 { F2(u,v)=(C1(u)-C2(v)).dC2/dv(v) = 0.
25 Le probleme consiste a rechercher, dans les intervalles de definition
26 des courbes, la racine du systeme la plus proche de (U0,V0).
27 On utilise la classe math_FunctionSetRoot avec les arguments de construction
29 - F: Extrema_FuncExtCC cree a partir de C1 et C2,
31 - math_Vector(TolU,TolV),
32 - math_Vector(Uinf,Usup),
33 - math_Vector(Vinf,Vsup),
35 -----------------------------------------------------------------------------*/
37 myDone = Standard_False;
39 Standard_Real Uinf = Tool1::FirstParameter(C1);
40 Standard_Real Usup = Tool1::LastParameter(C1);
48 Standard_Real Vinf = Tool2::FirstParameter(C2);
49 Standard_Real Vsup = Tool2::LastParameter(C2);
56 Extrema_CCLocF F (C1,C2);
57 math_Vector Tol(1, 2);
60 Standard_Real Tolf = 1.e-10;
62 math_Vector Start(1,2);
63 math_Vector Uuinf(1,2);
64 math_Vector Uusup(1,2);
74 math_FunctionSetRoot S (F,Start,Tol,Uuinf,Uusup);
75 if (S.IsDone() && F.NbExt() > 0) {
76 mySqDist = F.SquareDistance(1);
77 F.Points(1,myPoint1,myPoint2);
78 Start(1)=myPoint1.Parameter();
79 Start(2)=myPoint2.Parameter();
82 // cout << "Ff(1) = "<<Ff(1)<<endl;
83 // cout << "Ff(2) = "<<Ff(2)<<endl;
84 if ((Ff(1)<Tolf) && (Ff(2)<Tolf) ) myDone = Standard_True;
87 //=============================================================================
89 Standard_Boolean Extrema_GenLocateExtCC::IsDone () const { return myDone; }
90 //=============================================================================
92 Standard_Real Extrema_GenLocateExtCC::SquareDistance() const
94 if (!IsDone()) { StdFail_NotDone::Raise(); }
97 //=============================================================================
99 void Extrema_GenLocateExtCC::Point (POnC& P1, POnC& P2)
102 if (!IsDone()) { StdFail_NotDone::Raise(); }
106 //=============================================================================