7fd59977 |
1 | // File: Extrema_GenLocateExtPS.cxx |
2 | // Created: Tue Jul 18 08:23:33 1995 |
3 | // Author: Modelistation |
4 | // <model@metrox> |
5 | |
6 | |
7 | #include <Extrema_GenLocateExtPS.ixx> |
8 | #include <Extrema_FuncExtPS.hxx> |
9 | #include <StdFail_NotDone.hxx> |
10 | #include <gp.hxx> |
11 | #include <math_FunctionSetRoot.hxx> |
12 | #include <math_NewtonFunctionSetRoot.hxx> |
13 | #include <math_Vector.hxx> |
14 | |
15 | //============================================================================= |
16 | |
17 | Extrema_GenLocateExtPS::Extrema_GenLocateExtPS () { myDone = Standard_False; } |
18 | //============================================================================= |
19 | |
20 | Extrema_GenLocateExtPS::Extrema_GenLocateExtPS (const gp_Pnt& P, |
21 | const Adaptor3d_Surface& S, |
22 | const Standard_Real U0, |
23 | const Standard_Real V0, |
24 | const Standard_Real TolU, |
25 | const Standard_Real TolV) |
26 | /*----------------------------------------------------------------------------- |
27 | Fonction: |
28 | Recherche de (U,V) proche de (U0,V0) tel que dist(S(U,V),P) soit extremale. |
29 | |
30 | Methode: |
31 | Si (u,v) est solution, on peut ecrire: |
32 | { F1(u,v) = (S(u,v)-P).dS/du(u,v) = 0. |
33 | { F2(u,v) = (S(u,v)-P).dS/dv(u,v) = 0. |
34 | Le probleme consiste a rechercher, dans l'intervalle de definition de la |
35 | surface, la racine du systeme la plus proche de (U0,V0). |
36 | On utilise la classe math_FunctionSetRoot avec les arguments de construction |
37 | suivants: |
38 | - F: Extrema_FuncExtPS cree a partir de P et S, |
39 | - U0V0: math_Vector (U0,V0), |
40 | - Tol: Min(TolU,TolV), |
41 | |
42 | - math_Vector (Uinf,Usup), |
43 | - math_Vector (Vinf,Vsup), |
44 | - 100. . |
45 | ---------------------------------------------------------------------------*/ |
46 | { |
47 | myDone = Standard_False; |
48 | |
49 | Standard_Real Uinf, Usup, Vinf, Vsup; |
50 | Uinf = S.FirstUParameter(); |
51 | Usup = S.LastUParameter(); |
52 | Vinf = S.FirstVParameter(); |
53 | Vsup = S.LastVParameter(); |
54 | |
55 | Extrema_FuncExtPS F (P,S); |
56 | math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2); |
57 | |
58 | Tol(1) = TolU; |
59 | Tol(2) = TolV; |
60 | |
61 | Start(1) = U0; |
62 | Start(2) = V0; |
63 | |
64 | BInf(1) = Uinf; |
65 | BInf(2) = Vinf; |
66 | BSup(1) = Usup; |
67 | BSup(2) = Vsup; |
68 | |
69 | math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup); |
70 | if (!SR.IsDone()) |
71 | return; |
72 | |
73 | mySqDist = F.SquareDistance(1); |
74 | myPoint = F.Point(1); |
75 | myDone = Standard_True; |
76 | } |
77 | //============================================================================= |
78 | |
79 | Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; } |
80 | //============================================================================= |
81 | |
82 | Standard_Real Extrema_GenLocateExtPS::SquareDistance () const |
83 | { |
84 | if (!IsDone()) { StdFail_NotDone::Raise(); } |
85 | return mySqDist; |
86 | } |
87 | //============================================================================= |
88 | |
89 | Extrema_POnSurf Extrema_GenLocateExtPS::Point () const |
90 | { |
91 | if (!IsDone()) { StdFail_NotDone::Raise(); } |
92 | return myPoint; |
93 | } |
94 | //============================================================================= |