// 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
bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
{
- if(MYDEBUG) MESSAGE("CanPublishInStudy");
+ if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(myCurrentStudy));
+ if(CORBA::is_nil(myCurrentStudy))
+ return false;
+
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(theIOR);
if( !aMesh->_is_nil() )
return true;
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 );
}
}