1 // Created on: 1991-01-10
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_NamedUnknown_HeaderFile
18 #define _Expr_NamedUnknown_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Expr_NamedExpression.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Real.hxx>
27 #include <Expr_Array1OfNamedUnknown.hxx>
28 #include <TColStd_Array1OfReal.hxx>
29 class Expr_GeneralExpression;
30 class Expr_NotAssigned;
31 class Standard_OutOfRange;
32 class Standard_NumericError;
33 class Expr_InvalidAssignment;
34 class Expr_InvalidOperand;
35 class Expr_NotEvaluable;
36 class TCollection_AsciiString;
39 class Expr_NamedUnknown;
40 DEFINE_STANDARD_HANDLE(Expr_NamedUnknown, Expr_NamedExpression)
42 //! This class describes any variable of an expression.
43 //! Assignment is treated directly in this class.
44 class Expr_NamedUnknown : public Expr_NamedExpression
50 Standard_EXPORT Expr_NamedUnknown(const TCollection_AsciiString& name);
52 //! Tests if an expression is assigned to <me>.
53 Standard_Boolean IsAssigned() const;
55 //! If exists, returns the assigned expression.
56 //! An exception is raised if the expression does not exist.
57 Standard_EXPORT const Handle(Expr_GeneralExpression)& AssignedExpression() const;
59 //! Assigns <me> to <exp> expression.
60 //! Raises exception if <exp> refers to <me>.
61 Standard_EXPORT void Assign (const Handle(Expr_GeneralExpression)& exp);
63 //! Suppresses the assigned expression
66 //! Returns the number of sub-expressions contained
68 Standard_EXPORT Standard_Integer NbSubExpressions() const Standard_OVERRIDE;
70 //! Returns the <I>-th sub-expression of <me>
71 //! raises OutOfRange if <I> > NbSubExpressions(me)
72 Standard_EXPORT const Handle(Expr_GeneralExpression)& SubExpression (const Standard_Integer I) const Standard_OVERRIDE;
74 //! Returns a GeneralExpression after replacement of
75 //! NamedUnknowns by an associated expression and after
76 //! values computation.
77 Standard_EXPORT Handle(Expr_GeneralExpression) Simplified() const Standard_OVERRIDE;
79 //! Returns a GeneralExpression after a simplification
80 //! of the arguments of <me>.
81 Standard_EXPORT Handle(Expr_GeneralExpression) ShallowSimplified() const Standard_OVERRIDE;
83 //! Returns a copy of <me> having the same unknowns and functions.
84 Standard_EXPORT Handle(Expr_GeneralExpression) Copy() const Standard_OVERRIDE;
86 //! Tests if <me> contains NamedUnknown.
87 Standard_EXPORT Standard_Boolean ContainsUnknowns() const Standard_OVERRIDE;
89 //! Tests if <exp> is contained in <me>.
90 Standard_EXPORT Standard_Boolean Contains (const Handle(Expr_GeneralExpression)& exp) const Standard_OVERRIDE;
92 Standard_EXPORT Standard_Boolean IsLinear() const Standard_OVERRIDE;
94 //! Returns the derivative on <X> unknown of <me>
95 Standard_EXPORT Handle(Expr_GeneralExpression) Derivative (const Handle(Expr_NamedUnknown)& X) const Standard_OVERRIDE;
97 //! Replaces all occurrences of <var> with <with> in <me>
98 //! Raises InvalidOperand if <with> contains <me>.
99 Standard_EXPORT void Replace (const Handle(Expr_NamedUnknown)& var, const Handle(Expr_GeneralExpression)& with) Standard_OVERRIDE;
101 //! Returns the value of <me> (as a Real) by
102 //! replacement of <vars> by <vals>.
103 //! Raises NotEvaluable if <me> contains NamedUnknown not
104 //! in <vars> or NumericError if result cannot be computed.
105 Standard_EXPORT Standard_Real Evaluate (const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const Standard_OVERRIDE;
110 DEFINE_STANDARD_RTTIEXT(Expr_NamedUnknown,Expr_NamedExpression)
120 Handle(Expr_GeneralExpression) myExpression;
126 #include <Expr_NamedUnknown.lxx>
132 #endif // _Expr_NamedUnknown_HeaderFile