Commit | Line | Data |
---|---|---|
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 | /*----------------------------------------------------------------------------- | |
0d969553 Y |
27 | Function: |
28 | Find (U,V) close to (U0,V0) so that dist(S(U,V),P) was extreme. | |
7fd59977 | 29 | |
0d969553 Y |
30 | Method: |
31 | If (u,v) is a solution, it is possible to write: | |
7fd59977 | 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. | |
0d969553 Y |
34 | The problem consists in finding, in the interval of surface definition, |
35 | the root of the system closest to (U0,V0). | |
36 | Use class math_FunctionSetRoot with the following construction arguments: | |
37 | - F: Extrema_FuncExtPS created from P and S, | |
7fd59977 | 38 | - U0V0: math_Vector (U0,V0), |
39 | - Tol: Min(TolU,TolV), | |
40 | ||
41 | - math_Vector (Uinf,Usup), | |
42 | - math_Vector (Vinf,Vsup), | |
43 | - 100. . | |
44 | ---------------------------------------------------------------------------*/ | |
45 | { | |
46 | myDone = Standard_False; | |
47 | ||
48 | Standard_Real Uinf, Usup, Vinf, Vsup; | |
49 | Uinf = S.FirstUParameter(); | |
50 | Usup = S.LastUParameter(); | |
51 | Vinf = S.FirstVParameter(); | |
52 | Vsup = S.LastVParameter(); | |
53 | ||
54 | Extrema_FuncExtPS F (P,S); | |
55 | math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2); | |
56 | ||
57 | Tol(1) = TolU; | |
58 | Tol(2) = TolV; | |
59 | ||
60 | Start(1) = U0; | |
61 | Start(2) = V0; | |
62 | ||
63 | BInf(1) = Uinf; | |
64 | BInf(2) = Vinf; | |
65 | BSup(1) = Usup; | |
66 | BSup(2) = Vsup; | |
67 | ||
68 | math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup); | |
69 | if (!SR.IsDone()) | |
70 | return; | |
71 | ||
72 | mySqDist = F.SquareDistance(1); | |
73 | myPoint = F.Point(1); | |
74 | myDone = Standard_True; | |
75 | } | |
76 | //============================================================================= | |
77 | ||
78 | Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; } | |
79 | //============================================================================= | |
80 | ||
81 | Standard_Real Extrema_GenLocateExtPS::SquareDistance () const | |
82 | { | |
83 | if (!IsDone()) { StdFail_NotDone::Raise(); } | |
84 | return mySqDist; | |
85 | } | |
86 | //============================================================================= | |
87 | ||
88 | Extrema_POnSurf Extrema_GenLocateExtPS::Point () const | |
89 | { | |
90 | if (!IsDone()) { StdFail_NotDone::Raise(); } | |
91 | return myPoint; | |
92 | } | |
93 | //============================================================================= |