1 // Created on: 2016-05-10
2 // Created by: Alexander MALYSHEV
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2016 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.
18 #include <Extrema_FuncPSDist.hxx>
21 #include <math_Vector.hxx>
23 //=======================================================================
24 //function : Extrema_FuncPSDist
26 //=======================================================================
27 Extrema_FuncPSDist::Extrema_FuncPSDist(const Adaptor3d_Surface& theS,
34 //=======================================================================
35 //function : NbVariables
37 //=======================================================================
38 Standard_Integer Extrema_FuncPSDist::NbVariables () const
43 //=======================================================================
46 //=======================================================================
47 Standard_Boolean Extrema_FuncPSDist::Value(const math_Vector& X,Standard_Real& F)
50 return Standard_False;
52 F = mySurf.Value(X(1), X(2)).SquareDistance(myP);
57 //=======================================================================
60 //=======================================================================
61 Standard_Boolean Extrema_FuncPSDist::Gradient(const math_Vector& X,math_Vector& G)
65 return Standard_False;
69 mySurf.D1(X(1),X(2),aP,Du1s,Dv1s);
71 gp_Vec P1P2 (aP, myP);
73 G(1) = P1P2.Dot(Du1s);
74 G(2) = P1P2.Dot(Dv1s);
79 //=======================================================================
82 //=======================================================================
83 Standard_Boolean Extrema_FuncPSDist::Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
86 return Standard_False;
90 mySurf.D1(X(1),X(2),aP,Du1s,Dv1s);
92 gp_Vec P1P2 (aP, myP);
94 G(1) = P1P2.Dot(Du1s);
95 G(2) = P1P2.Dot(Dv1s);
97 F = mySurf.Value(X(1), X(2)).SquareDistance(myP);
102 //=======================================================================
103 //function : IsInside
105 //=======================================================================
106 Standard_Boolean Extrema_FuncPSDist::IsInside(const math_Vector& X)
108 if (X(1) < mySurf.FirstUParameter() ||
109 X(1) > mySurf.LastUParameter() ||
110 X(2) < mySurf.FirstUParameter() ||
111 X(2) > mySurf.LastUParameter() )
113 // Point out of borders.
114 return Standard_False;
118 return Standard_True;