Back to index

salome-smesh  6.5.0
Functions | Variables
SMESH_Gen_i_1.cxx File Reference
#include "SMESH_Gen_i.hxx"
#include "SMESH_Mesh_i.hxx"
#include "SMESH_Hypothesis_i.hxx"
#include "SMESH_Algo_i.hxx"
#include "SMESH_Group_i.hxx"
#include "SMESH_subMesh_i.hxx"
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
#include <TCollection_AsciiString.hxx>

Go to the source code of this file.

Functions

template<typename T >
static T * objectToServant (CORBA::Object_ptr theIOR)
static SALOMEDS::SObject_ptr publish (SALOMEDS::Study_ptr theStudy, CORBA::Object_ptr theIOR, SALOMEDS::SObject_ptr theFatherObject, const int theTag=0, const char *thePixMap=0, const bool theSelectable=true)
static void addReference (SALOMEDS::Study_ptr theStudy, SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theToObject, int theTag=0)
static long findMaxChildTag (SALOMEDS::SObject_ptr theSObject)
 findMaxChildTag [ static internal ]

Variables

static int MYDEBUG = 0

Function Documentation

static void addReference ( SALOMEDS::Study_ptr  theStudy,
SALOMEDS::SObject_ptr  theSObject,
CORBA::Object_ptr  theToObject,
int  theTag = 0 
) [static]

Definition at line 331 of file SMESH_Gen_i_1.cxx.

{
  SALOMEDS::SObject_var aToObjSO = SMESH_Gen_i::ObjectToSObject( theStudy, theToObject );
  if ( !aToObjSO->_is_nil() && !theSObject->_is_nil() ) {
    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(), ++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;
    }
    if ( !theSObject->FindSubObject( theTag, aReferenceSO ))
      aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag );
    aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
  }
}
static long findMaxChildTag ( SALOMEDS::SObject_ptr  theSObject) [static]

findMaxChildTag [ static internal ]

Finds maximum child tag for the given object

Definition at line 466 of file SMESH_Gen_i_1.cxx.

{
  long aTag = 0;
  if ( !theSObject->_is_nil() ) {
    SALOMEDS::Study_var aStudy = theSObject->GetStudy();
    if ( !aStudy->_is_nil() ) {
      SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSObject );
      for ( ; anIter->More(); anIter->Next() ) {
        long nTag = anIter->Value()->Tag();
        if ( nTag > aTag )
          aTag = nTag;
      }
    }
  }
  return aTag;
}
template<typename T >
static T* objectToServant ( CORBA::Object_ptr  theIOR) [inline, static]

Definition at line 199 of file SMESH_Gen_i_1.cxx.

{
  return dynamic_cast<T*>( SMESH_Gen_i::GetServant( theIOR ).in() );
}
static SALOMEDS::SObject_ptr publish ( SALOMEDS::Study_ptr  theStudy,
CORBA::Object_ptr  theIOR,
SALOMEDS::SObject_ptr  theFatherObject,
const int  theTag = 0,
const char *  thePixMap = 0,
const bool  theSelectable = true 
) [static]

Definition at line 246 of file SMESH_Gen_i_1.cxx.

{
  SALOMEDS::SObject_var SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR );
  SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
  if ( SO->_is_nil() ) {
    if ( theTag == 0 )
      SO = aStudyBuilder->NewObject( theFatherObject );
    else if ( !theFatherObject->FindSubObject( theTag, SO ))
      SO = aStudyBuilder->NewObjectToTag( theFatherObject, theTag );
  }

  SALOMEDS::GenericAttribute_var anAttr;
  if ( !CORBA::is_nil( theIOR )) {
    anAttr = aStudyBuilder->FindOrCreateAttribute( SO, "AttributeIOR" );
    CORBA::String_var objStr = SMESH_Gen_i::GetORB()->object_to_string( theIOR );
    SALOMEDS::AttributeIOR::_narrow(anAttr)->SetValue( objStr.in() );
  }
  if ( thePixMap ) {
    anAttr  = aStudyBuilder->FindOrCreateAttribute( SO, "AttributePixMap" );
    SALOMEDS::AttributePixMap_var pm = SALOMEDS::AttributePixMap::_narrow( anAttr );
    pm->SetPixMap( thePixMap );
  }
  if ( !theSelectable ) {
    anAttr   = aStudyBuilder->FindOrCreateAttribute( SO, "AttributeSelectable" );
    SALOMEDS::AttributeSelectable::_narrow( anAttr )->SetSelectable( false );
  }
  return SO._retn();
}

Variable Documentation

int MYDEBUG = 0 [static]

Definition at line 46 of file SMESH_Gen_i_1.cxx.