1 // Created on: 1991-04-15
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <Expr_UnaryExpression.ixx>
23 #include <Expr_NamedUnknown.hxx>
24 #include <Expr_InvalidOperand.hxx>
25 #include <Standard_OutOfRange.hxx>
27 void Expr_UnaryExpression::SetOperand (const Handle(Expr_GeneralExpression)& exp)
29 Handle(Expr_UnaryExpression) me = this;
31 Expr_InvalidOperand::Raise();
33 if (exp->Contains(me)) {
34 Expr_InvalidOperand::Raise();
39 void Expr_UnaryExpression::CreateOperand (const Handle(Expr_GeneralExpression)& exp)
44 Standard_Integer Expr_UnaryExpression::NbSubExpressions () const
49 const Handle(Expr_GeneralExpression)& Expr_UnaryExpression::SubExpression (const Standard_Integer I) const
52 Standard_OutOfRange::Raise();
57 Standard_Boolean Expr_UnaryExpression::ContainsUnknowns () const
59 if (!myOperand->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
60 return myOperand->ContainsUnknowns();
65 Standard_Boolean Expr_UnaryExpression::Contains (const Handle(Expr_GeneralExpression)& exp) const
67 if (myOperand != exp) {
68 return myOperand->Contains(exp);
73 void Expr_UnaryExpression::Replace (const Handle(Expr_NamedUnknown)& var, const Handle(Expr_GeneralExpression)& with)
75 if (myOperand == var) {
79 if (myOperand->Contains(var)) {
80 myOperand->Replace(var,with);
86 Handle(Expr_GeneralExpression) Expr_UnaryExpression::Simplified() const
88 Handle(Expr_UnaryExpression) cop = Handle(Expr_UnaryExpression)::DownCast(Copy());
89 Handle(Expr_GeneralExpression) op = cop->Operand();
90 cop->SetOperand(op->Simplified());
91 return cop->ShallowSimplified();