summaryrefslogtreecommitdiff
path: root/src/Expr/Expr.cxx
blob: 6da92bcf012640338759d535e8382c2bd709b669 (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
//static const char* sccsid = "@(#)Expr.cxx	3.2 95/01/10"; // Do not delete this line. Used by sccs.
// Copyright: 	Matra-Datavision 1991
// File:	Expr.cxx
// Created:	Fri Sep 20 11:23:07 1991
// Author:	Arnaud BOUZY
//		<adn>

#include <Expr.hxx>
#include <Expr_NamedUnknown.hxx>
#include <Expr_GeneralExpression.hxx>
#include <Expr_GeneralRelation.hxx>
#include <Expr_UnknownIterator.hxx>
#include <Expr_RUIterator.hxx>

Handle(Expr_GeneralExpression) Expr::CopyShare(const Handle(Expr_GeneralExpression)& exp)
{
  if (exp->IsShareable()) {
    return exp;
  }
  return exp->Copy();
}

Standard_Integer Expr::NbOfFreeVariables(const Handle(Expr_GeneralRelation)& rel)
{
  Standard_Integer nbvar = 0;
  Expr_RUIterator rit(rel);
  while (rit.More()) {
    if (!rit.Value()->IsAssigned()) {
      nbvar++;
    }
    rit.Next();
  }
  return nbvar;
}

Standard_Integer Expr::NbOfFreeVariables(const Handle(Expr_GeneralExpression)& exp)
{
  Standard_Integer nbvar = 0;
  Expr_UnknownIterator uit(exp);
  while (uit.More()) {
    if (!uit.Value()->IsAssigned()) {
      nbvar++;
    }
    uit.Next();
  }
  return nbvar;
}

Standard_Real Expr::Sign(const Standard_Real val)
{
  return ::Sign(1.0,val);
}