1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <StdFail_NotDone.hxx>
18 #include <math_FunctionSetRoot.hxx>
19 #include <math_Vector.hxx>
21 //=============================================================================
22 Extrema_GenLocateExtCC::Extrema_GenLocateExtCC (const Curve1& C1,
24 const Standard_Real U0, const Standard_Real V0,
25 const Standard_Real TolU, const Standard_Real TolV)
26 /*-----------------------------------------------------------------------------
28 Recherche du couple de valeurs de parametre (U,V) tel que:
29 - dist(C1(u),C2(v)) passe par un extremum,
30 - (U,V) soit la solution la plus proche de (U0,V0).
33 Si (u,v) est solution, alors:
34 { F1(u,v)=(C1(u)-C2(v)).dC1/du(u) = 0.
35 { F2(u,v)=(C1(u)-C2(v)).dC2/dv(v) = 0.
36 Le probleme consiste a rechercher, dans les intervalles de definition
37 des courbes, la racine du systeme la plus proche de (U0,V0).
38 On utilise la classe math_FunctionSetRoot avec les arguments de construction
40 - F: Extrema_FuncExtCC cree a partir de C1 et C2,
42 - math_Vector(TolU,TolV),
43 - math_Vector(Uinf,Usup),
44 - math_Vector(Vinf,Vsup),
46 -----------------------------------------------------------------------------*/
48 myDone = Standard_False;
50 Standard_Real Uinf = Tool1::FirstParameter(C1);
51 Standard_Real Usup = Tool1::LastParameter(C1);
59 Standard_Real Vinf = Tool2::FirstParameter(C2);
60 Standard_Real Vsup = Tool2::LastParameter(C2);
67 Extrema_CCLocF F (C1,C2);
68 math_Vector Tol(1, 2);
71 Standard_Real Tolf = 1.e-10;
73 math_Vector Start(1,2);
74 math_Vector Uuinf(1,2);
75 math_Vector Uusup(1,2);
85 math_FunctionSetRoot S(F, Tol);
86 S.Perform(F, Start, Uuinf, Uusup);
88 if (S.IsDone() && F.NbExt() > 0) {
89 mySqDist = F.SquareDistance(1);
90 F.Points(1,myPoint1,myPoint2);
91 Start(1)=myPoint1.Parameter();
92 Start(2)=myPoint2.Parameter();
95 // cout << "Ff(1) = "<<Ff(1)<<endl;
96 // cout << "Ff(2) = "<<Ff(2)<<endl;
97 if ((Ff(1)<Tolf) && (Ff(2)<Tolf) ) myDone = Standard_True;
100 //=============================================================================
102 Standard_Boolean Extrema_GenLocateExtCC::IsDone () const { return myDone; }
103 //=============================================================================
105 Standard_Real Extrema_GenLocateExtCC::SquareDistance() const
107 if (!IsDone()) { throw StdFail_NotDone(); }
110 //=============================================================================
112 void Extrema_GenLocateExtCC::Point (POnC& P1, POnC& P2)
115 if (!IsDone()) { throw StdFail_NotDone(); }
119 //=============================================================================