1 // Created on: 1991-01-14
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-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 _Expr_NamedFunction_HeaderFile
18 #define _Expr_NamedFunction_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <Expr_Array1OfNamedUnknown.hxx>
25 #include <Expr_GeneralFunction.hxx>
26 #include <Standard_Integer.hxx>
27 #include <Standard_Real.hxx>
28 #include <TColStd_Array1OfReal.hxx>
29 #include <Standard_Boolean.hxx>
30 class Expr_GeneralExpression;
31 class Standard_OutOfRange;
32 class Standard_DimensionMismatch;
33 class Standard_NumericError;
34 class Expr_NotEvaluable;
35 class TCollection_AsciiString;
36 class Expr_NamedUnknown;
37 class Expr_GeneralFunction;
40 class Expr_NamedFunction;
41 DEFINE_STANDARD_HANDLE(Expr_NamedFunction, Expr_GeneralFunction)
44 class Expr_NamedFunction : public Expr_GeneralFunction
50 //! Creates a function of given variables <vars> with name
51 //! <name> defined by the expression <exp>.
52 Standard_EXPORT Expr_NamedFunction(const TCollection_AsciiString& name, const Handle(Expr_GeneralExpression)& exp, const Expr_Array1OfNamedUnknown& vars);
54 //! Sets the name <newname> to <me>.
55 Standard_EXPORT void SetName (const TCollection_AsciiString& newname);
57 //! Returns the name assigned to <me>
58 Standard_EXPORT TCollection_AsciiString GetName() const;
60 //! Returns the number of variables of <me>.
61 Standard_EXPORT Standard_Integer NbOfVariables() const Standard_OVERRIDE;
63 //! Returns the variable denoted by <index> in <me>.
64 //! Raises OutOfRange if <index> is greater than
65 //! NbOfVariables of <me>, or less than or equal to zero.
66 Standard_EXPORT Handle(Expr_NamedUnknown) Variable (const Standard_Integer index) const Standard_OVERRIDE;
68 //! Computes the value of <me> with the given variables.
69 //! Raises DimensionMismatch if Length(vars) is different from
71 Standard_EXPORT Standard_Real Evaluate (const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& values) const Standard_OVERRIDE;
73 //! Returns a copy of <me> with the same form.
74 Standard_EXPORT Handle(Expr_GeneralFunction) Copy() const Standard_OVERRIDE;
76 //! Returns Derivative of <me> for variable <var>.
77 Standard_EXPORT Handle(Expr_GeneralFunction) Derivative (const Handle(Expr_NamedUnknown)& var) const Standard_OVERRIDE;
79 //! Returns Derivative of <me> for variable <var> with
81 Standard_EXPORT Handle(Expr_GeneralFunction) Derivative (const Handle(Expr_NamedUnknown)& var, const Standard_Integer deg) const Standard_OVERRIDE;
83 //! Tests if <me> and <func> are similar functions (same
84 //! name and same used expression).
85 Standard_EXPORT Standard_Boolean IsIdentical (const Handle(Expr_GeneralFunction)& func) const Standard_OVERRIDE;
87 //! Tests if <me> is linear on variable on range <index>
88 Standard_EXPORT Standard_Boolean IsLinearOnVariable (const Standard_Integer index) const Standard_OVERRIDE;
90 Standard_EXPORT TCollection_AsciiString GetStringName() const Standard_OVERRIDE;
92 //! Returns equivalent expression of <me>.
93 Standard_EXPORT Handle(Expr_GeneralExpression) Expression() const;
95 //! Modifies expression of <me>.
96 //! Warning: Beware of derivatives. See FunctionDerivative
97 Standard_EXPORT void SetExpression (const Handle(Expr_GeneralExpression)& exp);
102 DEFINE_STANDARD_RTTIEXT(Expr_NamedFunction,Expr_GeneralFunction)
112 TCollection_AsciiString myName;
113 Handle(Expr_GeneralExpression) myExp;
114 Expr_Array1OfNamedUnknown myVariables;
125 #endif // _Expr_NamedFunction_HeaderFile