mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-14 10:40:34 +05:00
fix bug 11757. Use free labels when publishing a reference
This commit is contained in:
parent
7d8a3a8516
commit
b28dc98b3a
@ -309,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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user