1 // Created on: 1995-07-18
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <StdFail_NotDone.hxx>
23 #include <math_FunctionSetRoot.hxx>
24 #include <math_Vector.hxx>
26 //=============================================================================
27 Extrema_GenLocateExtCC::Extrema_GenLocateExtCC (const Curve1& C1,
29 const Standard_Real U0, const Standard_Real V0,
30 const Standard_Real TolU, const Standard_Real TolV)
31 /*-----------------------------------------------------------------------------
33 Recherche du couple de valeurs de parametre (U,V) tel que:
34 - dist(C1(u),C2(v)) passe par un extremum,
35 - (U,V) soit la solution la plus proche de (U0,V0).
38 Si (u,v) est solution, alors:
39 { F1(u,v)=(C1(u)-C2(v)).dC1/du(u) = 0.
40 { F2(u,v)=(C1(u)-C2(v)).dC2/dv(v) = 0.
41 Le probleme consiste a rechercher, dans les intervalles de definition
42 des courbes, la racine du systeme la plus proche de (U0,V0).
43 On utilise la classe math_FunctionSetRoot avec les arguments de construction
45 - F: Extrema_FuncExtCC cree a partir de C1 et C2,
47 - math_Vector(TolU,TolV),
48 - math_Vector(Uinf,Usup),
49 - math_Vector(Vinf,Vsup),
51 -----------------------------------------------------------------------------*/
53 myDone = Standard_False;
55 Standard_Real Uinf = Tool1::FirstParameter(C1);
56 Standard_Real Usup = Tool1::LastParameter(C1);
64 Standard_Real Vinf = Tool2::FirstParameter(C2);
65 Standard_Real Vsup = Tool2::LastParameter(C2);
72 Extrema_CCLocF F (C1,C2);
73 math_Vector Tol(1, 2);
76 Standard_Real Tolf = 1.e-10;
78 math_Vector Start(1,2);
79 math_Vector Uuinf(1,2);
80 math_Vector Uusup(1,2);
90 math_FunctionSetRoot S (F,Start,Tol,Uuinf,Uusup);
91 if (S.IsDone() && F.NbExt() > 0) {
92 mySqDist = F.SquareDistance(1);
93 F.Points(1,myPoint1,myPoint2);
94 Start(1)=myPoint1.Parameter();
95 Start(2)=myPoint2.Parameter();
98 // cout << "Ff(1) = "<<Ff(1)<<endl;
99 // cout << "Ff(2) = "<<Ff(2)<<endl;
100 if ((Ff(1)<Tolf) && (Ff(2)<Tolf) ) myDone = Standard_True;
103 //=============================================================================
105 Standard_Boolean Extrema_GenLocateExtCC::IsDone () const { return myDone; }
106 //=============================================================================
108 Standard_Real Extrema_GenLocateExtCC::SquareDistance() const
110 if (!IsDone()) { StdFail_NotDone::Raise(); }
113 //=============================================================================
115 void Extrema_GenLocateExtCC::Point (POnC& P1, POnC& P2)
118 if (!IsDone()) { StdFail_NotDone::Raise(); }
122 //=============================================================================