Warning, /include/opencascade/Extrema_GenLocateExtCC.gxx is written in an unsupported language. File is not indexed.
0001 // Created on: 1995-07-18
0002 // Created by: Modelistation
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016
0017 #include <StdFail_NotDone.hxx>
0018 #include <math_FunctionSetRoot.hxx>
0019 #include <math_Vector.hxx>
0020
0021 //=============================================================================
0022 Extrema_GenLocateExtCC::Extrema_GenLocateExtCC (const Curve1& C1,
0023 const Curve2& C2,
0024 const Standard_Real U0, const Standard_Real V0,
0025 const Standard_Real TolU, const Standard_Real TolV)
0026 /*-----------------------------------------------------------------------------
0027 Fonction:
0028 Recherche du couple de valeurs de parametre (U,V) tel que:
0029 - dist(C1(u),C2(v)) passe par un extremum,
0030 - (U,V) soit la solution la plus proche de (U0,V0).
0031
0032 Methode:
0033 Si (u,v) est solution, alors:
0034 { F1(u,v)=(C1(u)-C2(v)).dC1/du(u) = 0.
0035 { F2(u,v)=(C1(u)-C2(v)).dC2/dv(v) = 0.
0036 Le probleme consiste a rechercher, dans les intervalles de definition
0037 des courbes, la racine du systeme la plus proche de (U0,V0).
0038 On utilise la classe math_FunctionSetRoot avec les arguments de construction
0039 suivants:
0040 - F: Extrema_FuncExtCC cree a partir de C1 et C2,
0041 - math_Vector(U0,V0),
0042 - math_Vector(TolU,TolV),
0043 - math_Vector(Uinf,Usup),
0044 - math_Vector(Vinf,Vsup),
0045 - 100. .
0046 -----------------------------------------------------------------------------*/
0047 {
0048 myDone = Standard_False;
0049 mySqDist = RealLast();
0050
0051 Standard_Real Uinf = Tool1::FirstParameter(C1);
0052 Standard_Real Usup = Tool1::LastParameter(C1);
0053 Standard_Real Uu;
0054 if (Uinf>Usup) {
0055 Uu=Uinf;
0056 Uinf=Usup;
0057 Usup =Uu;
0058 }
0059
0060 Standard_Real Vinf = Tool2::FirstParameter(C2);
0061 Standard_Real Vsup = Tool2::LastParameter(C2);
0062 if (Vinf>Vsup) {
0063 Uu=Vinf;
0064 Vinf=Vsup;
0065 Vsup =Uu;
0066 }
0067
0068 Extrema_CCLocF F (C1,C2);
0069 math_Vector Tol(1, 2);
0070 Tol(1) = TolU;
0071 Tol(2) = TolV;
0072 Standard_Real Tolf = 1.e-10;
0073
0074 math_Vector Start(1,2);
0075 math_Vector Uuinf(1,2);
0076 math_Vector Uusup(1,2);
0077
0078 Start(1) = U0;
0079 Start(2) = V0;
0080
0081 Uuinf(1)=Uinf;
0082 Uuinf(2)=Vinf;
0083 Uusup(1)=Usup;
0084 Uusup(2)=Vsup;
0085
0086 math_FunctionSetRoot S(F, Tol);
0087 S.Perform(F, Start, Uuinf, Uusup);
0088
0089 if (S.IsDone() && F.NbExt() > 0) {
0090 mySqDist = F.SquareDistance(1);
0091 F.Points(1,myPoint1,myPoint2);
0092 Start(1)=myPoint1.Parameter();
0093 Start(2)=myPoint2.Parameter();
0094 math_Vector Ff(1,2);
0095 F.Value(Start,Ff);
0096 // cout << "Ff(1) = "<<Ff(1)<<endl;
0097 // cout << "Ff(2) = "<<Ff(2)<<endl;
0098 if ((Ff(1)<Tolf) && (Ff(2)<Tolf) ) myDone = Standard_True;
0099 }
0100 }
0101 //=============================================================================
0102
0103 Standard_Boolean Extrema_GenLocateExtCC::IsDone () const { return myDone; }
0104 //=============================================================================
0105
0106 Standard_Real Extrema_GenLocateExtCC::SquareDistance() const
0107 {
0108 if (!IsDone()) { throw StdFail_NotDone(); }
0109 return mySqDist;
0110 }
0111 //=============================================================================
0112
0113 void Extrema_GenLocateExtCC::Point (POnC& P1, POnC& P2)
0114 const
0115 {
0116 if (!IsDone()) { throw StdFail_NotDone(); }
0117 P1 = myPoint1;
0118 P2 = myPoint2;
0119 }
0120 //=============================================================================