1 // Created on: 1991-07-24
2 // Created by: Michel CHAUVAT
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Extrema_FunctPSNorm_HeaderFile
18 #define _Extrema_FunctPSNorm_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
24 #include <TColStd_SequenceOfReal.hxx>
25 #include <Extrema_SequenceOfPOnSurf.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <math_FunctionSetWithDerivatives.hxx>
28 #include <Standard_Integer.hxx>
29 #include <math_Vector.hxx>
31 class Adaptor3d_Surface;
33 class Extrema_POnSurf;
37 //! Functional for search of extremum of the distance between point P and
38 //! surface S, starting from approximate solution (u0, v0).
40 //! The class inherits math_FunctionSetWithDerivatives and thus is intended
41 //! for use in math_FunctionSetRoot algorithm .
43 //! Denoting derivatives of the surface S(u,v) by u and v, respectively, as
44 //! Su and Sv, the two functions to be nullified are:
46 //! F1(u,v) = (S - P) * Su
47 //! F2(u,v) = (S - P) * Sv
49 //! The derivatives of the functional are:
51 //! Duf1(u,v) = Su^2 + (S-P) * Suu;
52 //! Dvf1(u,v) = Su * Sv + (S-P) * Suv
53 //! Duf2(u,v) = Sv * Su + (S-P) * Suv = Dvf1
54 //! Dvf2(u,v) = Sv^2 + (S-P) * Svv
56 //! Here * denotes scalar product, and ^2 is square power.
57 class Extrema_FuncPSNorm : public math_FunctionSetWithDerivatives
64 Standard_EXPORT Extrema_FuncPSNorm();
66 Standard_EXPORT Extrema_FuncPSNorm(const gp_Pnt& P, const Adaptor3d_Surface& S);
68 //! sets the field mysurf of the function.
69 Standard_EXPORT void Initialize (const Adaptor3d_Surface& S);
71 //! sets the field mysurf of the function.
72 Standard_EXPORT void SetPoint (const gp_Pnt& P);
74 Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
76 Standard_EXPORT Standard_Integer NbEquations() const Standard_OVERRIDE;
78 //! Calculate Fi(U,V).
79 Standard_EXPORT Standard_Boolean Value (const math_Vector& UV, math_Vector& F) Standard_OVERRIDE;
81 //! Calculate Fi'(U,V).
82 Standard_EXPORT Standard_Boolean Derivatives (const math_Vector& UV, math_Matrix& DF) Standard_OVERRIDE;
84 //! Calculate Fi(U,V) and Fi'(U,V).
85 Standard_EXPORT Standard_Boolean Values (const math_Vector& UV, math_Vector& F, math_Matrix& DF) Standard_OVERRIDE;
87 //! Save the found extremum.
88 Standard_EXPORT virtual Standard_Integer GetStateNumber() Standard_OVERRIDE;
90 //! Return the number of found extrema.
91 Standard_EXPORT Standard_Integer NbExt() const;
93 //! Return the value of the Nth distance.
94 Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
96 //! Returns the Nth extremum.
97 Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const;
102 const Adaptor3d_Surface* myS;
106 TColStd_SequenceOfReal mySqDist;
107 Extrema_SequenceOfPOnSurf myPoint;
108 Standard_Boolean myPinit;
109 Standard_Boolean mySinit;
111 #endif // _Extrema_FunctPSNorm_HeaderFile