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.
23 #include <Extrema_GenLocateExtPS.ixx>
24 #include <Extrema_FuncExtPS.hxx>
25 #include <StdFail_NotDone.hxx>
27 #include <math_FunctionSetRoot.hxx>
28 #include <math_NewtonFunctionSetRoot.hxx>
29 #include <math_Vector.hxx>
31 //=============================================================================
33 Extrema_GenLocateExtPS::Extrema_GenLocateExtPS () { myDone = Standard_False; }
34 //=============================================================================
36 Extrema_GenLocateExtPS::Extrema_GenLocateExtPS (const gp_Pnt& P,
37 const Adaptor3d_Surface& S,
38 const Standard_Real U0,
39 const Standard_Real V0,
40 const Standard_Real TolU,
41 const Standard_Real TolV)
42 /*-----------------------------------------------------------------------------
44 Find (U,V) close to (U0,V0) so that dist(S(U,V),P) was extreme.
47 If (u,v) is a solution, it is possible to write:
48 { F1(u,v) = (S(u,v)-P).dS/du(u,v) = 0.
49 { F2(u,v) = (S(u,v)-P).dS/dv(u,v) = 0.
50 The problem consists in finding, in the interval of surface definition,
51 the root of the system closest to (U0,V0).
52 Use class math_FunctionSetRoot with the following construction arguments:
53 - F: Extrema_FuncExtPS created from P and S,
54 - U0V0: math_Vector (U0,V0),
55 - Tol: Min(TolU,TolV),
57 - math_Vector (Uinf,Usup),
58 - math_Vector (Vinf,Vsup),
60 ---------------------------------------------------------------------------*/
62 myDone = Standard_False;
64 Standard_Real Uinf, Usup, Vinf, Vsup;
65 Uinf = S.FirstUParameter();
66 Usup = S.LastUParameter();
67 Vinf = S.FirstVParameter();
68 Vsup = S.LastVParameter();
70 Extrema_FuncExtPS F (P,S);
71 math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2);
84 math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup);
88 mySqDist = F.SquareDistance(1);
90 myDone = Standard_True;
92 //=============================================================================
94 Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; }
95 //=============================================================================
97 Standard_Real Extrema_GenLocateExtPS::SquareDistance () const
99 if (!IsDone()) { StdFail_NotDone::Raise(); }
102 //=============================================================================
104 Extrema_POnSurf Extrema_GenLocateExtPS::Point () const
106 if (!IsDone()) { StdFail_NotDone::Raise(); }
109 //=============================================================================