Commit | Line | Data |
---|---|---|
b311480e | 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 | |
5 | // | |
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. | |
10 | // | |
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. | |
13 | // | |
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. | |
20 | ||
7fd59977 | 21 | |
22 | ||
23 | #include <Extrema_GenLocateExtPS.ixx> | |
24 | #include <Extrema_FuncExtPS.hxx> | |
25 | #include <StdFail_NotDone.hxx> | |
26 | #include <gp.hxx> | |
27 | #include <math_FunctionSetRoot.hxx> | |
28 | #include <math_NewtonFunctionSetRoot.hxx> | |
29 | #include <math_Vector.hxx> | |
30 | ||
31 | //============================================================================= | |
32 | ||
33 | Extrema_GenLocateExtPS::Extrema_GenLocateExtPS () { myDone = Standard_False; } | |
34 | //============================================================================= | |
35 | ||
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 | /*----------------------------------------------------------------------------- | |
0d969553 Y |
43 | Function: |
44 | Find (U,V) close to (U0,V0) so that dist(S(U,V),P) was extreme. | |
7fd59977 | 45 | |
0d969553 Y |
46 | Method: |
47 | If (u,v) is a solution, it is possible to write: | |
7fd59977 | 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. | |
0d969553 Y |
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, | |
7fd59977 | 54 | - U0V0: math_Vector (U0,V0), |
55 | - Tol: Min(TolU,TolV), | |
56 | ||
57 | - math_Vector (Uinf,Usup), | |
58 | - math_Vector (Vinf,Vsup), | |
59 | - 100. . | |
60 | ---------------------------------------------------------------------------*/ | |
61 | { | |
62 | myDone = Standard_False; | |
63 | ||
64 | Standard_Real Uinf, Usup, Vinf, Vsup; | |
65 | Uinf = S.FirstUParameter(); | |
66 | Usup = S.LastUParameter(); | |
67 | Vinf = S.FirstVParameter(); | |
68 | Vsup = S.LastVParameter(); | |
69 | ||
70 | Extrema_FuncExtPS F (P,S); | |
71 | math_Vector Tol(1, 2), Start(1, 2), BInf(1, 2), BSup(1, 2); | |
72 | ||
73 | Tol(1) = TolU; | |
74 | Tol(2) = TolV; | |
75 | ||
76 | Start(1) = U0; | |
77 | Start(2) = V0; | |
78 | ||
79 | BInf(1) = Uinf; | |
80 | BInf(2) = Vinf; | |
81 | BSup(1) = Usup; | |
82 | BSup(2) = Vsup; | |
83 | ||
84 | math_FunctionSetRoot SR (F, Start,Tol, BInf, BSup); | |
85 | if (!SR.IsDone()) | |
86 | return; | |
87 | ||
88 | mySqDist = F.SquareDistance(1); | |
89 | myPoint = F.Point(1); | |
90 | myDone = Standard_True; | |
91 | } | |
92 | //============================================================================= | |
93 | ||
94 | Standard_Boolean Extrema_GenLocateExtPS::IsDone () const { return myDone; } | |
95 | //============================================================================= | |
96 | ||
97 | Standard_Real Extrema_GenLocateExtPS::SquareDistance () const | |
98 | { | |
99 | if (!IsDone()) { StdFail_NotDone::Raise(); } | |
100 | return mySqDist; | |
101 | } | |
102 | //============================================================================= | |
103 | ||
104 | Extrema_POnSurf Extrema_GenLocateExtPS::Point () const | |
105 | { | |
106 | if (!IsDone()) { StdFail_NotDone::Raise(); } | |
107 | return myPoint; | |
108 | } | |
109 | //============================================================================= |