1 // Created on: 1991-06-13
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Expr_GeneralExpression.hxx>
20 #include <Expr_GeneralRelation.hxx>
21 #include <Expr_LessThan.hxx>
22 #include <Expr_NumericValue.hxx>
23 #include <Standard_NumericError.hxx>
24 #include <Standard_Type.hxx>
25 #include <TCollection_AsciiString.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(Expr_LessThan,Expr_SingleRelation)
29 Expr_LessThan::Expr_LessThan (const Handle(Expr_GeneralExpression)& exp1, const Handle(Expr_GeneralExpression)& exp2)
32 SetSecondMember(exp2);
35 Standard_Boolean Expr_LessThan::IsSatisfied () const
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());
48 return Standard_False;
51 Handle(Expr_GeneralRelation) Expr_LessThan::Simplified () const
53 Handle(Expr_GeneralExpression) fm = FirstMember();
54 Handle(Expr_GeneralExpression) sm = SecondMember();
55 return new Expr_LessThan(fm->Simplified(),sm->Simplified());
58 void Expr_LessThan::Simplify ()
60 Handle(Expr_GeneralExpression) fm = FirstMember();
61 Handle(Expr_GeneralExpression) sm = SecondMember();
62 SetFirstMember(fm->Simplified());
63 SetSecondMember(sm->Simplified());
66 Handle(Expr_GeneralRelation) Expr_LessThan::Copy () const
68 return new Expr_LessThan(Expr::CopyShare(FirstMember()),
69 Expr::CopyShare(SecondMember()));
72 TCollection_AsciiString Expr_LessThan::String() const
74 return FirstMember()->String() + " < " + SecondMember()->String();