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 <Extrema_GenLocateExtPS.ixx>
18 #include <Extrema_FuncExtPS.hxx>
19 #include <StdFail_NotDone.hxx>
21 #include <math_FunctionSetRoot.hxx>
22 #include <math_NewtonFunctionSetRoot.hxx>
23 #include <math_Vector.hxx>
25 //=============================================================================
27 Extrema_GenLocateExtPS::Extrema_GenLocateExtPS () { myDone = Standard_False; }
28 //=============================================================================
30 Extrema_GenLocateExtPS::Extrema_GenLocateExtPS (const gp_Pnt& P,
31 const Adaptor3d_Surface& S,
32 const Standard_Real U0,
33 const Standard_Real V0,
34 const Standard_Real TolU,
35 const Standard_Real TolV)
36 /*-----------------------------------------------------------------------------
38 Find (U,V) close to (U0,V0) so that dist(S(U,V),P) was extreme.
41 If (u,v) is a solution, it is possible to write:
42 { F1(u,v) = (S(u,v)-P).dS/du(u,v) = 0.
43 { F2(u,v) = (S(u,v)-P).dS/dv(u,v) = 0.
44 The problem consists in finding, in the interval of surface definition,
45 the root of the system closest to (U0,V0).
46 Use class math_FunctionSetRoot with the following construction arguments:
47 - F: Extrema_FuncExtPS created from P and S,
48 - U0V0: math_Vector (U0,V0),
49 - Tol: Min(TolU,TolV),
51 - math_Vector (Uinf,Usup),
52 - math_Vector (Vinf,Vsup),
54 ---------------------------------------------------------------------------*/
56 myDone = Standard_False;
58 Standard_Real Uinf, Usup, Vinf, Vsup;
59 Uinf = S.FirstUParameter();
60 Usup = S.LastUParameter();
61 Vinf = S.FirstVParameter();
62 Vsup = S.LastVParameter();
64 Extrema_FuncExtPS F (P,S);
65 math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2);
78 math_FunctionSetRoot SR (F, Tol);
79 SR.Perform(F, Start, BInf, BSup);
83 mySqDist = F.SquareDistance(1);
85 myDone = Standard_True;
87 //=============================================================================
89 Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; }
90 //=============================================================================
92 Standard_Real Extrema_GenLocateExtPS::SquareDistance () const
94 if (!IsDone()) { StdFail_NotDone::Raise(); }
97 //=============================================================================
99 const Extrema_POnSurf& Extrema_GenLocateExtPS::Point () const
101 if (!IsDone()) { StdFail_NotDone::Raise(); }
104 //=============================================================================