b311480e |
1 | // Created on: 1991-03-06 |
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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Expr_GeneralExpression.hxx> |
19 | #include <Expr_NamedUnknown.hxx> |
20 | #include <Expr_NumericValue.hxx> |
21 | #include <Standard_OutOfRange.hxx> |
22 | #include <Standard_Type.hxx> |
23 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
24 | |
42cf5bc1 |
25 | #include <stdio.h> |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(Expr_NumericValue,Expr_GeneralExpression) |
27 | |
7fd59977 |
28 | Expr_NumericValue::Expr_NumericValue(const Standard_Real val) |
29 | { |
30 | myValue = val; |
31 | } |
32 | |
33 | Standard_Real Expr_NumericValue::GetValue() const |
34 | { |
35 | return myValue; |
36 | } |
37 | |
38 | void Expr_NumericValue::SetValue(const Standard_Real val) |
39 | { |
40 | myValue = val; |
41 | } |
42 | |
43 | Standard_Integer Expr_NumericValue::NbSubExpressions() const |
44 | { |
45 | return 0; |
46 | } |
47 | |
48 | const Handle(Expr_GeneralExpression)& Expr_NumericValue::SubExpression(const Standard_Integer) const |
49 | { |
9775fa61 |
50 | throw Standard_OutOfRange(); |
7fd59977 |
51 | } |
52 | |
53 | Handle(Expr_GeneralExpression) Expr_NumericValue::Simplified() const |
54 | { |
55 | return Copy(); |
56 | } |
57 | |
58 | Handle(Expr_GeneralExpression) Expr_NumericValue::Copy() const |
59 | { |
60 | return new Expr_NumericValue(myValue); |
61 | } |
62 | |
63 | Standard_Boolean Expr_NumericValue::ContainsUnknowns () const |
64 | { |
65 | return Standard_False; |
66 | } |
67 | |
68 | Standard_Boolean Expr_NumericValue::Contains (const Handle(Expr_GeneralExpression)& ) const |
69 | { |
70 | return Standard_False; |
71 | } |
72 | |
73 | Standard_Boolean Expr_NumericValue::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const |
74 | { |
75 | if (!Other->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
76 | return Standard_False; |
77 | } |
78 | Handle(Expr_NumericValue) NVOther = Handle(Expr_NumericValue)::DownCast(Other); |
79 | return (myValue == NVOther->GetValue()); |
80 | } |
81 | |
82 | Standard_Boolean Expr_NumericValue::IsLinear () const |
83 | { |
84 | return Standard_True; |
85 | } |
86 | |
87 | Handle(Expr_GeneralExpression) Expr_NumericValue::Derivative (const Handle(Expr_NamedUnknown)& ) const |
88 | { |
89 | return new Expr_NumericValue(0.0); |
90 | } |
91 | |
92 | Handle(Expr_GeneralExpression) Expr_NumericValue::NDerivative (const Handle(Expr_NamedUnknown)& , const Standard_Integer) const |
93 | { |
94 | return new Expr_NumericValue(0.0); |
95 | } |
96 | |
97 | void Expr_NumericValue::Replace (const Handle(Expr_NamedUnknown)& , const Handle(Expr_GeneralExpression)& ) |
98 | { |
99 | } |
100 | |
101 | Handle(Expr_GeneralExpression) Expr_NumericValue::ShallowSimplified () const |
102 | { |
103 | Handle(Expr_NumericValue) me = this; |
104 | return me; |
105 | } |
106 | |
107 | Standard_Real Expr_NumericValue::Evaluate(const Expr_Array1OfNamedUnknown&, const TColStd_Array1OfReal&) const |
108 | { |
109 | return myValue; |
110 | } |
111 | |
112 | TCollection_AsciiString Expr_NumericValue::String() const |
113 | { |
114 | char val[100]; |
91322f44 |
115 | Sprintf(val,"%g",myValue); |
7fd59977 |
116 | return TCollection_AsciiString(val); |
117 | } |