Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:30

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