Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-25 09:19:35

0001 // Created on: 2016-05-10
0002 // Created by: Alexander MALYSHEV
0003 // Copyright (c) 1991-1999 Matra Datavision
0004 // Copyright (c) 1999-2016 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Extrema_FuncPSDsit_HeaderFile
0018 #define _Extrema_FuncPSDsit_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <math_MultipleVarFunctionWithGradient.hxx>
0024 #include <Adaptor3d_Surface.hxx>
0025 
0026 #include <Standard_Boolean.hxx>
0027 
0028 template <typename T>
0029 class math_VectorBase;
0030 using math_Vector = math_VectorBase<double>;
0031 
0032 //! Functional for search of extremum of the square Euclidean distance between point P and
0033 //! surface S, starting from approximate solution (u0, v0).
0034 //!
0035 //! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
0036 //! for use in math_BFGS algorithm.
0037 //!
0038 //! The criteria is:
0039 //! F = SquareDist(P, S(u, v)) - > min
0040 //!
0041 //! The first derivative are:
0042 //! F1(u,v) = (S(u,v) - P) * Su
0043 //! F2(u,v) = (S(u,v) - P) * Sv
0044 //!
0045 //! Su and Sv are first derivatives of the surface, * symbol means dot product.
0046 class Extrema_FuncPSDist : public math_MultipleVarFunctionWithGradient
0047 {
0048 public:
0049   DEFINE_STANDARD_ALLOC
0050 
0051   //! Constructor.
0052   Standard_EXPORT Extrema_FuncPSDist(const Adaptor3d_Surface& theS, const gp_Pnt& theP);
0053 
0054   //! Number of variables.
0055   Standard_EXPORT int NbVariables() const override;
0056 
0057   //! Value.
0058   Standard_EXPORT bool Value(const math_Vector& X, double& F) override;
0059 
0060   //! Gradient.
0061   Standard_EXPORT bool Gradient(const math_Vector& X, math_Vector& G) override;
0062 
0063   //! Value and gradient.
0064   Standard_EXPORT bool Values(const math_Vector& X, double& F, math_Vector& G) override;
0065 
0066 private:
0067   //! Check point is inside of the surface parameter space.
0068   //! Returns true if inside and false otherwise.
0069   bool IsInside(const math_Vector& X);
0070 
0071   const Extrema_FuncPSDist& operator=(const Extrema_FuncPSDist&) = delete;
0072   Extrema_FuncPSDist(const Extrema_FuncPSDist&)                  = delete;
0073 
0074   const Adaptor3d_Surface& mySurf;
0075   const gp_Pnt&            myP;
0076 };
0077 #endif // _Extrema_FuncPSDsit_HeaderFile