From a2ca2a304fdce83c3af9f67b1e3097817b4ed47b Mon Sep 17 00:00:00 2001 From: pdn Date: Mon, 22 Sep 2014 19:47:04 +0400 Subject: [PATCH] 0025257: Expr should use names for comparing Expression should use string names for comparing, fixed --- src/Expr/Expr_NamedExpression.cxx | 40 ++++++++++++++++++++++++++----- src/Expr/Expr_NamedUnknown.cxx | 10 ++++++-- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/Expr/Expr_NamedExpression.cxx b/src/Expr/Expr_NamedExpression.cxx index de5769d0e1..a398b41227 100644 --- a/src/Expr/Expr_NamedExpression.cxx +++ b/src/Expr/Expr_NamedExpression.cxx @@ -16,29 +16,57 @@ #include +//======================================================================= +//function : GetName +//purpose : +//======================================================================= + const TCollection_AsciiString& Expr_NamedExpression::GetName() const { return myName; } +//======================================================================= +//function : SetName +//purpose : +//======================================================================= + void Expr_NamedExpression::SetName(const TCollection_AsciiString& name) { myName = name; } +//======================================================================= +//function : IsShareable +//purpose : +//======================================================================= + Standard_Boolean Expr_NamedExpression::IsShareable () const { return Standard_True; } -Standard_Boolean Expr_NamedExpression::IsIdentical (const Handle(Expr_GeneralExpression)& Other) const +//======================================================================= +//function : IsIdentical +//purpose : +//======================================================================= + +Standard_Boolean Expr_NamedExpression::IsIdentical + (const Handle(Expr_GeneralExpression)& theOther) const { - if (!Other->IsKind(STANDARD_TYPE(Expr_NamedExpression))) { - return Standard_False; + Standard_Boolean aResult(Standard_False); + if (theOther->IsKind(STANDARD_TYPE(Expr_NamedExpression))) { +// Handle(Expr_NamedExpression) me = this; +// Handle(Expr_NamedExpression) NEOther = Handle(Expr_NamedExpression)::DownCast(Other); +// return (me == NEOther); + +//AGV 22.03.12: Comparison should be based on names rather than Handles + const Expr_NamedExpression* pOther = + static_cast(theOther.operator->()); + if (pOther == this || pOther->GetName().IsEqual(myName)) + aResult = Standard_True; } - Handle(Expr_NamedExpression) me = this; - Handle(Expr_NamedExpression) NEOther = Handle(Expr_NamedExpression)::DownCast(Other); - return (me == NEOther); + return aResult; } TCollection_AsciiString Expr_NamedExpression::String() const diff --git a/src/Expr/Expr_NamedUnknown.cxx b/src/Expr/Expr_NamedUnknown.cxx index bbca0e5f80..dead2e03a2 100644 --- a/src/Expr/Expr_NamedUnknown.cxx +++ b/src/Expr/Expr_NamedUnknown.cxx @@ -92,10 +92,16 @@ Standard_Boolean Expr_NamedUnknown::ContainsUnknowns () const } } -Standard_Boolean Expr_NamedUnknown::Contains (const Handle(Expr_GeneralExpression)& exp) const +Standard_Boolean Expr_NamedUnknown::Contains + (const Handle(Expr_GeneralExpression)& exp) const { if (!IsAssigned()) { - return Standard_False; + const Handle(Expr_NamedUnknown) expNamed = + Handle(Expr_NamedUnknown)::DownCast(exp); + if (expNamed.IsNull() || expNamed->IsAssigned()) + return Standard_False; + //AGV 22.03.12: Comparison based on name coincidence + return IsIdentical(expNamed); } if (myExpression == exp) { return Standard_True;