summaryrefslogtreecommitdiff
path: root/src/Expr/Expr_GreaterThanOrEqual.cxx
blob: 461837d6c0c29785435c9a713fd1034e7e244596 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//static const char* sccsid = "@(#)Expr_GreaterThanOrEqual.cxx	3.2 95/01/10"; // Do not delete this line. Used by sccs.
// Copyright: 	Matra-Datavision 1991
// File:	Expr_GreaterThanOrEqual.cxx
// Created:	Thu Jun 13 13:48:41 1991
// Author:	Arnaud BOUZY
//		<adn>

#include <Expr_GreaterThanOrEqual.ixx>
#include <Expr_NumericValue.hxx>
#include <Expr.hxx>

Expr_GreaterThanOrEqual::Expr_GreaterThanOrEqual (const Handle(Expr_GeneralExpression)& exp1, const Handle(Expr_GeneralExpression)& exp2)
{
  SetFirstMember(exp1);
  SetSecondMember(exp2);
}

Standard_Boolean Expr_GreaterThanOrEqual::IsSatisfied () const
{
  Handle(Expr_GeneralExpression) fm = FirstMember();
  Handle(Expr_GeneralExpression) sm = SecondMember();
  fm = fm->Simplified();
  sm = sm->Simplified();
  if (fm->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
    if (sm->IsKind(STANDARD_TYPE(Expr_NumericValue))) {
      Handle(Expr_NumericValue) nfm = Handle(Expr_NumericValue)::DownCast(fm);
      Handle(Expr_NumericValue) nsm = Handle(Expr_NumericValue)::DownCast(sm);
      return (nfm->GetValue() >= nsm->GetValue());
    }
  }
  return Standard_False;
}

Handle(Expr_GeneralRelation) Expr_GreaterThanOrEqual::Simplified () const
{
  Handle(Expr_GeneralExpression) fm = FirstMember();
  Handle(Expr_GeneralExpression) sm = SecondMember();
  return new Expr_GreaterThanOrEqual(fm->Simplified(),sm->Simplified());
}

void Expr_GreaterThanOrEqual::Simplify ()
{
  Handle(Expr_GeneralExpression) fm = FirstMember();
  Handle(Expr_GeneralExpression) sm = SecondMember();
  SetFirstMember(fm->Simplified());
  SetSecondMember(sm->Simplified());
}

Handle(Expr_GeneralRelation) Expr_GreaterThanOrEqual::Copy () const
{
  return new Expr_GreaterThanOrEqual(Expr::CopyShare(FirstMember()),
				     Expr::CopyShare(SecondMember()));
}

TCollection_AsciiString Expr_GreaterThanOrEqual::String() const
{
  return FirstMember()->String() + " >= " + SecondMember()->String();
}