7fd59977 |
1 | // Copyright: Matra-Datavision 1991 |
2 | // File: Expr_NumericValue.cxx |
3 | // Created: Wed Mar 6 11:06:16 1991 |
4 | // Author: Arnaud BOUZY |
5 | // <adn> |
6 | |
7 | |
8 | #include <Expr_NumericValue.ixx> |
9 | #include <Standard_OutOfRange.hxx> |
10 | |
11 | //#if defined (WNT) || !defined (DEB) |
12 | # include <stdio.h> |
13 | //#endif // WNT || !DEB |
14 | |
15 | Expr_NumericValue::Expr_NumericValue(const Standard_Real val) |
16 | { |
17 | myValue = val; |
18 | } |
19 | |
20 | Standard_Real Expr_NumericValue::GetValue() const |
21 | { |
22 | return myValue; |
23 | } |
24 | |
25 | void Expr_NumericValue::SetValue(const Standard_Real val) |
26 | { |
27 | myValue = val; |
28 | } |
29 | |
30 | Standard_Integer Expr_NumericValue::NbSubExpressions() const |
31 | { |
32 | return 0; |
33 | } |
34 | |
35 | const Handle(Expr_GeneralExpression)& Expr_NumericValue::SubExpression(const Standard_Integer) const |
36 | { |
37 | Standard_OutOfRange::Raise(); |
38 | Handle(Expr_GeneralExpression)* bid=NULL; |
39 | return *bid; |
40 | } |
41 | |
42 | Handle(Expr_GeneralExpression) Expr_NumericValue::Simplified() const |
43 | { |
44 | return Copy(); |
45 | } |
46 | |
47 | Handle(Expr_GeneralExpression) Expr_NumericValue::Copy() const |
48 | { |
49 | return new Expr_NumericValue(myValue); |
50 | } |
51 | |
52 | Standard_Boolean Expr_NumericValue::ContainsUnknowns () const |
53 | { |
54 | return Standard_False; |
55 | } |
56 | |
57 | Standard_Boolean Expr_NumericValue::Contains (const Handle(Expr_GeneralExpression)& ) const |
58 | { |
59 | return Standard_False; |
60 | } |
61 | |
62 | Standard_Boolean Expr_NumericValue::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const |
63 | { |
64 | if (!Other->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
65 | return Standard_False; |
66 | } |
67 | Handle(Expr_NumericValue) NVOther = Handle(Expr_NumericValue)::DownCast(Other); |
68 | return (myValue == NVOther->GetValue()); |
69 | } |
70 | |
71 | Standard_Boolean Expr_NumericValue::IsLinear () const |
72 | { |
73 | return Standard_True; |
74 | } |
75 | |
76 | Handle(Expr_GeneralExpression) Expr_NumericValue::Derivative (const Handle(Expr_NamedUnknown)& ) const |
77 | { |
78 | return new Expr_NumericValue(0.0); |
79 | } |
80 | |
81 | Handle(Expr_GeneralExpression) Expr_NumericValue::NDerivative (const Handle(Expr_NamedUnknown)& , const Standard_Integer) const |
82 | { |
83 | return new Expr_NumericValue(0.0); |
84 | } |
85 | |
86 | void Expr_NumericValue::Replace (const Handle(Expr_NamedUnknown)& , const Handle(Expr_GeneralExpression)& ) |
87 | { |
88 | } |
89 | |
90 | Handle(Expr_GeneralExpression) Expr_NumericValue::ShallowSimplified () const |
91 | { |
92 | Handle(Expr_NumericValue) me = this; |
93 | return me; |
94 | } |
95 | |
96 | Standard_Real Expr_NumericValue::Evaluate(const Expr_Array1OfNamedUnknown&, const TColStd_Array1OfReal&) const |
97 | { |
98 | return myValue; |
99 | } |
100 | |
101 | TCollection_AsciiString Expr_NumericValue::String() const |
102 | { |
103 | char val[100]; |
104 | sprintf(val,"%g",myValue); |
105 | return TCollection_AsciiString(val); |
106 | } |