0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / Expr / Expr_NumericValue.cxx
1 // Created on: 1991-03-06
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
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>
24
25 #include <stdio.h>
26 IMPLEMENT_STANDARD_RTTIEXT(Expr_NumericValue,Expr_GeneralExpression)
27
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 {
50   throw Standard_OutOfRange();
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];
115   Sprintf(val,"%g",myValue);
116   return TCollection_AsciiString(val);
117 }