X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGEOM_I%2FGEOM_Object_i.cc;h=165613dc60e94d13267cef658b3e77a1174dcd43;hb=693e5f65fe0f4868fe2e0f2923aef6a3afb20d67;hp=54e5c458d28ab550dd224dbd783b89e8cd16ce22;hpb=4e4b3762fc1215eb520840fe65eaeeea0854eff8;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index 54e5c458d..165613dc6 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,7 @@ //============================================================================= GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - Handle(GEOM_Object) theImpl) : + Handle(::GEOM_Object) theImpl) : SALOME::GenericObj_i( thePOA ), GEOM_BaseObject_i( thePOA, theEngine, theImpl ), _impl( theImpl ) @@ -75,7 +76,7 @@ GEOM_Object_i::GEOM_Object_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr GEOM_Object_i::~GEOM_Object_i() { - MESSAGE("GEOM_Object_i::~GEOM_Object_i"); + //MESSAGE("GEOM_Object_i::~GEOM_Object_i"); } //============================================================================= @@ -158,6 +159,47 @@ GEOM::shape_type GEOM_Object_i::GetMaxShapeType() return getMinMaxShapeType( _impl->GetValue(), false ); } +//================================================================================ +/*! + * GetSubShapeName + */ +//================================================================================ + +char* GEOM_Object_i::GetSubShapeName(CORBA::Long subID) +{ + CORBA::String_var name(""); + + Handle(::GEOM_Function) aMainFun = _impl->GetLastFunction(); + if ( aMainFun.IsNull() ) return name._retn(); + + const TDataStd_ListOfExtendedString& aListEntries = aMainFun->GetSubShapeReferences(); + TDataStd_ListIteratorOfListOfExtendedString anIt( aListEntries ); + for (; anIt.More(); anIt.Next()) + { + TCollection_AsciiString anEntry = anIt.Value(); + Handle(::GEOM_BaseObject) anObj = + GEOM_Engine::GetEngine()->GetObject( _impl->GetDocID(), anEntry.ToCString(), false ); + if ( anObj.IsNull() ) continue; + + TCollection_AsciiString aSubName = anObj->GetName(); + if ( aSubName.IsEmpty() ) continue; + + Handle(::GEOM_Function) aFun = anObj->GetLastFunction(); + if ( aFun.IsNull() ) continue; + + GEOM_ISubShape ISS( aFun ); + Handle(TColStd_HArray1OfInteger) subIDs = ISS.GetIndices(); + if ( subIDs.IsNull() || subIDs->Length() != 1 ) continue; + + if ( subIDs->Value( subIDs->Lower() ) == subID ) + { + name = aSubName.ToCString(); + break; + } + } + return name._retn(); +} + //============================================================================= /*! * SetColor @@ -317,7 +359,7 @@ GEOM::ListOfLong* GEOM_Object_i::GetSubShapeIndices() GEOM::ListOfLong_var anIndices = new GEOM::ListOfLong; if(!_impl->IsMainShape()) { - Handle(GEOM_Function) aFunction = _impl->GetLastFunction(); //Get Sub-shape function (always the first (and last) one) + Handle(::GEOM_Function) aFunction = _impl->GetLastFunction(); //Get Sub-shape function (always the first (and last) one) if(aFunction.IsNull()) return anIndices._retn(); GEOM_ISubShape ISS(aFunction); Handle(TColStd_HArray1OfInteger) anArray = ISS.GetIndices(); @@ -342,7 +384,7 @@ GEOM::GEOM_Object_ptr GEOM_Object_i::GetMainShape() { GEOM::GEOM_Object_var obj; if(!_impl->IsMainShape()) { - Handle(GEOM_Function) aFunction = _impl->GetFunction(1); //Get Sub-shape function (always the first (and last) one) + Handle(::GEOM_Function) aFunction = _impl->GetFunction(1); //Get Sub-shape function (always the first (and last) one) if(aFunction.IsNull()) return obj._retn(); GEOM_ISubShape ISS(aFunction); @@ -364,15 +406,20 @@ 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) { - 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(); + bool result = false; + + GEOM::GEOM_Object_var shapePtr = GEOM::GEOM_Object::_narrow( other ); + if ( !CORBA::is_nil( shapePtr ) ) { + CORBA::String_var entry = shapePtr->GetEntry(); + Handle(::GEOM_Object) otherObject = Handle(::GEOM_Object)::DownCast + ( GEOM_Engine::GetEngine()->GetObject( shapePtr->GetStudyID(), entry, false )); + if ( !otherObject.IsNull() ) { + TopoDS_Shape thisShape = _impl->GetValue(); + TopoDS_Shape otherShape = otherObject->GetValue(); + result = !thisShape.IsNull() && !otherShape.IsNull() && thisShape.IsSame( otherShape ); + } } - return thisShape.IsSame( otherShape ); + return result; }