From 81701662553ea47c664d146a0c27de5951a1fbd0 Mon Sep 17 00:00:00 2001 From: ana Date: Wed, 17 Dec 2014 16:22:00 +0300 Subject: [PATCH 1/2] 0022832: EDF GEOM: Bug with curve construction --- src/GEOM_I/GEOM_Object_i.cc | 15 ++++++++------- src/GEOM_I/GEOM_Object_i.hh | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 54e5c458d..dcaf20289 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -364,15 +364,16 @@ bool GEOM_Object_i::IsShape() return !_impl->GetValue().IsNull() && _impl->GetType() != GEOM_MARKER; } -bool GEOM_Object_i::IsSame(GEOM::GEOM_Object_ptr other) +bool GEOM_Object_i::IsSame(GEOM::GEOM_BaseObject_ptr other) { + GEOM::GEOM_Object_ptr shapePtr = GEOM::GEOM_Object::_narrow( other ); + if ( CORBA::is_nil( shapePtr ) ) + return false; TopoDS_Shape thisShape = _impl->GetValue(); TopoDS_Shape otherShape; - if ( !CORBA::is_nil( other ) ) { - Handle(GEOM_Object) otherObject = Handle(GEOM_Object)::DownCast - ( GEOM_Engine::GetEngine()->GetObject( other->GetStudyID(), other->GetEntry(), false )); - if ( !otherObject.IsNull() ) - otherShape = otherObject->GetValue(); - } + Handle(GEOM_Object) otherObject = Handle(GEOM_Object)::DownCast + ( GEOM_Engine::GetEngine()->GetObject( shapePtr->GetStudyID(), shapePtr->GetEntry(), false )); + if ( !otherObject.IsNull() ) + otherShape = otherObject->GetValue(); return thisShape.IsSame( otherShape ); } diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh index da7f035ed..b20020269 100644 --- a/src/GEOM_I/GEOM_Object_i.hh +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -75,7 +75,7 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual GEOM::GEOM_Object_ptr GetMainShape(); - virtual bool IsSame(GEOM::GEOM_Object_ptr other); + virtual bool IsSame(GEOM::GEOM_BaseObject_ptr other); virtual bool IsShape(); From 3af84898743f2a045a215c498d2fb77f2673b935 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 18 Dec 2014 18:11:55 +0300 Subject: [PATCH 2/2] 0022832: EDF GEOM: Bug with curve construction Additional commit: fix memory leak plus small redesign --- src/GEOM_I/GEOM_Object_i.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index dcaf20289..08f2d1afd 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -366,14 +366,17 @@ bool GEOM_Object_i::IsShape() bool GEOM_Object_i::IsSame(GEOM::GEOM_BaseObject_ptr other) { - GEOM::GEOM_Object_ptr shapePtr = GEOM::GEOM_Object::_narrow( other ); - if ( CORBA::is_nil( shapePtr ) ) - return false; - TopoDS_Shape thisShape = _impl->GetValue(); - TopoDS_Shape otherShape; - Handle(GEOM_Object) otherObject = Handle(GEOM_Object)::DownCast - ( GEOM_Engine::GetEngine()->GetObject( shapePtr->GetStudyID(), shapePtr->GetEntry(), false )); - if ( !otherObject.IsNull() ) - otherShape = otherObject->GetValue(); - return thisShape.IsSame( otherShape ); + bool result = false; + + GEOM::GEOM_Object_var shapePtr = GEOM::GEOM_Object::_narrow( other ); + if ( !CORBA::is_nil( shapePtr ) ) { + Handle(GEOM_Object) otherObject = Handle(GEOM_Object)::DownCast + ( GEOM_Engine::GetEngine()->GetObject( shapePtr->GetStudyID(), shapePtr->GetEntry(), false )); + if ( !otherObject.IsNull() ) { + TopoDS_Shape thisShape = _impl->GetValue(); + TopoDS_Shape otherShape = otherObject->GetValue(); + result = !thisShape.IsNull() && !otherShape.IsNull() && thisShape.IsSame( otherShape ); + } + } + return result; }