7fd59977 |
1 | // Copyright: Matra-Datavision 1991 |
2 | // File: Expr_Sign.cxx |
3 | // Created: Tue May 28 12:54:14 1991 |
4 | // Author: Arnaud BOUZY |
5 | // <adn> |
6 | |
7 | #include <Expr_Sign.ixx> |
8 | #include <Expr_NumericValue.hxx> |
9 | #include <Expr.hxx> |
10 | |
11 | Expr_Sign::Expr_Sign (const Handle(Expr_GeneralExpression)& exp) |
12 | { |
13 | CreateOperand(exp); |
14 | } |
15 | |
16 | Handle(Expr_GeneralExpression) Expr_Sign::ShallowSimplified () const |
17 | { |
18 | Handle(Expr_GeneralExpression) op = Operand(); |
19 | if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
20 | Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op); |
21 | return new Expr_NumericValue(Expr::Sign(valop->GetValue())); |
22 | } |
23 | Handle(Expr_Sign) me = this; |
24 | return me; |
25 | } |
26 | |
27 | Handle(Expr_GeneralExpression) Expr_Sign::Copy () const |
28 | { |
29 | return new Expr_Sign(Expr::CopyShare(Operand())); |
30 | } |
31 | |
32 | Standard_Boolean Expr_Sign::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const |
33 | { |
34 | if (!Other->IsKind(STANDARD_TYPE(Expr_Sign))) { |
35 | return Standard_False; |
36 | } |
37 | Handle(Expr_GeneralExpression) op = Operand(); |
38 | return op->IsIdentical(Other->SubExpression(1)); |
39 | } |
40 | |
41 | Standard_Boolean Expr_Sign::IsLinear () const |
42 | { |
43 | return !ContainsUnknowns(); |
44 | } |
45 | |
46 | Handle(Expr_GeneralExpression) Expr_Sign::Derivative (const Handle(Expr_NamedUnknown)& ) const |
47 | { |
48 | return new Expr_NumericValue(0.0); |
49 | } |
50 | |
51 | Standard_Real Expr_Sign::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const |
52 | { |
53 | Standard_Real res = Operand()->Evaluate(vars,vals); |
54 | return Expr::Sign(res); |
55 | } |
56 | |
57 | TCollection_AsciiString Expr_Sign::String() const |
58 | { |
59 | TCollection_AsciiString str("Sign("); |
60 | str += Operand()->String(); |
61 | str += ")"; |
62 | return str; |
63 | } |