0029069: Samples - handle UNICODE filenames within C++/CLI CSharp sample
[occt.git] / src / Extrema / Extrema_FuncPSNorm.hxx
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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Extrema_FunctPSNorm_HeaderFile
18 #define _Extrema_FunctPSNorm_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22
23 #include <gp_Pnt.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;
33 class gp_Pnt;
34 class Adaptor3d_Surface;
35 class math_Matrix;
36 class Extrema_POnSurf;
37
38
39
40 //! Functional for search of extremum of the distance between point P and
41 //! surface S, starting from approximate solution (u0, v0).
42 //!
43 //! The class inherits math_FunctionSetWithDerivatives and thus is intended
44 //! for use in math_FunctionSetRoot algorithm .
45 //!
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:
48 //!
49 //! F1(u,v) = (S - P) * Su
50 //! F2(u,v) = (S - P) * Sv
51 //!
52 //! The derivatives of the functional are:
53 //!
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
58 //!
59 //! Here * denotes scalar product, and ^2 is square power.
60 class Extrema_FuncPSNorm  : public math_FunctionSetWithDerivatives
61 {
62 public:
63
64   DEFINE_STANDARD_ALLOC
65
66   
67   Standard_EXPORT Extrema_FuncPSNorm();
68   
69   Standard_EXPORT Extrema_FuncPSNorm(const gp_Pnt& P, const Adaptor3d_Surface& S);
70   
71   //! sets the field mysurf of the function.
72   Standard_EXPORT void Initialize (const Adaptor3d_Surface& S);
73   
74   //! sets the field mysurf of the function.
75   Standard_EXPORT void SetPoint (const gp_Pnt& P);
76   
77   Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
78   
79   Standard_EXPORT Standard_Integer NbEquations() const Standard_OVERRIDE;
80   
81   //! Calculate Fi(U,V).
82   Standard_EXPORT Standard_Boolean Value (const math_Vector& UV, math_Vector& F) Standard_OVERRIDE;
83   
84   //! Calculate Fi'(U,V).
85   Standard_EXPORT Standard_Boolean Derivatives (const math_Vector& UV, math_Matrix& DF) Standard_OVERRIDE;
86   
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;
89   
90   //! Save the found extremum.
91   Standard_EXPORT virtual Standard_Integer GetStateNumber() Standard_OVERRIDE;
92   
93   //! Return the number of found extrema.
94   Standard_EXPORT Standard_Integer NbExt() const;
95   
96   //! Return the value of the Nth distance.
97   Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const;
98   
99   //! Returns the Nth extremum.
100   Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const;
101
102 private:
103
104   gp_Pnt myP;
105   Adaptor3d_SurfacePtr myS;
106   Standard_Real myU;
107   Standard_Real myV;
108   gp_Pnt myPs;
109   TColStd_SequenceOfReal mySqDist;
110   Extrema_SequenceOfPOnSurf myPoint;
111   Standard_Boolean myPinit;
112   Standard_Boolean mySinit;
113 };
114 #endif // _Extrema_FunctPSNorm_HeaderFile