1 // Created on: 1996-03-06
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 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.
17 #ifndef _FairCurve_Energy_HeaderFile
18 #define _FairCurve_Energy_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <TColgp_HArray1OfPnt2d.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <TColgp_Array1OfXY.hxx>
28 #include <math_Vector.hxx>
29 #include <math_MultipleVarFunctionWithHessian.hxx>
30 #include <Standard_Real.hxx>
35 //! necessary methodes to compute the energy of an FairCurve.
36 class FairCurve_Energy : public math_MultipleVarFunctionWithHessian
43 //! returns the number of variables of the energy.
44 virtual Standard_Integer NbVariables() const Standard_OVERRIDE;
46 //! computes the values of the Energys E for the
48 //! Returns True if the computation was done successfully,
50 Standard_EXPORT virtual Standard_Boolean Value (const math_Vector& X, Standard_Real& E) Standard_OVERRIDE;
52 //! computes the gradient <G> of the energys for the
54 //! Returns True if the computation was done successfully,
56 Standard_EXPORT virtual Standard_Boolean Gradient (const math_Vector& X, math_Vector& G) Standard_OVERRIDE;
58 //! computes the Energy <E> and the gradient <G> of the
59 //! energy for the variable <X>.
60 //! Returns True if the computation was done successfully,
62 Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& E, math_Vector& G) Standard_OVERRIDE;
64 //! computes the Energy <E>, the gradient <G> and the
65 //! Hessian <H> of the energy for the variable <X>.
66 //! Returns True if the computation was done
67 //! successfully, False otherwise.
68 Standard_EXPORT virtual Standard_Boolean Values (const math_Vector& X, Standard_Real& E, math_Vector& G, math_Matrix& H) Standard_OVERRIDE;
70 //! compute the variables <X> which correspond with the field <MyPoles>
71 Standard_EXPORT virtual Standard_Boolean Variable (math_Vector& X) const;
74 const Handle(TColgp_HArray1OfPnt2d)& Poles() const;
82 //! Angles corresspond to the Ox axis
83 //! ConstrOrder1(2) can be equal to 0, 1 or 2
84 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);
86 //! It is use internally to make the Gradient Vector <G>
87 Standard_EXPORT void Gradient1 (const math_Vector& TheVector, math_Vector& G);
89 //! It is use internally to make the Hessian Matrix <H>
90 Standard_EXPORT void Hessian1 (const math_Vector& TheVector, math_Matrix& H);
92 //! compute the poles which correspond with the variable X
93 Standard_EXPORT virtual void ComputePoles (const math_Vector& X);
95 Standard_Integer Indice (const Standard_Integer i, const Standard_Integer j) const;
97 //! compute the pole which depend of variables and G1 constraint
98 Standard_EXPORT void ComputePolesG1 (const Standard_Integer Side, const Standard_Real Lambda, const gp_Pnt2d& P1, gp_Pnt2d& P2) const;
100 //! compute the pole which depend of variables and G2 constraint
101 Standard_EXPORT void ComputePolesG2 (const Standard_Integer Side, const Standard_Real Lambda, const Standard_Real Rho, const gp_Pnt2d& P1, gp_Pnt2d& P2) const;
103 //! compute the energy (and derivatives) in intermediat format
104 Standard_EXPORT virtual Standard_Boolean Compute (const Standard_Integer DerivativeOrder, math_Vector& Result) = 0;
107 Handle(TColgp_HArray1OfPnt2d) MyPoles;
108 Standard_Integer MyContrOrder1;
109 Standard_Integer MyContrOrder2;
110 Standard_Boolean MyWithAuxValue;
111 Standard_Integer MyNbVar;
118 Standard_Integer MyNbValues;
119 TColgp_Array1OfXY MyLinearForm;
120 TColgp_Array1OfXY MyQuadForm;
121 math_Vector MyGradient;
122 math_Vector MyHessian;
128 #include <FairCurve_Energy.lxx>
134 #endif // _FairCurve_Energy_HeaderFile