0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- manual
[occt.git] / src / Expr / Expr_Sign.cxx
CommitLineData
b311480e 1// Created on: 1991-05-28
2// Created by: Arnaud BOUZY
3// Copyright (c) 1991-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
7fd59977 18#include <Expr.hxx>
42cf5bc1 19#include <Expr_GeneralExpression.hxx>
20#include <Expr_NamedUnknown.hxx>
21#include <Expr_NotEvaluable.hxx>
22#include <Expr_NumericValue.hxx>
23#include <Expr_Sign.hxx>
24#include <Standard_NumericError.hxx>
25#include <Standard_Type.hxx>
26#include <TCollection_AsciiString.hxx>
7fd59977 27
28Expr_Sign::Expr_Sign (const Handle(Expr_GeneralExpression)& exp)
29{
30 CreateOperand(exp);
31}
32
33Handle(Expr_GeneralExpression) Expr_Sign::ShallowSimplified () const
34{
35 Handle(Expr_GeneralExpression) op = Operand();
36 if (op->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
37 Handle(Expr_NumericValue) valop = Handle(Expr_NumericValue)::DownCast(op);
38 return new Expr_NumericValue(Expr::Sign(valop->GetValue()));
39 }
40 Handle(Expr_Sign) me = this;
41 return me;
42}
43
44Handle(Expr_GeneralExpression) Expr_Sign::Copy () const
45{
46 return new Expr_Sign(Expr::CopyShare(Operand()));
47}
48
49Standard_Boolean Expr_Sign::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const
50{
51 if (!Other->IsKind(STANDARD_TYPE(Expr_Sign))) {
52 return Standard_False;
53 }
54 Handle(Expr_GeneralExpression) op = Operand();
55 return op->IsIdentical(Other->SubExpression(1));
56}
57
58Standard_Boolean Expr_Sign::IsLinear () const
59{
60 return !ContainsUnknowns();
61}
62
63Handle(Expr_GeneralExpression) Expr_Sign::Derivative (const Handle(Expr_NamedUnknown)& ) const
64{
65 return new Expr_NumericValue(0.0);
66}
67
68Standard_Real Expr_Sign::Evaluate(const Expr_Array1OfNamedUnknown& vars, const TColStd_Array1OfReal& vals) const
69{
70 Standard_Real res = Operand()->Evaluate(vars,vals);
71 return Expr::Sign(res);
72}
73
74TCollection_AsciiString Expr_Sign::String() const
75{
76 TCollection_AsciiString str("Sign(");
77 str += Operand()->String();
78 str += ")";
79 return str;
80}