Warnings on vc14 were eliminated
[occt.git] / src / Extrema / Extrema_FuncPSDist.hxx
1 // Created on: 2016-05-10
2 // Created by: Alexander MALYSHEV
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2016 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_FuncPSDsit_HeaderFile
18 #define _Extrema_FuncPSDsit_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22
23 #include <math_MultipleVarFunctionWithGradient.hxx>
24 #include <gp_Pnt.hxx>
25 #include <Adaptor3d_Surface.hxx>
26
27 #include <Standard_Real.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <Standard_Integer.hxx>
30
31 class math_Vector;
32
33 //! Functional for search of extremum of the square Euclidean distance between point P and
34 //! surface S, starting from approximate solution (u0, v0).
35 //!
36 //! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
37 //! for use in math_BFGS algorithm.
38 //!
39 //! The criteria is:
40 //! F = SquareDist(P, S(u, v)) - > min
41 //!
42 //! The first derivative are:
43 //! F1(u,v) = (S(u,v) - P) * Su
44 //! F2(u,v) = (S(u,v) - P) * Sv
45 //!
46 //! Su and Sv are first derivatives of the surface, * symbol means dot product.
47 class Extrema_FuncPSDist  : public math_MultipleVarFunctionWithGradient
48 {
49 public:
50
51   DEFINE_STANDARD_ALLOC
52
53   //! Constructor.
54   Standard_EXPORT Extrema_FuncPSDist(const Adaptor3d_Surface& theS,
55                                      const gp_Pnt& theP);
56
57   //! Number of variables.
58   Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
59
60   //! Value.
61   Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
62
63   //! Gradient.
64   Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) Standard_OVERRIDE;
65
66   //! Value and gradient.
67   Standard_EXPORT Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) Standard_OVERRIDE;
68
69 private:
70
71
72   //! Check point is inside of the surface parameter space.
73   //! Returns true if inside and false otherwise.
74   Standard_Boolean IsInside(const math_Vector& X);
75
76   const Extrema_FuncPSDist& operator=(const Extrema_FuncPSDist&);
77   Extrema_FuncPSDist(const Extrema_FuncPSDist&);
78
79   const Adaptor3d_Surface &mySurf;
80   const gp_Pnt &myP;
81 };
82 #endif // _Extrema_FuncPSDsit_HeaderFile