1 -- Created on: 1991-07-24
2 -- Created by: Michel CHAUVAT
3 -- Copyright (c) 1991-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.
22 -- Modified by skv - Thu Sep 30 15:19:59 2004 OCC593
25 private class FuncExtPS from Extrema
27 inherits FunctionSetWithDerivatives from math
30 -- Functional for search of extremum of the distance between point P and
31 -- surface S, starting from approximate solution (u0, v0).
33 -- The class inherits math_FunctionSetWithDerivatives and thus is intended
34 -- for use in math_FunctionSetRoot algorithm .
36 -- Denoting derivatives of the surface S(u,v) by u and v, respectively, as
37 -- Su and Sv, the two functions to be nullified are:
39 -- F1(u,v) = (S - P) * Su
40 -- F2(u,v) = (S - P) * Sv
42 -- The derivatives of the functional are:
44 -- Duf1(u,v) = Su^2 + (S-P) * Suu;
45 -- Dvf1(u,v) = Su * Sv + (S-P) * Suv
46 -- Duf2(u,v) = Sv * Su + (S-P) * Suv = Dvf1
47 -- Dvf2(u,v) = Sv^2 + (S-P) * Svv
49 -- Here * denotes scalar product, and ^2 is square power.
51 uses POnSurf from Extrema,
52 SequenceOfPOnSurf from Extrema,
53 SequenceOfReal from TColStd,
57 Surface from Adaptor3d,
58 SurfacePtr from Adaptor3d
60 raises OutOfRange from Standard
63 Create returns FuncExtPS;
65 Create (P: Pnt; S: Surface from Adaptor3d) returns FuncExtPS;
68 Initialize(me: in out; S: Surface from Adaptor3d)
69 ---Purpose: sets the field mysurf of the function.
72 SetPoint(me: in out; P: Pnt)
73 ---Purpose: sets the field mysurf of the function.
76 ------------------------------------------------------------
77 -- In all next methods, an exception is raised if the fields
78 -- were not initialized.
80 NbVariables (me) returns Integer;
82 NbEquations (me) returns Integer;
84 Value (me: in out; UV: Vector; F: out Vector) returns Boolean;
85 ---Purpose: Calculate Fi(U,V).
87 Derivatives (me: in out; UV: Vector; DF: out Matrix)
89 ---Purpose: Calculate Fi'(U,V).
91 Values (me: in out; UV: Vector; F: out Vector; DF: out Matrix)
93 ---Purpose: Calculate Fi(U,V) and Fi'(U,V).
95 GetStateNumber (me: in out) returns Integer
96 ---Purpose: Save the found extremum.
99 NbExt (me) returns Integer;
100 ---Purpose: Return the number of found extrema.
102 SquareDistance (me; N: Integer) returns Real
103 ---Purpose: Return the value of the Nth distance.
105 -- if N < 1 or N > NbExt(me).
107 Point (me; N: Integer) returns POnSurf
108 ---Purpose: Returns the Nth extremum.
110 -- if N < 1 or N > NbExt(me).
114 myS : SurfacePtr from Adaptor3d;
116 myU : Real; -- current value of U
117 myV : Real; -- current value of V
118 myPs : Pnt from gp; -- current point
120 mySqDist: SequenceOfReal from TColStd;
121 myPoint: SequenceOfPOnSurf from Extrema;