X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i_1.cxx;h=2021f22e2df7a4c43c62934b4ee3757577eb3a6e;hb=c63ee099ad2b149bd70136839c973e8910137bc5;hp=ac8641de2bd5858d9565ca42babe85209531ee41;hpb=1bc504bf901039d3cf41d8f1a65f1f955579cf34;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index ac8641de2..2021f22e2 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // File : SMESH_Gen_i_1.cxx @@ -146,7 +146,10 @@ long SMESH_Gen_i::GetVolumeGroupsTag() bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) { - if(MYDEBUG) MESSAGE("CanPublishInStudy"); + if(MYDEBUG) MESSAGE("CanPublishInStudy - "<_is_nil() ) return true; @@ -306,23 +309,30 @@ static void addReference (SALOMEDS::Study_ptr theStudy, SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); SALOMEDS::SObject_var aReferenceSO; if ( !theTag ) { + // check if the reference to theToObject already exists + // and find a free label for the reference object bool isReferred = false; + int tag = 1; SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator( theSObject ); - for ( ; !isReferred && anIter->More(); anIter->Next() ) { - if ( anIter->Value()->ReferencedObject( aReferenceSO ) && - strcmp( aReferenceSO->GetID(), aToObjSO->GetID() ) == 0 ) - isReferred = true; - } - if ( !isReferred ) { - aReferenceSO = aStudyBuilder->NewObject( theSObject ); - aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); + for ( ; !isReferred && anIter->More(); anIter->Next(), ++tag ) { + if ( anIter->Value()->ReferencedObject( aReferenceSO )) { + if ( strcmp( aReferenceSO->GetID(), aToObjSO->GetID() ) == 0 ) + isReferred = true; + } + else if ( !theTag ) { + SALOMEDS::GenericAttribute_var anAttr; + if ( !anIter->Value()->FindAttribute( anAttr, "AttributeIOR" )) + theTag = tag; + } } + if ( isReferred ) + return; + if ( !theTag ) + theTag = tag; } - else { - if ( !theSObject->FindSubObject( theTag, aReferenceSO )) - aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag ); - aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); - } + if ( !theSObject->FindSubObject( theTag, aReferenceSO )) + aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag ); + aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); } }