b311480e |
1 | // Created on: 1991-06-13 |
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_GeneralRelation.hxx> |
21 | #include <Expr_LessThanOrEqual.hxx> |
22 | #include <Expr_NumericValue.hxx> |
23 | #include <Standard_NumericError.hxx> |
24 | #include <Standard_Type.hxx> |
25 | #include <TCollection_AsciiString.hxx> |
7fd59977 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(Expr_LessThanOrEqual,Expr_SingleRelation) |
28 | |
7fd59977 |
29 | Expr_LessThanOrEqual::Expr_LessThanOrEqual (const Handle(Expr_GeneralExpression)& exp1, const Handle(Expr_GeneralExpression)& exp2) |
30 | { |
31 | SetFirstMember(exp1); |
32 | SetSecondMember(exp2); |
33 | } |
34 | |
35 | Standard_Boolean Expr_LessThanOrEqual::IsSatisfied () const |
36 | { |
37 | Handle(Expr_GeneralExpression) fm = FirstMember(); |
38 | Handle(Expr_GeneralExpression) sm = SecondMember(); |
39 | fm = fm->Simplified(); |
40 | sm = sm->Simplified(); |
41 | if (fm->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
42 | if (sm->IsKind(STANDARD_TYPE(Expr_NumericValue))) { |
43 | Handle(Expr_NumericValue) nfm = Handle(Expr_NumericValue)::DownCast(fm); |
44 | Handle(Expr_NumericValue) nsm = Handle(Expr_NumericValue)::DownCast(sm); |
45 | return (nfm->GetValue() <= nsm->GetValue()); |
46 | } |
47 | } |
48 | return Standard_False; |
49 | } |
50 | |
51 | Handle(Expr_GeneralRelation) Expr_LessThanOrEqual::Simplified () const |
52 | { |
53 | Handle(Expr_GeneralExpression) fm = FirstMember(); |
54 | Handle(Expr_GeneralExpression) sm = SecondMember(); |
55 | return new Expr_LessThanOrEqual(fm->Simplified(),sm->Simplified()); |
56 | } |
57 | |
58 | void Expr_LessThanOrEqual::Simplify () |
59 | { |
60 | Handle(Expr_GeneralExpression) fm = FirstMember(); |
61 | Handle(Expr_GeneralExpression) sm = SecondMember(); |
62 | SetFirstMember(fm->Simplified()); |
63 | SetSecondMember(sm->Simplified()); |
64 | } |
65 | |
66 | Handle(Expr_GeneralRelation) Expr_LessThanOrEqual::Copy () const |
67 | { |
68 | return new Expr_LessThanOrEqual(Expr::CopyShare(FirstMember()), |
69 | Expr::CopyShare(SecondMember())); |
70 | } |
71 | |
72 | TCollection_AsciiString Expr_LessThanOrEqual::String() const |
73 | { |
74 | return FirstMember()->String() + " <= " + SecondMember()->String(); |
75 | } |