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 <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> 30 31 class Adaptor3d_Surface; 32 class math_Matrix; 33 class Extrema_POnSurf; 34 35 36 37 //! Functional for search of extremum of the distance between point P and 38 //! surface S, starting from approximate solution (u0, v0). 39 //! 40 //! The class inherits math_FunctionSetWithDerivatives and thus is intended 41 //! for use in math_FunctionSetRoot algorithm . 42 //! 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: 45 //! 46 //! F1(u,v) = (S - P) * Su 47 //! F2(u,v) = (S - P) * Sv 48 //! 49 //! The derivatives of the functional are: 50 //! 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 55 //! 56 //! Here * denotes scalar product, and ^2 is square power. 57 class Extrema_FuncPSNorm : public math_FunctionSetWithDerivatives 58 { 59 public: 60 61 DEFINE_STANDARD_ALLOC 62 63 64 Standard_EXPORT Extrema_FuncPSNorm(); 65 66 Standard_EXPORT Extrema_FuncPSNorm(const gp_Pnt& P, const Adaptor3d_Surface& S); 67 68 //! sets the field mysurf of the function. 69 Standard_EXPORT void Initialize (const Adaptor3d_Surface& S); 70 71 //! sets the field mysurf of the function. 72 Standard_EXPORT void SetPoint (const gp_Pnt& P); 73 74 Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE; 75 76 Standard_EXPORT Standard_Integer NbEquations() const Standard_OVERRIDE; 77 78 //! Calculate Fi(U,V). 79 Standard_EXPORT Standard_Boolean Value (const math_Vector& UV, math_Vector& F) Standard_OVERRIDE; 80 81 //! Calculate Fi'(U,V). 82 Standard_EXPORT Standard_Boolean Derivatives (const math_Vector& UV, math_Matrix& DF) Standard_OVERRIDE; 83 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; 86 87 //! Save the found extremum. 88 Standard_EXPORT virtual Standard_Integer GetStateNumber() Standard_OVERRIDE; 89 90 //! Return the number of found extrema. 91 Standard_EXPORT Standard_Integer NbExt() const; 92 93 //! Return the value of the Nth distance. 94 Standard_EXPORT Standard_Real SquareDistance (const Standard_Integer N) const; 95 96 //! Returns the Nth extremum. 97 Standard_EXPORT const Extrema_POnSurf& Point (const Standard_Integer N) const; 98 99 private: 100 101 gp_Pnt myP; 102 const Adaptor3d_Surface* myS; 103 Standard_Real myU; 104 Standard_Real myV; 105 gp_Pnt myPs; 106 TColStd_SequenceOfReal mySqDist; 107 Extrema_SequenceOfPOnSurf myPoint; 108 Standard_Boolean myPinit; 109 Standard_Boolean mySinit; 110 }; 111 #endif // _Extrema_FunctPSNorm_HeaderFile 112