Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:19:58

0001 // Created on: 1996-03-06
0002 // Created by: Philippe MANGIN
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 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 _FairCurve_Energy_HeaderFile
0018 #define _FairCurve_Energy_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <gp_Pnt2d.hxx>
0025 #include <NCollection_Array1.hxx>
0026 #include <NCollection_HArray1.hxx>
0027 #include <Standard_Integer.hxx>
0028 #include <gp_XY.hxx>
0029 #include <math_MultipleVarFunctionWithHessian.hxx>
0030 #include <Standard_Real.hxx>
0031 class math_Matrix;
0032 class gp_Pnt2d;
0033 
0034 //! necessary methodes to compute the energy of an FairCurve.
0035 class FairCurve_Energy : public math_MultipleVarFunctionWithHessian
0036 {
0037 public:
0038   DEFINE_STANDARD_ALLOC
0039 
0040   //! returns the number of variables of the energy.
0041   int NbVariables() const override;
0042 
0043   //! computes the values of the Energys E for the
0044   //! variable <X>.
0045   //! Returns True if the computation was done successfully,
0046   //! False otherwise.
0047   Standard_EXPORT bool Value(const math_Vector& X, double& E) override;
0048 
0049   //! computes the gradient <G> of the energys for the
0050   //! variable <X>.
0051   //! Returns True if the computation was done successfully,
0052   //! False otherwise.
0053   Standard_EXPORT bool Gradient(const math_Vector& X, math_Vector& G) override;
0054 
0055   //! computes the Energy <E> and the gradient <G> of the
0056   //! energy for the variable <X>.
0057   //! Returns True if the computation was done successfully,
0058   //! False otherwise.
0059   Standard_EXPORT bool Values(const math_Vector& X, double& E, math_Vector& G) override;
0060 
0061   //! computes the Energy <E>, the gradient <G> and the
0062   //! Hessian <H> of the energy for the variable <X>.
0063   //! Returns True if the computation was done
0064   //! successfully, False otherwise.
0065   Standard_EXPORT bool Values(const math_Vector& X,
0066                               double&            E,
0067                               math_Vector&       G,
0068                               math_Matrix&       H) override;
0069 
0070   //! compute the variables <X> which correspond with the field <MyPoles>
0071   Standard_EXPORT virtual bool Variable(math_Vector& X) const;
0072 
0073   //! return the poles
0074   const occ::handle<NCollection_HArray1<gp_Pnt2d>>& Poles() const;
0075 
0076 protected:
0077   //! Angles correspond to the Ox axis
0078   //! ConstrOrder1(2) can be equal to 0, 1 or 2
0079   Standard_EXPORT FairCurve_Energy(const occ::handle<NCollection_HArray1<gp_Pnt2d>>& Poles,
0080                                    const int                                         ConstrOrder1,
0081                                    const int                                         ConstrOrder2,
0082                                    const bool   WithAuxValue = false,
0083                                    const double Angle1       = 0,
0084                                    const double Angle2       = 0,
0085                                    const int    Degree       = 2,
0086                                    const double Curvature1   = 0,
0087                                    const double Curvature2   = 0);
0088 
0089   //! It is use internally to make the Gradient Vector <G>
0090   Standard_EXPORT void Gradient1(const math_Vector& TheVector, math_Vector& G);
0091 
0092   //! It is use internally to make the Hessian Matrix <H>
0093   Standard_EXPORT void Hessian1(const math_Vector& TheVector, math_Matrix& H);
0094 
0095   //! compute the poles which correspond with the variable X
0096   Standard_EXPORT virtual void ComputePoles(const math_Vector& X);
0097 
0098   int Indice(const int i, const int j) const;
0099 
0100   //! compute the pole which depend of variables and G1 constraint
0101   Standard_EXPORT void ComputePolesG1(const int       Side,
0102                                       const double    Lambda,
0103                                       const gp_Pnt2d& P1,
0104                                       gp_Pnt2d&       P2) const;
0105 
0106   //! compute the pole which depend of variables and G2 constraint
0107   Standard_EXPORT void ComputePolesG2(const int       Side,
0108                                       const double    Lambda,
0109                                       const double    Rho,
0110                                       const gp_Pnt2d& P1,
0111                                       gp_Pnt2d&       P2) const;
0112 
0113   //! compute the energy (and derivatives) in intermediate format
0114   Standard_EXPORT virtual bool Compute(const int DerivativeOrder, math_Vector& Result) = 0;
0115 
0116   occ::handle<NCollection_HArray1<gp_Pnt2d>> MyPoles;
0117   int                                        MyContrOrder1;
0118   int                                        MyContrOrder2;
0119   bool                                       MyWithAuxValue;
0120   int                                        MyNbVar;
0121 
0122 private:
0123   int                       MyNbValues;
0124   NCollection_Array1<gp_XY> MyLinearForm;
0125   NCollection_Array1<gp_XY> MyQuadForm;
0126   math_Vector               MyGradient;
0127   math_Vector               MyHessian;
0128 };
0129 
0130 #include <FairCurve_Energy.lxx>
0131 
0132 #endif // _FairCurve_Energy_HeaderFile