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 <Adaptor3d_SurfacePtr.hxx>
25 #include <Standard_Real.hxx>
26 #include <TColStd_SequenceOfReal.hxx>
27 #include <Extrema_SequenceOfPOnSurf.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <math_FunctionSetWithDerivatives.hxx>
30 #include <Standard_Integer.hxx>
31 #include <math_Vector.hxx>
32 class Standard_OutOfRange;
34 class Adaptor3d_Surface;
36 class Extrema_POnSurf;
40 //! Functional for search of extremum of the distance between point P and
41 //! surface S, starting from approximate solution (u0, v0).
43 //! The class inherits math_FunctionSetWithDerivatives and thus is intended
44 //! for use in math_FunctionSetRoot algorithm .
46 //! Denoting derivatives of the surface S(u,v) by u and v, respectively, as
47 //! Su and Sv, the two functions to be nullified are:
49 //! F1(u,v) = (S - P) * Su
50 //! F2(u,v) = (S - P) * Sv
52 //! The derivatives of the functional are:
54 //! Duf1(u,v) = Su^2 + (S-P) * Suu;
55 //! Dvf1(u,v) = Su * Sv + (S-P) * Suv
56 //! Duf2(u,v) = Sv * Su + (S-P) * Suv = Dvf1
57 //! Dvf2(u,v) = Sv^2 + (S-P) * Svv
59 //! Here * denotes scalar product, and ^2 is square power.
60 class Extrema_FuncPSNorm : public math_FunctionSetWithDerivatives
67 Standard_EXPORT Extrema_FuncPSNorm();
69 Standard_EXPORT Extrema_FuncPSNorm(const gp_Pnt& P, const Adaptor3d_Surface& S);
71 //! sets the field mysurf of the function.
72 Standard_EXPORT void Initialize (const Adaptor3d_Surface& S);
74 //! sets the field mysurf of the function.
75 Standard_EXPORT void SetPoint (const gp_Pnt& P);
77 Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
79 Standard_EXPORT Standard_Integer NbEquations() const Standard_OVERRIDE;
81 //! Calculate Fi(U,V).
82 Standard_EXPORT Standard_Boolean Value (const math_Vector& UV, math_Vector& F) Standard_OVERRIDE;
84 //! Calculate Fi'(U,V).
85 Standard_EXPORT Standard_Boolean Derivatives (const math_Vector& UV, math_Matrix& DF) Standard_OVERRIDE;
87 //! Calculate Fi(U,V) and Fi'(U,V).
88 Standard_EXPORT Standard_Boolean Values (const math_Vector& UV, math_Vector& F, math_Matrix& DF) Standard_OVERRIDE;
90 //! Save the found extremum.
91 Standard_EXPORT virtual Standard_Integer GetStateNumber() Standard_OVERRIDE;
93 //! Return the number of found extrema.
94 Standard_EXPORT Standard_Integer NbExt() const;
96 //! Return the value of the Nth distance.
97 Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
99 //! Returns the Nth extremum.
100 Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const;
105 Adaptor3d_SurfacePtr myS;
109 TColStd_SequenceOfReal mySqDist;
110 Extrema_SequenceOfPOnSurf myPoint;
111 Standard_Boolean myPinit;
112 Standard_Boolean mySinit;
114 #endif // _Extrema_FunctPSNorm_HeaderFile