b311480e |
1 | // Created on: 1991-03-06 |
2 | // Created by: Arnaud BOUZY |
3 | // Copyright (c) 1991-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <Expr_NumericValue.ixx> |
24 | #include <Standard_OutOfRange.hxx> |
25 | |
26 | //#if defined (WNT) || !defined (DEB) |
27 | # include <stdio.h> |
28 | //#endif // WNT || !DEB |
29 | |
30 | Expr_NumericValue::Expr_NumericValue(const Standard_Real val) |
31 | { |
32 | myValue = val; |
33 | } |
34 | |
35 | Standard_Real Expr_NumericValue::GetValue() const |
36 | { |
37 | return myValue; |
38 | } |
39 | |
40 | void Expr_NumericValue::SetValue(const Standard_Real val) |
41 | { |
42 | myValue = val; |
43 | } |
44 | |
45 | Standard_Integer Expr_NumericValue::NbSubExpressions() const |
46 | { |
47 | return 0; |
48 | } |
49 | |
50 | const Handle(Expr_GeneralExpression)& Expr_NumericValue::SubExpression(const Standard_Integer) const |
51 | { |
52 | Standard_OutOfRange::Raise(); |
53 | Handle(Expr_GeneralExpression)* bid=NULL; |
54 | return *bid; |
55 | } |
56 | |
57 | Handle(Expr_GeneralExpression) Expr_NumericValue::Simplified() const |
58 | { |
59 | return Copy(); |
60 | } |
61 | |
62 | Handle(Expr_GeneralExpression) Expr_NumericValue::Copy() const |
63 | { |
64 | return new Expr_NumericValue(myValue); |
65 | } |
66 | |
67 | Standard_Boolean Expr_NumericValue::ContainsUnknowns () const |
68 | { |
69 | return Standard_False; |
70 | } |
71 | |
72 | Standard_Boolean Expr_NumericValue::Contains (const Handle(Expr_GeneralExpression)& ) const |
73 | { |
74 | return Standard_False; |
75 | } |
76 | |
77 | Standard_Boolean Expr_NumericValue::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const |
78 | { |
79 | if (!Other->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
80 | return Standard_False; |
81 | } |
82 | Handle(Expr_NumericValue) NVOther = Handle(Expr_NumericValue)::DownCast(Other); |
83 | return (myValue == NVOther->GetValue()); |
84 | } |
85 | |
86 | Standard_Boolean Expr_NumericValue::IsLinear () const |
87 | { |
88 | return Standard_True; |
89 | } |
90 | |
91 | Handle(Expr_GeneralExpression) Expr_NumericValue::Derivative (const Handle(Expr_NamedUnknown)& ) const |
92 | { |
93 | return new Expr_NumericValue(0.0); |
94 | } |
95 | |
96 | Handle(Expr_GeneralExpression) Expr_NumericValue::NDerivative (const Handle(Expr_NamedUnknown)& , const Standard_Integer) const |
97 | { |
98 | return new Expr_NumericValue(0.0); |
99 | } |
100 | |
101 | void Expr_NumericValue::Replace (const Handle(Expr_NamedUnknown)& , const Handle(Expr_GeneralExpression)& ) |
102 | { |
103 | } |
104 | |
105 | Handle(Expr_GeneralExpression) Expr_NumericValue::ShallowSimplified () const |
106 | { |
107 | Handle(Expr_NumericValue) me = this; |
108 | return me; |
109 | } |
110 | |
111 | Standard_Real Expr_NumericValue::Evaluate(const Expr_Array1OfNamedUnknown&, const TColStd_Array1OfReal&) const |
112 | { |
113 | return myValue; |
114 | } |
115 | |
116 | TCollection_AsciiString Expr_NumericValue::String() const |
117 | { |
118 | char val[100]; |
91322f44 |
119 | Sprintf(val,"%g",myValue); |
7fd59977 |
120 | return TCollection_AsciiString(val); |
121 | } |