From 08a495c90bddf890e2584ee920f9c3a043a7f25f Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 26 Jan 2005 06:47:57 +0000 Subject: [PATCH] PR: merge from tag mergefrom_HEAD_24Jan05 + corrections --- INSTALL | 5 +- Makefile.in | 1 + bin/VERSION | 2 +- bin/orbmodule.py | 8 +- bin/runSalome.py | 6 +- doc/salome/tui/Makefile.in | 1 + idl/Makefile.in | 1 + idl/SALOME_Component.idl | 10 +- resources/KERNELCatalog.xml | 2 +- salome_adm/unix/make_commence.in | 3 + salome_adm/unix/make_conclude.in | 2 +- src/Container/Component_i.cxx | 18 + src/Container/Container_i.cxx | 221 ++----- src/Container/Makefile.in | 18 +- src/Container/SALOME_Component_i.hxx | 2 + src/Container/SALOME_Container.cxx | 52 +- src/Container/SALOME_Container_i.hxx | 11 +- src/DataTypeCatalog/Makefile.in | 3 +- src/LifeCycleCORBA/LifeCycleCORBA.py | 192 +++--- src/LifeCycleCORBA/Makefile.in | 9 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 393 ++++-------- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 33 +- src/Loader/Makefile.in | 3 +- src/Logger/SALOME_Logger_Server.cxx | 2 +- src/MEDWrapper/Base/MED_Algorithm.cxx | 95 +-- src/MEDWrapper/Base/MED_Algorithm.hxx | 8 +- src/MEDWrapper/Base/MED_Common.hxx | 29 +- src/MEDWrapper/Base/MED_Structures.cxx | 13 - src/MEDWrapper/Base/MED_Structures.hxx | 123 ++-- src/MEDWrapper/Base/MED_TStructures.hxx | 201 +++++- src/MEDWrapper/Base/MED_TWrapper.hxx | 339 +++++++--- src/MEDWrapper/Base/MED_Utilities.cxx | 2 + src/MEDWrapper/Base/MED_Utilities.hxx | 2 +- src/MEDWrapper/Base/MED_Wrapper.cxx | 147 ++++- src/MEDWrapper/Base/MED_Wrapper.hxx | 593 ++++++++++++------ src/MEDWrapper/Base/Makefile.in | 4 +- src/MEDWrapper/Factory/MED_Factory.hxx | 2 - src/MEDWrapper/Factory/MED_Test.cxx | 88 ++- src/MEDWrapper/Factory/Makefile.in | 4 +- src/MEDWrapper/V2_1/MED_V2_1_Wrapper.cxx | 39 +- src/MEDWrapper/V2_1/MED_V2_1_Wrapper.hxx | 17 +- src/MEDWrapper/V2_1/Makefile.in | 2 + src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx | 320 +++++++++- src/MEDWrapper/V2_2/MED_V2_2_Wrapper.hxx | 288 ++++++--- src/MPIContainer/MPIContainer_i.cxx | 2 +- src/MSG2QM/Makefile.in | 1 + src/Makefile.in | 4 +- src/ModuleCatalog/Makefile.in | 3 +- .../SALOME_ModuleCatalog_Server.cxx | 2 +- .../NamingService_WaitForServerReadiness.cxx | 6 +- src/NamingService/SALOME_NamingService.cxx | 73 ++- src/NamingService/SALOME_NamingService.hxx | 8 + src/OCCViewer/Makefile.in | 1 + src/Plot2d/Makefile.in | 1 + src/Registry/Makefile.in | 4 +- src/RessourcesCatalog/Makefile.in | 3 +- src/SALOMEDS/Makefile.in | 6 +- src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx | 5 +- src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx | 14 +- src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx | 3 +- src/SALOMEDS/SALOMEDS_IORAttribute.cxx | 8 +- src/SALOMEDS/SALOMEDS_IORAttribute.hxx | 6 +- src/SALOMEDS/SALOMEDS_SObject_i.cxx | 117 ++-- src/SALOMEDS/SALOMEDS_SObject_i.hxx | 19 +- src/SALOMEDS/SALOMEDS_Server.cxx | 2 +- src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx | 151 ++--- src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx | 3 + src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 501 +++++++-------- src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 10 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 99 +-- src/SALOMEDS/SALOMEDS_Study_i.hxx | 14 +- src/SALOMEGUI/CLIENT_msg_en.po | 6 +- src/SALOMEGUI/Makefile.in | 1 + src/SALOMEGUI/PyInterp_base.cxx | 10 + src/SALOMELocalTrace/Makefile.in | 4 +- src/SALOME_PY/Makefile.in | 1 + src/SALOME_PYQT/Makefile.in | 2 +- src/SALOME_SWIG_WITHOUTIHM/salome.py | 13 +- src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py | 14 +- src/SALOME_SWIG_WITHOUTIHM/salome_kernel.py | 28 +- src/SALOME_SWIG_WITHOUTIHM/salome_study.py | 43 +- src/SUPERVGraph/Makefile.in | 1 + src/Session/Makefile.in | 6 +- src/Session/Session_ServerLauncher.cxx | 13 +- src/Session/Session_ServerThread.cxx | 51 +- src/Session/Session_ServerThread.hxx | 2 + src/TOOLSGUI/Makefile.in | 2 +- src/TestContainer/Makefile.in | 3 +- src/VTKViewer/Makefile.in | 3 +- 89 files changed, 2834 insertions(+), 1749 deletions(-) diff --git a/INSTALL b/INSTALL index a8d9d6266..f3e4b6917 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,8 @@ -This is the version 2.1.0 of KERNEL +This is the version 2.2.0 of KERNEL Previous versions : - - 2.0.0 + - 2.1.0 + - 2.0.0 - 1.4.1 - 1.3.0 - 1.2.1 diff --git a/Makefile.in b/Makefile.in index 426130bbd..ab8870626 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,6 +21,7 @@ back.xpm \ cascade.png \ CatalogDataType.xml \ KERNELCatalog.xml \ +CatalogResources.xml \ CatalogRessources.xml \ close.png \ config \ diff --git a/bin/VERSION b/bin/VERSION index f15697e35..9f5dca975 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - KERNEL VERSION: 2.1.0 +THIS IS SALOME - KERNEL VERSION: 2.2.0 diff --git a/bin/orbmodule.py b/bin/orbmodule.py index a96bc9847..a7cc2a2eb 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -118,9 +118,9 @@ class client: # -------------------------------------------------------------------------- - def waitNS(self,name,typobj=None,maxcount=70): + def waitNS(self,name,typobj=None,maxcount=40): count=0 - delta=0.3 + delta=0.5 print "Searching %s in Naming Service " % name, while(1): count += 1 @@ -161,9 +161,9 @@ class client: # -------------------------------------------------------------------------- - def waitLogger(self,name,typobj=None,maxcount=10): + def waitLogger(self,name,typobj=None,maxcount=40): count=0 - delta=0.3 + delta=0.5 print "Searching %s in Naming Service " % name, while(1): count += 1 diff --git a/bin/runSalome.py b/bin/runSalome.py index 1bc604970..8f9562703 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -252,7 +252,6 @@ class Server: pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD -# --- class InterpServer(Server): def __init__(self,args): @@ -465,6 +464,8 @@ def startSalome(args, modules_list, modules_root_dir): # Notify Server launch # + print "Notify Server to launch" + myServer=NotifyServer(args,modules_root_dir) myServer.run() @@ -482,6 +483,7 @@ def startSalome(args, modules_list, modules_root_dir): # Lancement Catalog Server, # attente de la disponibilité du Catalog Server dans le Naming Service # + if 'moduleCatalog' not in args['embedded']: cataServer=CatalogServer(args) @@ -543,7 +545,7 @@ def startSalome(args, modules_list, modules_root_dir): os.environ["HOSTNAME"]=os.getenv("HOST") theComputer = getShortHostName() - + # # Lancement Container C++ local, # attente de la disponibilité du Container C++ local dans le Naming Service diff --git a/doc/salome/tui/Makefile.in b/doc/salome/tui/Makefile.in index 3f4811e43..eeaff820d 100644 --- a/doc/salome/tui/Makefile.in +++ b/doc/salome/tui/Makefile.in @@ -23,6 +23,7 @@ docs: mv -f doxyfile1 doxyfile; \ $(doxygen) ./doxyfile; \ cd ..; \ + mkdir KERNEL; \ cp -fr $(srcdir)/KERNEL/sources/static/*.* ./KERNEL/ cp -fr $(srcdir)/KERNEL/sources/ KERNEL/ cp -fr $(srcdir)/KERNEL/HTML/ KERNEL/ diff --git a/idl/Makefile.in b/idl/Makefile.in index 6e46e61bd..40542236a 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -20,6 +20,7 @@ IDL_FILES = \ SALOMEDS_Attributes.idl \ SALOME_Session.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_TestComponent.idl \ SALOME_Registry.idl \ SALOME_MPIObject.idl \ diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index ecad1fa41..8760ae9df 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -52,12 +52,6 @@ module Engines */ interface Container { -/*! - Initializes the %container with a definite name. - \param ContainerName Name of the container - \return an initialized container -*/ - Container start_impl( in string ContainerName ) ; /*! Loads into the container a new component, registers it and starts it's CORBA servant. @@ -94,6 +88,10 @@ module Engines Returns True if the %container has been killed */ boolean Kill_impl() ; +/*! + Shutdown the Container process. +*/ + oneway void Shutdown(); /*! Returns the hostname of the container */ diff --git a/resources/KERNELCatalog.xml b/resources/KERNELCatalog.xml index c0d046504..1208eb26f 100644 --- a/resources/KERNELCatalog.xml +++ b/resources/KERNELCatalog.xml @@ -16,7 +16,7 @@ Salome Other NRI - 2.1.0 + 2.2.0 GUI Neutral Context 1 diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index 77747e2b8..7e5122adb 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -11,10 +11,13 @@ HAVE_SSTREAM=@HAVE_SSTREAM@ LIBS=@LIBS@ +LIBSFORBIN=@LIBS@ # LDFLAGS=@LDFLAGS@ -L$(top_builddir)/lib/salome -Xlinker -rpath-link -Xlinker -L$(top_builddir)/lib/salome LDFLAGS=@LDFLAGS@ -L$(top_builddir)/lib/salome +LDFLAGSFORBIN=@LDFLAGS@ -L$(top_builddir)/lib/salome # add libstdc++ to link c++ library with libtool ! LDFLAGS+= @STDLIB@ +LDFLAGSFORBIN+= @STDLIB@ #CP=@CP@ diff --git a/salome_adm/unix/make_conclude.in b/salome_adm/unix/make_conclude.in index 9c35798ec..2b8f95495 100644 --- a/salome_adm/unix/make_conclude.in +++ b/salome_adm/unix/make_conclude.in @@ -95,7 +95,7 @@ $(BIN:%=$(top_builddir)/bin/salome/%) $(TEST_PROGS:%=$(top_builddir)/bin/salome/ ln -sf $(CURDIR)/$< $@ $(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGS) $(LIBS) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGSFORBIN) $(LIBSFORBIN) # copy python scripts in $(top_builddir)/bin/salome # diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 880bb0438..ff343a2cc 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SALOME_Component_i.hxx" +#include "SALOME_Container_i.hxx" #include "RegistryConnexion.hxx" #include "OpUtil.hxx" #include @@ -397,3 +398,20 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() { void Engines_Component_i::sendMessage(const char *event_type, const char *message) { _notifSupplier->Send(graphName(), nodeName(), event_type, message); } + +string Engines_Component_i::GetDynLibraryName(const char *componentName) +{ + string ret="lib"; + ret+=componentName; + ret+="Engine.so"; + return ret; +} + +string Engines_Component_i::BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname) +{ + string ret=Engines_Container_i::BuildContainerNameForNS(ContainerName,hostname); + ret+="/"; + ret+=ComponentName; + return ret; +} + diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index e36089f5e..301b56719 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -30,8 +30,9 @@ #include CORBA_SERVER_HEADER(SALOME_Component) #include "SALOME_Container_i.hxx" #include "SALOME_NamingService.hxx" -#include "Utils_SINGLETON.hxx" +//#include "Utils_SINGLETON.hxx" #include "OpUtil.hxx" +#include #include #include #include @@ -52,6 +53,8 @@ char ** _ArgV ; extern "C" {void ActSigIntHandler() ; } extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } +const char *Engines_Container_i::_defaultContainerName="FactoryServer"; + Engines_Container_i::Engines_Container_i () : _numInstance(0) { @@ -61,13 +64,12 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, char *containerName , int argc , char* argv[], - bool regist, - bool activ ) : + bool activAndRegist ) : _numInstance(0) { _pid = (long)getpid(); - if(regist) + if(activAndRegist) ActSigIntHandler() ; _ArgC = argc ; @@ -98,35 +100,20 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, SCRUTE(hostname); - _containerName = "/Containers/"; - if (strlen(containerName)== 0) - { - _containerName += hostname; - } - else - { - _containerName += hostname; - _containerName += "/" ; - _containerName += containerName; - } + _containerName = BuildContainerNameForNS(containerName,hostname.c_str()); _orb = CORBA::ORB::_duplicate(orb) ; _poa = PortableServer::POA::_duplicate(poa) ; - // Pour les containers paralleles: il ne faut pas activer le container generique, mais le container specialise - if(activ){ - MESSAGE("activate object"); - _id = _poa->activate_object(this); - } - - // Pour les containers paralleles: il ne faut pas enregistrer le container generique, mais le container specialise - if(regist){ - // _NS = new SALOME_NamingService(_orb); - _NS = SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - _NS->init_orb( orb ) ; - Engines::Container_ptr pCont - = Engines::Container::_narrow(_this()); + // Pour les containers paralleles: il ne faut pas enregistrer et activer le container generique, mais le container specialise + if(activAndRegist){ + _id = _poa->activate_object(this); + _NS = new SALOME_NamingService();//SINGLETON_::Instance() ; + //ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ; + CORBA::Object_var obj=_poa->id_to_reference(*_id); + Engines::Container_var pCont + = Engines::Container::_narrow(obj); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -135,6 +122,7 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, Engines_Container_i::~Engines_Container_i() { MESSAGE("Container_i::~Container_i()"); + delete _id; } char* Engines_Container_i::name() @@ -154,6 +142,16 @@ void Engines_Container_i::ping() MESSAGE("Engines_Container_i::ping() pid "<< getpid()); } +// shutdown corba server +void Engines_Container_i::Shutdown() +{ + MESSAGE("Engines_Container_i::Shutdown()"); + _NS->Destroy_Name(_containerName.c_str()); + //_remove_ref(); + //_poa->deactivate_object(*_id); + _orb->shutdown(0); +} + //! Kill current container bool Engines_Container_i::Kill_impl() { MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " @@ -162,147 +160,6 @@ bool Engines_Container_i::Kill_impl() { exit( 0 ) ; } -//! Launch a new container from the current container -Engines::Container_ptr Engines_Container_i::start_impl( - const char* ContainerName ) { - MESSAGE("start_impl argc " << _argc << " ContainerName " << ContainerName - << hex << this << dec) ; - _numInstanceMutex.lock() ; // lock on the instance number - - CORBA::Object_var obj = Engines::Container::_nil() ; - bool nilvar = true ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - INFOS(machineName() << " start_impl unknown container " << cont.c_str() - << " try to Resolve" ); - obj = _NS->Resolve( cont.c_str() ); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS(machineName() << " start_impl unknown container " - << ContainerName); - } - } - catch (ServiceUnreachable&) { - INFOS(machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS(machineName() << "Caught unknown exception."); - } - if ( !nilvar ) { - _numInstanceMutex.unlock() ; - MESSAGE("start_impl container found without new launch") ; - return Engines::Container::_narrow(obj); - } - int i = 0 ; - while ( _argv[ i ] ) { - MESSAGE(" argv" << i << " " << _argv[ i ]) ; - i++ ; - } - string shstr = string(getenv("KERNEL_ROOT_DIR")) + "/bin/salome/SALOME_Container "; -// string shstr( "./runSession SALOME_Container " ) ; - shstr += ContainerName ; - if ( _argc == 4 ) { - shstr += " " ; - shstr += _argv[ 2 ] ; - shstr += " " ; - shstr += _argv[ 3 ] ; - } - - // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. - // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py. - string tempfilename = "/tmp/logs/"; - tempfilename += getenv( "USER" ) ; - tempfilename += "/" ; - tempfilename += ContainerName ; - tempfilename += ".log" ; - FILE* f = fopen ( tempfilename.c_str(), "a" ); - if ( f ) { // check if file can be opened for writing - fclose( f ); - shstr += " > " ; - shstr += tempfilename; - shstr += " 2>&1 &" ; - } - else { // if file can't be opened - use a guaranteed temp file name - char* tmpFileName = tempnam( NULL, ContainerName ); - shstr += " > "; - shstr += tmpFileName; - shstr += " 2>&1 &"; - free( tmpFileName ); - } - - MESSAGE("system(" << shstr << ")") ; - int status = system( shstr.c_str() ) ; - if (status == -1) { - INFOS("Engines_Container_i::start_impl SALOME_Container failed (system command status -1)") ; - } - else if (status == 217) { - INFOS("Engines_Container_i::start_impl SALOME_Container failed (system command status 217)") ; - } - INFOS(machineName() << " Engines_Container_i::start_impl SALOME_Container launch done"); - -// pid_t pid = fork() ; -// if ( pid == 0 ) { -// string anExe( _argv[ 0 ] ) ; -// anExe += "runSession" ; -// char * args[ 6 ] ; -// args[ 0 ] = "runSession" ; -// args[ 1 ] = "SALOME_Container" ; -// args[ 2 ] = strdup( ContainerName ) ; -// args[ 3 ] = strdup( _argv[ 2 ] ) ; -// args[ 4 ] = strdup( _argv[ 3 ] ) ; -// args[ 5 ] = NULL ; -// MESSAGE("execl(" << anExe.c_str() << " , " << args[ 0 ] << " , " -// << args[ 1 ] << " , " << args[ 2 ] << " , " << args[ 3 ] -// << " , " << args[ 4 ] << ")") ; -// int status = execv( anExe.c_str() , args ) ; -// if (status == -1) { -// INFOS("Engines_Container_i::start_impl execl failed (system command status -1)") ; -// perror( "Engines_Container_i::start_impl execl error ") ; -// } -// else { -// INFOS(machineName() << " Engines_Container_i::start_impl execl done"); -// } -// exit(0) ; -// } - - obj = Engines::Container::_nil() ; - try { - string cont("/Containers/"); - cont += machineName() ; - cont += "/" ; - cont += ContainerName; - nilvar = true ; - int count = 20 ; - while ( nilvar && count >= 0) { - sleep( 1 ) ; - obj = _NS->Resolve(cont.c_str()); - nilvar = CORBA::is_nil( obj ) ; - if ( nilvar ) { - INFOS(count << ". " << machineName() - << " start_impl unknown container " << cont.c_str()); - count -= 1 ; - } - } - _numInstanceMutex.unlock() ; - if ( !nilvar ) { - MESSAGE("start_impl container found after new launch of SALOME_Container") ; - } - return Engines::Container::_narrow(obj); - } - catch (ServiceUnreachable&) { - INFOS(machineName() << "Caught exception: Naming Service Unreachable"); - } - catch (...) { - INFOS(machineName() << "Caught unknown exception."); - } - _numInstanceMutex.unlock() ; - MESSAGE("start_impl container not found after new launch of SALOME_Container") ; - return Engines::Container::_nil() ; -} - Engines::Component_ptr Engines_Container_i::load_impl( const char* nameToRegister, const char* componentName ) { @@ -477,3 +334,27 @@ long Engines_Container_i::getPID() { char* Engines_Container_i::getHostName() { return((char*)(GetHostname().c_str())); } + +// Retrieves only with container naming convention if it is a python container +bool Engines_Container_i::isPythonContainer(const char* ContainerName) +{ + bool ret=false; + int len=strlen(ContainerName); + if(len>=2) + if(strcmp(ContainerName+len-2,"Py")==0) + ret=true; + return ret; +} + +string Engines_Container_i::BuildContainerNameForNS(const char *ContainerName, const char *hostname) +{ + string ret="/Containers/"; + ret += hostname; + ret+="/"; + if (strlen(ContainerName)== 0) + ret+=_defaultContainerName; + else + ret += ContainerName; + return ret; +} + diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in index 5cd3980a5..1ed861ed0 100644 --- a/src/Container/Makefile.in +++ b/src/Container/Makefile.in @@ -38,24 +38,28 @@ EXPORT_PYSCRIPTS = SALOME_ComponentPy.py SALOME_ContainerPy.py EXPORT_HEADERS = \ SALOME_Component_i.hxx \ - SALOME_Container_i.hxx + SALOME_Container_i.hxx \ + SALOME_ContainerManager.hxx # Libraries targets LIB = libSalomeContainer.la -LIB_SRC = Component_i.cxx Container_i.cxx -LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl +LIB_SRC = Component_i.cxx Container_i.cxx SALOME_ContainerManager.cxx +LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl SALOME_ContainerManager.idl +LIB_CLIENT_IDL = # Executables targets BIN = SALOME_Container BIN_SRC = SALOME_Container_SignalsHandler.cxx -BIN_SERVER_IDL = SALOME_Component.idl +BIN_SERVER_IDL = SALOME_Component.idl SALOME_ContainerManager.idl -CPPFLAGS+= $(PYTHON_INCLUDES) $(MPI_INCLUDE) $(OCC_INCLUDES) +CPPFLAGS+= $(PYTHON_INCLUDES) $(MPI_INCLUDE) $(OCC_INCLUDES) $(QT_MT_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -lSALOMETraceCollector -lSalomeResourcesManager -LIBS += @LDEXPDYNFLAGS@ $(PYTHON_LIBS) $(MPI_LIBS) -lCASCatch +LIBS += @LDEXPDYNFLAGS@ $(PYTHON_LIBS) $(MPI_LIBS) +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector +LIBSFORBIN= $(LIBS) @CONCLUDE@ diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 2911434da..620ca1499 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -92,6 +92,8 @@ public: long CpuUsed() ; CORBA::Long CpuUsed_impl() ; + static std::string GetDynLibraryName(const char *componentName); + static std::string BuildComponentNameForNS(const char *ComponentName, const char *ContainerName, const char *hostname); protected: std::string _instanceName ; std::string _interfaceName ; diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 646480535..dfd501e9f 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -30,8 +30,9 @@ #include #include -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +//#include "Utils_ORB_INIT.hxx" +//#include "Utils_SINGLETON.hxx" +#include #include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" #include "utilities.h" @@ -59,8 +60,8 @@ int main(int argc, char* argv[]) MPI_Init(&argc,&argv); #endif // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &orb = init( argc , argv ) ; + //ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; BEGIN_OF(argv[0]); @@ -73,7 +74,7 @@ int main(int argc, char* argv[]) // Obtain a reference to the root POA. // obtain the root poa manager // - long TIMESleep = 250000000; + long TIMESleep = 500000000; int NumberOfTries = 40; int a; timespec ts_req; @@ -87,7 +88,7 @@ int main(int argc, char* argv[]) CORBA::Object_var theObj; CORBA::Object_var obj; CORBA::Object_var object; - SALOME_NamingService &naming = *SINGLETON_::Instance() ; + //SALOME_NamingService &naming = *SINGLETON_::Instance() ; int CONTAINER=0; const char * Env = getenv("USE_LOGGER"); int EnvL =0; @@ -139,47 +140,14 @@ int main(int argc, char* argv[]) break; } - // define policy objects - PortableServer::ImplicitActivationPolicy_var implicitActivation = - root_poa->create_implicit_activation_policy(PortableServer::NO_IMPLICIT_ACTIVATION) ; - - // default = NO_IMPLICIT_ACTIVATION - PortableServer::ThreadPolicy_var threadPolicy = - root_poa->create_thread_policy(PortableServer::ORB_CTRL_MODEL); - // default = ORB_CTRL_MODEL, other choice SINGLE_THREAD_MODEL - - // create policy list - CORBA::PolicyList policyList; - policyList.length(2); - policyList[0] = PortableServer::ImplicitActivationPolicy::_duplicate(implicitActivation) ; - policyList[1] = PortableServer::ThreadPolicy::_duplicate(threadPolicy) ; - - // create the child POA - PortableServer::POAManager_var nil_mgr = PortableServer::POAManager::_nil() ; - PortableServer::POA_var factory_poa = - root_poa->create_POA("factory_poa", pman, policyList) ; - //with nil_mgr instead of pman, a new POA manager is created with the new POA - - // destroy policy objects - implicitActivation->destroy() ; - threadPolicy->destroy() ; - char *containerName = ""; if(argc > 1){ containerName = argv[1] ; } Engines_Container_i * myContainer - = new Engines_Container_i(orb, factory_poa, containerName , argc , argv ); - - // Engines_Container_i * myContainer - // = new Engines_Container_i(string(argv[1]),string(argv[2]), orb, factory_poa); - - // use naming service - // myContainer->_NS.init_orb(orb); - // Engines::Container_ptr pCont = Engines::Container::_narrow(myContainer->_this()); - // myContainer->_NS.Register(pCont, argv[2]); - + = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + pman->activate(); #ifdef CHECKTIME @@ -191,8 +159,6 @@ int main(int argc, char* argv[]) #endif HandleServerSideSignals(orb); - - orb->destroy(); }catch(CORBA::SystemException&){ INFOS("Caught CORBA::SystemException."); }catch(PortableServer::POA::WrongPolicy&){ diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 6f309c50c..249f80657 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -52,14 +52,10 @@ public: PortableServer::POA_ptr poa, char * containerName , int argc, char* argv[], - bool regist = true, - bool activ = true); + bool activAndRegist = true); virtual ~Engines_Container_i(); - //! Launch a new container from the current container - Engines::Container_ptr start_impl(const char* ContainerName); - //! Load component in current container Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); @@ -71,13 +67,16 @@ public: char* name(); char* machineName(); void ping(); - + void Shutdown(); //! Kill current container bool Kill_impl() ; char* getHostName(); CORBA::Long getPID(); + static bool isPythonContainer(const char* ContainerName); + static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); + static const char *_defaultContainerName; protected: SALOME_NamingService *_NS ; diff --git a/src/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in index f5bd3bc35..7ba1a085f 100644 --- a/src/DataTypeCatalog/Makefile.in +++ b/src/DataTypeCatalog/Makefile.in @@ -54,6 +54,7 @@ BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/LifeCycleCORBA/LifeCycleCORBA.py b/src/LifeCycleCORBA/LifeCycleCORBA.py index 273916dd4..82c364936 100644 --- a/src/LifeCycleCORBA/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA/LifeCycleCORBA.py @@ -78,6 +78,15 @@ class LifeCycleCORBA: if self._catalog is None: MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" ) + name = [CosNaming.NameComponent("ContainerManager","object")] + try: + obj = self._rootContext.resolve(name) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE( "ContainerManager.object not found in Naming Service" ) + self._contManager = obj._narrow(Engines.ContainerManager) + if self._contManager is None: + MESSAGE( "ContainerManager.object exists but is not a ContainerManager") + #------------------------------------------------------------------------- def ContainerName(self, containerName): @@ -130,120 +139,81 @@ class LifeCycleCORBA: #------------------------------------------------------------------------- - def FindOrStartContainer(self, theComputer , theContainer ): - MESSAGE( "FindOrStartContainer" + theComputer + theContainer ) - aContainer = self.FindContainer( theComputer + "/" + theContainer ) - if aContainer is None : - if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") : - myMachine=getShortHostName() - if theComputer == myMachine : - rshstr = "" - else : - rshstr = "rsh -n " + theComputer + " " - path = self.ComputerPath( theComputer ) -## if path != "" : -## rshstr = rshstr + path + "/../bin/" -## else : -## rshstr = rshstr + os.getenv( "KERNEL_ROOT_DIR" ) + "/bin/" - if theContainer == "FactoryServer" : - rshstr = rshstr + path + "SALOME_Container " - else : - rshstr = rshstr + path + "SALOME_ContainerPy.py '" - rshstr = rshstr + theContainer + " -" - omniORBcfg = os.getenv( "OMNIORB_CONFIG" ) - file = os.open( omniORBcfg , os.O_RDONLY ) - ORBInitRef = os.read(file,132) - if ORBInitRef[len(ORBInitRef)-1] == '\n' : - ORBInitRef,bsn = ORBInitRef.split('\n') - os.close( file ) - rshstr = rshstr + ORBInitRef - if theContainer == "FactoryServerPy" : - rshstr = rshstr + "'" - rshstr = rshstr + " > /tmp/" + theContainer + "_" - rshstr = rshstr + theComputer - rshstr = rshstr + ".log 2>&1 &" - os.system( rshstr ) - MESSAGE( "FindOrStartContainer" + rshstr + " done" ) - else : - if theContainer.find('Py') == -1 : - aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" ) - else : - aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" ) - aContainer = aContainer.start_impl( theContainer ) - - count = 21 - while aContainer is None : - time.sleep(1) - count = count - 1 - MESSAGE( str(count) + ". Waiting for " + theComputer + "/" + theContainer ) - aContainer = self.FindContainer( theComputer + "/" + theContainer ) - if count == 0 : - return aContainer - - return aContainer - #os.system("rsh -n dm2s0017 /export/home/KERNEL_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") + def FindComponent(self,containerName,componentName,listOfMachines): + if containerName!="": + machinesOK=[] + for i in range(len(listOfMachines)): + currentMachine=listOfMachines[i] + componentNameForNS= [CosNaming.NameComponent(currentMachine,"dir"), + CosNaming.NameComponent(containerName,"dir"), + CosNaming.NameComponent(componentName,"object")] + obj=None + try: + obj = self._containerRootContext.resolve(componentNameForNS) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE( "component " + componentName + " not found on machine " + currentMachine + " , trying to load" ) + pass + if obj is not None: + machinesOK.append(currentMachine) + pass + pass + if len(machinesOK)!=0: + bestMachine=self._contManager.FindBest(machinesOK) + componentNameForNS= [CosNaming.NameComponent(bestMachine,"dir"), + CosNaming.NameComponent(containerName,"dir"), + CosNaming.NameComponent(componentName,"object")] + obj=None + try: + obj = self._containerRootContext.resolve(componentNameForNS) + except: + pass + if obj is not None: + return obj._narrow(Engines.Component) + else: + MESSAGE( "Big problem !!!") + return None + else: + return None + else: + bestMachine=self._contManager.FindBest(listOfMachines) + MESSAGE("Not implemented yet ...") + return None + pass #------------------------------------------------------------------------- - def FindOrLoadComponent(self, containerName, componentName): - - theComputer,theContainer = self.ContainerName( containerName ) - name = [CosNaming.NameComponent(theComputer,"dir"), - CosNaming.NameComponent(theContainer,"dir"), - CosNaming.NameComponent(componentName,"object")] + def LoadComponent(self,containerName,componentName,listOfMachine): + container=self._contManager.FindOrStartContainer(containerName,listOfMachine) + implementation="lib"+componentName+"Engine.so" try: - obj = self._containerRootContext.resolve(name) - except CosNaming.NamingContext.NotFound, ex: - MESSAGE( "component " + componentName + " not found, trying to load" ) - container = self.FindContainer(theComputer + "/" + theContainer) - if container is None: - MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" ) - if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") : - if theContainer.find('Py') == -1 : - theFactorycontainer = "FactoryServer" - else : - theFactorycontainer = "FactoryServerPy" - Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer) - if Factorycontainer is None: - MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" ) - Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer) - else: - Factorycontainer = self.FindOrStartContainer(theComputer,theContainer) - if Factorycontainer != None : - container = self.FindOrStartContainer(theComputer,theContainer) - - if container != None: - compoinfo = self._catalog.GetComponent(componentName) - if compoinfo is None: - MESSAGE( "component " + componentName + " not found in Module Catalog" ) - else: - try: - machineName = theComputer - path = compoinfo.GetPathPrefix(machineName) + "/" - except SALOME_ModuleCatalog.NotFound, ex: - MESSAGE( "machine " + machineName + " not found in Module Catalog" ) - MESSAGE( "trying localhost" ) - try: - path = compoinfo.GetPathPrefix("localhost") + "/" - except SALOME_ModuleCatalog.NotFound, ex: - path = "" - implementation = path + "lib" + componentName + "Engine.so" - MESSAGE( "Trying to load " + implementation ) - try: - component = container.load_impl(componentName, implementation) - MESSAGE( "component " + component._get_instanceName() + " launched !" ) - return component - except: - MESSAGE( "component " + componentName + " NOT launched !" ) + component = container.load_impl(componentName, implementation) + MESSAGE( "component " + component._get_instanceName() + " launched !" ) + return component + except: + MESSAGE( "component " + componentName + " NOT launched !" ) + return None + #------------------------------------------------------------------------- + + + def FindOrLoadComponent(self, containerName, componentName): + sp=containerName.split("/") + if len(sp)==1: + listOfMachine=[] + listOfMachine.append(getShortHostName()) + comp=self.FindComponent(containerName,componentName,listOfMachine) + if comp is None: + return self.LoadComponent(containerName,componentName,listOfMachine) + else: + return comp + pass else: - try: - component = obj._narrow(Engines.Component) - if component is None: - MESSAGE( componentName + " is not a component !" ) - else: - MESSAGE( "component " + component._get_instanceName() + " found !" ) - return component - except: - MESSAGE( componentName + " failure" ) - return None + params= Engines.MachineParameters(sp[1],sp[0],"LINUX",0,0,0,0) + listOfMachine=self._contManager.GetFittingResources(params,componentName) + ret=self.FindComponent(sp[1],componentName,listOfMachine); + if ret is None: + return self.LoadComponent(sp[1],componentName,listOfMachine) + else: + return ret + pass + diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 33ee1ac81..64daf70e8 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -43,15 +43,18 @@ EXPORT_PYSCRIPTS = LifeCycleCORBA.py LIB = libSalomeLifeCycleCORBA.la LIB_SRC = SALOME_LifeCycleCORBA.cxx LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ - SALOME_ModuleCatalog.idl + SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl # Executables targets BIN = TestLifeCycleCORBA BIN_SRC = BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ - SALOME_ModuleCatalog.idl + SALOME_ModuleCatalog.idl SALOME_ContainerManager.idl -LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace +CPPFLAGS += $(QT_MT_INCLUDES) + +LDFLAGS += -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSalomeContainer -lSalomeResourcesManager +LDFLAGSFORBIN= $(LDFLAGS) -lRegistry -lSalomeNotification -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 7908d60ae..4b110ce6b 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -38,19 +38,18 @@ #include "SALOME_LifeCycleCORBA.hxx" #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +#include "SALOME_ContainerManager.hxx" +#include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" using namespace std; -SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA() -{ - _NS = NULL; - _FactoryServer = NULL ; -} - SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) { _NS = ns; - _FactoryServer = NULL ; + //add try catch + CORBA::Object_var obj=_NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS); + ASSERT( !CORBA::is_nil(obj)); + _ContManager=Engines::ContainerManager::_narrow(obj); } SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() @@ -86,9 +85,38 @@ string SALOME_LifeCycleCORBA::ContainerName( theComputerContainer += "/" ; theComputerContainer += *theContainer ; } + delete [] ContainerName; return theComputerContainer ; } +bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) +{ + + try + { + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + SALOME_ModuleCatalog::Acomponent_ptr compoInfo = + Catalog->GetComponent(componentName); + if (CORBA::is_nil (compoInfo)) + { + INFOS("Catalog Error : Component not found in the catalog"); + return false; + } + else return true; + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) + { + INFOS("Caught unknown exception."); + } + return false; +} + string SALOME_LifeCycleCORBA::ComputerPath( const char * theComputer ) { CORBA::String_var path; @@ -106,7 +134,8 @@ string SALOME_LifeCycleCORBA::ComputerPath( return CORBA::string_dup( path ) ; } -Engines::Container_var SALOME_LifeCycleCORBA::FindContainer(const char *containerName ) { +Engines::Container_ptr SALOME_LifeCycleCORBA::FindContainer(const char *containerName) +{ ASSERT(_NS != NULL); string cont ; if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... @@ -135,287 +164,105 @@ Engines::Container_var SALOME_LifeCycleCORBA::FindContainer(const char *containe return Engines::Container::_nil(); } -Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( - const string aComputerContainer , - const string theComputer , - const string theContainer ) { - Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; - Engines::Container_var aFactoryServer ; - SCRUTE( aComputerContainer ) ; - SCRUTE( theComputer ) ; - SCRUTE( theContainer ) ; - bool pyCont = false ; - int len = theContainer.length() ; - if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { - pyCont = true ; - } - if ( !CORBA::is_nil( aContainer ) ) { - return aContainer ; - } - else { - string FactoryServer = theComputer ; - if ( pyCont ) { - FactoryServer += "/FactoryServerPy" ; - } - else { - FactoryServer += "/FactoryServer" ; - } - aFactoryServer = FindContainer( FactoryServer.c_str() ) ; - if ( CORBA::is_nil( aFactoryServer ) ) { -// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & - string rsh( "" ) ; - if ( theComputer!= GetHostname() ) { - rsh += "rsh -n " ; - rsh += theComputer ; - rsh += " " ; - } - string path = ComputerPath( theComputer.c_str() ) ; - SCRUTE( path ) ; - if ( path[0] != '\0' ) { - rsh += path ; - rsh += "/../bin/" ; - } - rsh += "runSession " ; - if ( pyCont ) { - rsh += "SALOME_ContainerPy.py " ; - rsh += "FactoryServerPy -" ; - } - else { - rsh += "SALOME_Container " ; - rsh += "FactoryServer -" ; - } - string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ; - ifstream omniORBfile( omniORBcfg.c_str() ) ; - char ORBInitRef[12] ; - char nameservice[132] ; - omniORBfile >> ORBInitRef ; - rsh += ORBInitRef ; - rsh += " " ; - omniORBfile >> nameservice ; - omniORBfile.close() ; - char * bsn = strchr( nameservice , '\n' ) ; - if ( bsn ) { - bsn[ 0 ] = '\0' ; - } - rsh += nameservice ; - if ( pyCont ) { - rsh += " > /tmp/FactoryServerPy_" ; - } - else { - rsh += " > /tmp/FactoryServer_" ; - } - rsh += theComputer ; - rsh += ".log 2>&1 &" ; - SCRUTE( rsh ); - int status = system( rsh.c_str() ) ; - if (status == -1) { - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; - } - else if (status == 217) { - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; - } - else { - int count = 21 ; - while ( CORBA::is_nil( aFactoryServer ) && count ) { - sleep( 1 ) ; - count-- ; - if ( count != 10 ) - MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) - aFactoryServer = FindContainer( FactoryServer.c_str() ) ; - } - if ( CORBA::is_nil( aFactoryServer ) ) { - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; - } - else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { - _FactoryServer = aFactoryServer ; +Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component + (const char *containerName, + const char *componentName) +{ + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + char *stContainer=strdup(containerName); + string st2Container(stContainer); + int rg=st2Container.find("/"); + if(rg>=0) + { + stContainer[rg]='\0'; + if(strcmp(stContainer,"localhost")==0) + { + Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1,componentName); + free(stContainer); + return ret; } - } - } - if ( !CORBA::is_nil( aFactoryServer ) ) { - if ( strcmp( theContainer.c_str() , "FactoryServer" ) || - strcmp( theContainer.c_str() , "FactoryServerPy" ) ) { - MESSAGE("Container not found ! trying to start " << aComputerContainer); - Engines::Container_var myContainer = aFactoryServer->start_impl( theContainer.c_str() ) ; - if ( !CORBA::is_nil( myContainer ) ) { - MESSAGE("Container " << aComputerContainer << " started"); - return myContainer ; - } - else { - MESSAGE("Container " << aComputerContainer << " NOT started"); - } - } - else { - MESSAGE("Container " << aComputerContainer << " started"); - return aFactoryServer ; - } } + if(rg<0) { + //containerName doesn't contain "/" => Local container + free(stContainer); + Engines::MachineList_var listOfMachine=new Engines::MachineList; + listOfMachine->length(1); + listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); + Engines::Component_ptr ret=FindComponent(containerName,componentName,listOfMachine.in()); + if(CORBA::is_nil(ret)) + return LoadComponent(containerName,componentName,listOfMachine); + else + return ret; + } + else { + //containerName contains "/" => Remote container + stContainer[rg]='\0'; + Engines::MachineParameters_var params=new Engines::MachineParameters; + params->container_name=CORBA::string_dup(stContainer+rg+1); + params->hostname=CORBA::string_dup(stContainer); + params->OS=CORBA::string_dup("LINUX"); + free(stContainer); + return FindOrLoad_Component(params,componentName); } - return Engines::Container::_nil(); } -Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component - (const char *containerName, - const char *componentName, - const char *implementation) +Engines::Component_ptr SALOME_LifeCycleCORBA::FindOrLoad_Component(const Engines::MachineParameters& params, + const char *componentName) { - BEGIN_OF("FindOrLoad_Component(1)"); - ASSERT(_NS != NULL); - string theComputer ; - string theContainer ; - string theComputerContainer = ContainerName( containerName , - &theComputer , - &theContainer ) ; - Engines::Container_var cont = FindOrStartContainer( theComputerContainer , - theComputer , - theContainer ) ; -// ASSERT(!CORBA::is_nil(cont)); + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + Engines::MachineList_var listOfMachine=_ContManager->GetFittingResources(params,componentName); + Engines::Component_ptr ret=FindComponent(params.container_name,componentName,listOfMachine); + if(CORBA::is_nil(ret)) + return LoadComponent(params.container_name,componentName,listOfMachine); + else + return ret; +} - string path( theComputerContainer ); - path = path + "/"; - path = path + componentName; - SCRUTE(path); - try +Engines::Component_ptr SALOME_LifeCycleCORBA::FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines) +{ + if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + if(containerName[0]!='\0') { - CORBA::Object_var obj = _NS->Resolve(path.c_str()); - if (CORBA::is_nil(obj)) - { - MESSAGE("Component not found ! trying to load " << path); - Engines::Component_var compo - = cont->load_impl(componentName, implementation); -// ASSERT(!CORBA::is_nil(compo)); - MESSAGE("Component launched !" << path); - return compo; - } - else + Engines::MachineList_var machinesOK=new Engines::MachineList; + unsigned int lghtOfmachinesOK=0; + machinesOK->length(listOfMachines.length()); + for(unsigned int i=0;iResolve(componentNameForNS.c_str()); + if(!CORBA::is_nil(obj)) { - compo->ping(); + machinesOK[lghtOfmachinesOK++]=CORBA::string_dup(currentMachine); } - catch (CORBA::COMM_FAILURE&) - { - INFOS("Caught CORBA::SystemException CommFailure. Engine " - << path << "does not respond" ); - } - return compo; } + if(lghtOfmachinesOK!=0) + { + machinesOK->length(lghtOfmachinesOK); + CORBA::String_var bestMachine=_ContManager->FindBest(machinesOK); + string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); + CORBA::Object_var obj=_NS->Resolve(componentNameForNS.c_str()); + return Engines::Component::_narrow(obj); + } + else + return Engines::Component::_nil(); } - catch (ServiceUnreachable&) - { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) + else { - INFOS("Caught unknown exception."); + //user specified no container name so trying to find a component in the best machine among listOfMachines + CORBA::String_var bestMachine=_ContManager->FindBest(listOfMachines); + //Normally look at all containers launched on bestMachine to see if componentName is already launched on one of them. To do.. + string componentNameForNS=Engines_Component_i::BuildComponentNameForNS(componentName,containerName,bestMachine); + CORBA::Object_var obj = _NS->Resolve(componentNameForNS.c_str()); + return Engines::Component::_narrow(obj); } - return Engines::Component::_nil(); } -Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component - (const char *containerName, - const char *componentName) +Engines::Component_ptr SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines) { -// BEGIN_OF("FindOrLoad_Component(2)"); - ASSERT(_NS != NULL); - string theComputer ; - string theContainer ; - string theComputerContainer = ContainerName( containerName , - &theComputer , - &theContainer ) ; - Engines::Container_var cont = FindOrStartContainer( theComputerContainer , - theComputer , - theContainer ) ; - - if ( CORBA::is_nil( cont ) ) { - MESSAGE("Container not found ! " << theComputerContainer ); - return Engines::Component::_nil(); - } - -// char * machine = cont->machineName() ; - const char * machine = theComputer.c_str() ; - - string path( theComputerContainer ); - path += "/"; - path += componentName; - SCRUTE(path); - - try { - CORBA::Object_var obj = _NS->Resolve(path.c_str()); - if ( CORBA::is_nil( obj ) ) { - MESSAGE("Component not found ! trying to load " << path); - CORBA::Object_var obj2 = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj2); - - SALOME_ModuleCatalog::Acomponent_ptr compoInfo = - Catalog->GetComponent(componentName); - if (CORBA::is_nil (compoInfo)) - { - INFOS("Catalog Error : Component not found in the catalog") - return Engines::Component::_nil(); -// exit (-1); - } - - string path; - try - { - path = compoInfo->GetPathPrefix( machine ) ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) - { - INFOS("GetPathPrefix(" << machine << ") not found!" - << "trying localhost"); - try { - path = compoInfo->GetPathPrefix("localhost") ; - path += "/" ; - } - catch (SALOME_ModuleCatalog::NotFound&) { - INFOS("GetPathPrefix(localhost) not found!") ; - path = "" ; - } - } - - SCRUTE(path); - string implementation(path); - implementation += "lib"; - implementation += componentName; - implementation += "Engine.so"; - - Engines::Component_var compo - = cont->load_impl(componentName, implementation.c_str()); - -// ASSERT(!CORBA::is_nil(compo)); -// MESSAGE("Component launched !" << path); - return compo; - } - else - { - MESSAGE("Component found !" << path); - Engines::Component_var compo = Engines::Component::_narrow(obj); -// ASSERT(!CORBA::is_nil(compo)); - try - { - string instanceName = compo->instanceName(); - } - catch (CORBA::COMM_FAILURE&) - { - INFOS("Caught CORBA::SystemException CommFailure. Engine " - << path << "does not respond" ); - } - return compo; - } - } - catch (ServiceUnreachable&) - { - INFOS("Caught exception: Naming Service Unreachable"); - } - catch (...) - { - INFOS("Caught unknown exception."); - } - return Engines::Component::_nil(); + Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName,listOfMachines); + string implementation=Engines_Component_i::GetDynLibraryName(componentName); + return cont->load_impl(componentName, implementation.c_str()); } diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index 23b4e8797..a7a145c27 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -34,6 +34,7 @@ #include #include +#include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include CORBA_CLIENT_HEADER(SALOME_Component) class SALOME_NamingService; @@ -41,29 +42,31 @@ class SALOME_NamingService; class SALOME_LifeCycleCORBA { public: - SALOME_LifeCycleCORBA(); SALOME_LifeCycleCORBA(SALOME_NamingService *ns); virtual ~SALOME_LifeCycleCORBA(); - - Engines::Container_var FindContainer(const char *containerName); - Engines::Component_var FindOrLoad_Component(const char *containerName, - const char *componentName, - const char *implementationPath); - Engines::Component_var FindOrLoad_Component(const char *containerName, + Engines::Container_ptr FindContainer(const char *containerName); // for supervision + Engines::Component_ptr FindOrLoad_Component(const Engines::MachineParameters& params, + const char *componentName); + Engines::Component_ptr FindOrLoad_Component(const char *containerName, const char *componentName); + bool isKnownComponentClass(const char *componentName); protected: - SALOME_NamingService *_NS; - Engines::Container_var _FactoryServer ; + //! Establish if a component called "componentName" in a container called "containerName" exists among the list of resources + //! in "listOfMachines". This method uses Naming Service to find the component. + Engines::Component_ptr FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); + Engines::Component_ptr LoadComponent(const char *containerName, const char *componentName, const Engines::MachineList& listOfMachines); + + SALOME_NamingService *_NS; + Engines::ContainerManager_var _ContManager; + //private: std::string ContainerName( const char * aComputerContainer , - std::string * theComputer , - std::string * theContainer ) ; + std::string * theComputer , + std::string * theContainer ) ; std::string ComputerPath( const char * theComputer ) ; - Engines::Container_var FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; - } ; #endif diff --git a/src/Loader/Makefile.in b/src/Loader/Makefile.in index 99c98ab06..7660e9882 100644 --- a/src/Loader/Makefile.in +++ b/src/Loader/Makefile.in @@ -31,7 +31,8 @@ BIN_CLIENT_IDL = SALOME_Session.idl \ CPPFLAGS+=$(QT_MT_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx index df2cd8a1c..f4b6fd53b 100644 --- a/src/Logger/SALOME_Logger_Server.cxx +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -67,7 +67,7 @@ int main(int argc, char **argv) try { //Initialize the ORB - const long TIMESleep = 250000000; + const long TIMESleep = 500000000; const int NumberOfTries = 40; int i; timespec ts_req = {0, TIMESleep}; diff --git a/src/MEDWrapper/Base/MED_Algorithm.cxx b/src/MEDWrapper/Base/MED_Algorithm.cxx index cafc21b0b..a1a42ed96 100644 --- a/src/MEDWrapper/Base/MED_Algorithm.cxx +++ b/src/MEDWrapper/Base/MED_Algorithm.cxx @@ -39,35 +39,51 @@ static int MYVALUEDEBUG = 0; namespace MED{ //--------------------------------------------------------------- - TCellGroup - GetCellsByEntity(TWrapper& theWrapper, + TElemGroup + GetElemsByEntity(TWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo) { - MSG(MYDEBUG,"GetCellsByEntity(...)"); - TCellGroup aGroup; + MSG(MYDEBUG,"GetElemsByEntity(...)"); + TElemGroup aGroup; MED::TEntityInfo::const_iterator anIter = theEntityInfo.begin(); for(; anIter != theEntityInfo.end(); anIter++){ const EEntiteMaillage& anEntity = anIter->first; if(anEntity == eNOEUD) continue; const MED::TGeom& aGeom = anIter->second; - TCellSet& aCellSet = aGroup[anEntity]; + TElemSet& aElemSet = aGroup[anEntity]; MED::TGeom::const_iterator anGeomIter = aGeom.begin(); for(; anGeomIter != aGeom.end(); anGeomIter++){ const EGeometrieElement& aGeo = anGeomIter->first; - PCellInfo aCellInfo = theWrapper.GetPCellInfo(theMeshInfo,anEntity,aGeo); - aCellSet.insert(aCellInfo); - if(MYDEBUG){ - TInt aNbElem = aCellInfo->GetNbElem(); - INITMSG(MYDEBUG,"aGeo = "<GetConnDim(); - for(TInt iConn = 0; iConn < iConnEnd; iConn++){ - ADDMSG(MYVALUEDEBUG,aCellInfo->GetConn(iElem,iConn)<<","); + switch(aGeo){ + case ePOLYGONE: + { + PPolygoneInfo aPolygoneInfo = theWrapper.GetPPolygoneInfo(theMeshInfo,anEntity,aGeo); + aElemSet.insert(aPolygoneInfo); + TElemNum aConn = aPolygoneInfo->GetConnectivite(); + TElemNum aIndex = aPolygoneInfo->GetIndex(); + TInt aNbIndex = aIndex.size(); + TInt aIndex0 = aIndex[0]; + INITMSG(MYDEBUG,"aGeo = "<GetName(); - TInt aNbAttr = aFamilyInfo->GetNbAttr(); - TInt aNbGroup = aFamilyInfo->GetNbGroup(); - INITMSG(MYDEBUG, - "aFamilyName = '"<GetGroupName(iGroup); - INITMSG(MYDEBUG,"aGroupName = '"<= 0) + aGroup.insert(aFamilyInfo); } ADDMSG(MYDEBUG,"\n"); return aGroup; @@ -119,6 +125,8 @@ namespace MED{ aGroup[aFamilyInfo->GetGroupName(iGroup)].insert(aFamilyInfo); } } + +#ifdef _DEBUG_ if(MYDEBUG){ TGroupInfo::const_iterator anIter = aGroup.begin(); for(; anIter != aGroup.end(); anIter++){ @@ -133,6 +141,8 @@ namespace MED{ } ADDMSG(MYDEBUG,"\n"); } +#endif + return aGroup; } @@ -149,9 +159,8 @@ namespace MED{ INITMSG(MYDEBUG,"GetNbFields() = "<GetNbComp(); - string aName = aFieldInfo->GetName(); - INITMSG(MYDEBUG,"aFieldName = '"<first; TFamilyIdSet& aFamilyIdSet = aFamilyIdByEntity[anEntity]; - const TCellSet& aCellSet = anIter->second; - TCellSet::const_iterator anCellIter = aCellSet.begin(); - for(; anCellIter != aCellSet.end(); anCellIter++){ - const PCellInfo& aCellInfo = *anCellIter; - if(TInt aNbElem = aCellInfo->GetNbElem()){ + const TElemSet& aElemSet = anIter->second; + TElemSet::const_iterator anElemIter = aElemSet.begin(); + for(; anElemIter != aElemSet.end(); anElemIter++){ + const PElemInfo& aElemInfo = *anElemIter; + if(TInt aNbElem = aElemInfo->GetNbElem()){ for(TInt i = 0; i < aNbElem; i++){ - aFamilyIdSet.insert(aCellInfo->GetFamNum(i)); + aFamilyIdSet.insert(aElemInfo->GetFamNum(i)); } } } diff --git a/src/MEDWrapper/Base/MED_Algorithm.hxx b/src/MEDWrapper/Base/MED_Algorithm.hxx index 7d519c0ad..e72917a74 100644 --- a/src/MEDWrapper/Base/MED_Algorithm.hxx +++ b/src/MEDWrapper/Base/MED_Algorithm.hxx @@ -36,10 +36,10 @@ namespace MED{ //--------------------------------------------------------------- - typedef std::set TCellSet; - typedef std::map TCellGroup; + typedef std::set TElemSet; + typedef std::map TElemGroup; - TCellGroup GetCellsByEntity(TWrapper& theWrapper, + TElemGroup GetElemsByEntity(TWrapper& theWrapper, const PMeshInfo& theMeshInfo, const MED::TEntityInfo& theEntityInfo); @@ -56,7 +56,7 @@ namespace MED{ TFamilyByEntity GetFamiliesByEntity(TWrapper& theWrapper, const PNodeInfo& theNodeInfo, - const TCellGroup& theCellGroup, + const TElemGroup& theElemGroup, const TFamilyGroup& theFamilyGroup); diff --git a/src/MEDWrapper/Base/MED_Common.hxx b/src/MEDWrapper/Base/MED_Common.hxx index 51307abe8..5cac8fbd1 100644 --- a/src/MEDWrapper/Base/MED_Common.hxx +++ b/src/MEDWrapper/Base/MED_Common.hxx @@ -97,14 +97,21 @@ namespace MED{ const TEntity2GeomSet& GetEntity2GeomSet(); - inline TInt GetNbConn(EEntiteMaillage theEntity, - EGeometrieElement theElem, - TInt theMeshDim) - { - TInt anElemDim = theElem / 100, nsup = 0; - if(theEntity == eMAILLE && anElemDim < theMeshDim) nsup = 1; - return nsup + theElem % 100; - } + enum EVersion {eVUnknown = -1, eV2_1, eV2_2}; + + TInt GetNbConnectivities(EGeometrieElement typmai); + + template + TInt GetNbConn(EGeometrieElement typmai, + TInt mdim); + + template<> + TInt GetNbConn(EGeometrieElement typmai, + TInt mdim); + + template<> + TInt GetNbConn(EGeometrieElement typmai, + TInt mdim); struct TNameInfo; typedef MED::shared_ptr PNameInfo; @@ -121,6 +128,12 @@ namespace MED{ struct TNodeInfo; typedef MED::shared_ptr PNodeInfo; + struct TPolygoneInfo; + typedef MED::shared_ptr PPolygoneInfo; + + struct TPolyedreInfo; + typedef MED::shared_ptr PPolyedreInfo; + struct TCellInfo; typedef MED::shared_ptr PCellInfo; diff --git a/src/MEDWrapper/Base/MED_Structures.cxx b/src/MEDWrapper/Base/MED_Structures.cxx index 24185816f..3ec5eece4 100644 --- a/src/MEDWrapper/Base/MED_Structures.cxx +++ b/src/MEDWrapper/Base/MED_Structures.cxx @@ -123,19 +123,6 @@ TInt TCellInfo::GetConn(TInt theElemId, TInt theConnId) const { void TCellInfo::SetConn(TInt theElemId, TInt theConnId, TInt theVal){ GETINDEX(myConn,GetConnDim()*theElemId + theConnId) = theVal; } - -TConstConnSlice -TCellInfo::GetConnSlice(TInt theElemId) const -{ - return TConstConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbConnectivities(myTGeom),1)); -} - -TConnSlice -TCellInfo::GetConnSlice(TInt theElemId) -{ - return TConnSlice(myConn,std::slice(GetConnDim()*theElemId,GetNbConnectivities(myTGeom),1)); -} - //--------------------------------------------------------------- TInt TPolygoneInfo::GetNbConn(TInt theElemId) const { TInt i1 = GETINDEX(myIndex,theElemId); diff --git a/src/MEDWrapper/Base/MED_Structures.hxx b/src/MEDWrapper/Base/MED_Structures.hxx index 8ade5eb2f..888c3aeb1 100644 --- a/src/MEDWrapper/Base/MED_Structures.hxx +++ b/src/MEDWrapper/Base/MED_Structures.hxx @@ -36,22 +36,12 @@ namespace MED{ //--------------------------------------------------------------- typedef std::vector TString; - inline std::string GetString(TInt theId, TInt theStep, - const TString& theString) - { - const char* aPos = &theString[theId*theStep]; - TInt aSize = std::min(TInt(strlen(aPos)),theStep); - return std::string(aPos,aSize); - } - - inline void SetString(TInt theId, TInt theStep, - TString& theString, - const std::string& theValue) - { - TInt aSize = std::min(TInt(theValue.size()+1),theStep); - strncpy(&theString[theId*theStep],theValue.c_str(),aSize); - } + std::string GetString(TInt theId, TInt theStep, + const TString& theString); + void SetString(TInt theId, TInt theStep, + TString& theString, + const std::string& theValue); //--------------------------------------------------------------- struct TBase @@ -107,12 +97,12 @@ namespace MED{ TInt GetNbAttr() const { return myNbAttr;} TFamAttr myAttrId; - TInt GetAttrId(TInt theId) const { return myAttrId[theId];} - void SetAttrId(TInt theId, TInt theVal) { myAttrId[theId] = theVal;} + TInt GetAttrId(TInt theId) const; + void SetAttrId(TInt theId, TInt theVal); TFamAttr myAttrVal; - TInt GetAttrVal(TInt theId) const { return myAttrVal[theId];} - void SetAttrVal(TInt theId, TInt theVal) { myAttrVal[theId] = theVal;} + TInt GetAttrVal(TInt theId) const; + void SetAttrVal(TInt theId, TInt theVal); TString myAttrDesc; virtual std::string GetAttrDesc(TInt theId) const = 0; @@ -132,15 +122,15 @@ namespace MED{ TInt GetNbElem() const { return myNbElem;} TElemNum myFamNum; - TInt GetFamNum(TInt theId) const { return myFamNum[theId];} - void SetFamNum(TInt theId, TInt theVal) { myFamNum[theId] = theVal;} + TInt GetFamNum(TInt theId) const; + void SetFamNum(TInt theId, TInt theVal); EBooleen myIsElemNum; EBooleen IsElemNum() const { return myIsElemNum;} TElemNum myElemNum; - TInt GetElemNum(TInt theId) const { return myElemNum[theId];} - void SetElemNum(TInt theId, TInt theVal) { myElemNum[theId] = theVal;} + TInt GetElemNum(TInt theId) const; + void SetElemNum(TInt theId, TInt theVal); EBooleen myIsElemNames; EBooleen IsElemNames() const { return myIsElemNames;} @@ -157,12 +147,8 @@ namespace MED{ struct TNodeInfo: virtual TElemInfo { TNodeCoord myCoord; - TFloat GetNodeCoord(TInt theId, TInt theComp) const { - return myCoord[myMeshInfo->myDim*theId + theComp]; - } - void SetNodeCoord(TInt theId, TInt theComp, TFloat theVal){ - myCoord[myMeshInfo->myDim*theId + theComp] = theVal; - } + TFloat GetNodeCoord(TInt theId, TInt theComp) const; + void SetNodeCoord(TInt theId, TInt theComp, TFloat theVal); ERepere mySystem; ERepere GetSystem() const { return mySystem;} @@ -190,18 +176,63 @@ namespace MED{ EConnectivite myTConn; EConnectivite GetConn() const { return myTConn;} + virtual TInt GetConnDim() const = 0; + + TElemNum myConn; + TInt GetConn(TInt theElemId, TInt theConnId) const; + void SetConn(TInt theElemId, TInt theConnId, TInt theVal); + }; + + //--------------------------------------------------------------- + struct TPolygoneInfo: virtual TElemInfo + { + EEntiteMaillage myTEntity; // MED_FACE|MED_MAILLE + EEntiteMaillage GetEntity() const { return myTEntity;} + + EGeometrieElement myTGeom; // ePOLYGONE + EGeometrieElement GetGeom() const { return ePOLYGONE;} + + EConnectivite myTConn; // eNOD|eDESC(eDESC not used) + EConnectivite GetConn() const { return myTConn;} + TInt myConnDim; TInt GetConnDim() const { return myConnDim;} - TElemNum myConn; - TInt GetConn(TInt theElemId, TInt theConnId) const { - return myConn[myConnDim*theElemId + theConnId]; - } - void SetConn(TInt theElemId, TInt theConnId, TInt theVal){ - myConn[myConnDim*theElemId + theConnId] = theVal; - } + TElemNum myConn; // Table de connectivities + TElemNum GetConnectivite() const { return myConn;} + + TElemNum myIndex; // Table de indexes + TElemNum GetIndex() {return myIndex;} + TInt GetNbConn(TInt theElemId) const; }; + //--------------------------------------------------------------- + struct TPolyedreInfo: virtual TElemInfo + { + EEntiteMaillage myTEntity; // MED_FACE|MED_MAILLE + EEntiteMaillage GetEntity() const { return myTEntity;} + + EGeometrieElement myTGeom; // ePOLYEDRE + EGeometrieElement GetGeom() const { return ePOLYEDRE;} + + EConnectivite myTConn; // eNOD|eDESC(eDESC not used) + EConnectivite GetConn() const { return myTConn;} + + TInt myNbConn; + TInt GetNbConn() const { return myNbConn;} + + TElemNum myConn; // Table de connectivities + TElemNum GetConnectivite() const { return myConn;} + + TInt myNbFacesIndex; + TInt GetNbFacesIndex() const { return myNbFacesIndex;} + + TElemNum myFacesIndex; // Table de faces indexes + TElemNum GetFacesIndex() {return myFacesIndex;} + + TElemNum myIndex; // Table de indexes + TElemNum GetIndex() {return myIndex;} + }; //--------------------------------------------------------------- struct TFieldInfo: virtual TNameInfo @@ -272,24 +303,10 @@ namespace MED{ TMeshValue myMeshValue; TFloat GetVal(EGeometrieElement theGeom, TInt theId, - TInt theComp, TInt theGauss = 0) const - { - TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp; - TInt aNbGauss = myTimeStampInfo->myNbGauss; - TInt aStep = aNbComp*aNbGauss; - TMeshValue::const_iterator anIter = myMeshValue.find(theGeom); - if(anIter != myMeshValue.end()) - return anIter->second[theId*aStep + theComp*aNbGauss + theGauss]; - return TFloat(); - } + TInt theComp, TInt theGauss = 0) const; + void SetVal(EGeometrieElement theGeom, TInt theId, - TInt theComp, TFloat theVal, TInt theGauss = 0) - { - TInt aNbComp = myTimeStampInfo->myFieldInfo->myNbComp; - TInt aNbGauss = myTimeStampInfo->myNbGauss; - TInt aStep = aNbComp*aNbGauss; - myMeshValue[theGeom][theId*aStep + theComp*aNbGauss + theGauss] = theVal; - } + TInt theComp, TFloat theVal, TInt theGauss = 0); EModeProfil myPflMode; EModeProfil GetPflMode() const { return myPflMode;} void GetPflMode(EModeProfil theVal) { myPflMode = theVal;} diff --git a/src/MEDWrapper/Base/MED_TStructures.hxx b/src/MEDWrapper/Base/MED_TStructures.hxx index 93dc7b66b..15319fe7e 100644 --- a/src/MEDWrapper/Base/MED_TStructures.hxx +++ b/src/MEDWrapper/Base/MED_TStructures.hxx @@ -39,7 +39,7 @@ namespace MED{ const TInt LNOM = 80; //--------------------------------------------------------------- - template + template struct TTNameInfo: virtual TNameInfo { TTNameInfo(const std::string& theValue = "") @@ -59,10 +59,10 @@ namespace MED{ //--------------------------------------------------------------- - template - struct TTMeshInfo: TMeshInfo, TTNameInfo + template + struct TTMeshInfo: TMeshInfo, TTNameInfo { - typedef TTNameInfo TNameInfoBase; + typedef TTNameInfo TNameInfoBase; TTMeshInfo(const PMeshInfo& theInfo): TNameInfoBase(theInfo->GetName()) @@ -98,10 +98,10 @@ namespace MED{ //--------------------------------------------------------------- - template - struct TTFamilyInfo: TFamilyInfo, TTNameInfo + template + struct TTFamilyInfo: TFamilyInfo, TTNameInfo { - typedef TTNameInfo TNameInfoBase; + typedef TTNameInfo TNameInfoBase; TTFamilyInfo(const PMeshInfo& theMeshInfo, const PFamilyInfo& theInfo): TNameInfoBase(theInfo->GetName()) @@ -206,7 +206,7 @@ namespace MED{ //--------------------------------------------------------------- - template + template struct TTElemInfo: virtual TElemInfo { TTElemInfo(const PMeshInfo& theMeshInfo, const PElemInfo& theInfo) @@ -301,10 +301,10 @@ namespace MED{ //--------------------------------------------------------------- - template - struct TTNodeInfo: TNodeInfo, TTElemInfo + template + struct TTNodeInfo: TNodeInfo, TTElemInfo { - typedef TTElemInfo TElemInfoBase; + typedef TTElemInfo TElemInfoBase; TTNodeInfo(const PMeshInfo& theMeshInfo, const PNodeInfo& theInfo): TElemInfoBase(theMeshInfo,theInfo) @@ -398,12 +398,140 @@ namespace MED{ } }; + //--------------------------------------------------------------- + template + struct TTPolygoneInfo: TPolygoneInfo, TTElemInfo + { + typedef TTElemInfo TElemInfoBase; + TTPolygoneInfo(const PMeshInfo& theMeshInfo, const PPolygoneInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myTEntity = theInfo->GetEntity(); + myTGeom = theInfo->GetGeom(); + myTConn = theInfo->GetConn(); + myConnDim = theInfo->GetConnDim(); + myConn = theInfo->GetConnectivite(); + myIndex = theInfo->GetIndex(); + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myConnDim = theNbConn; + myConn.resize(myConnDim); + myIndex.resize(theNbElem+1); + } + + TTPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myConnDim = theConnectivities.size(); + myConn = theConnectivities; + myIndex = theIndexes; + } + }; //--------------------------------------------------------------- - template - struct TTCellInfo: TCellInfo, TTElemInfo + template + struct TTPolyedreInfo: TPolyedreInfo, TTElemInfo { - typedef TTElemInfo TElemInfoBase; + typedef TTElemInfo TElemInfoBase; + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, const PPolyedreInfo& theInfo): + TElemInfoBase(theMeshInfo,theInfo) + { + myTEntity = theInfo->GetEntity(); + myTGeom = theInfo->GetGeom(); + myTConn = theInfo->GetConn(); + myNbConn = theInfo->GetNbConn(); + myNbFacesIndex = theInfo->GetNbFacesIndex(); + myConn = theInfo->GetConnectivite(); + myFacesIndex = theInfo->GetFacesIndex(); + myIndex = theInfo->GetIndex(); + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + TInt theNbFacesIndex, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI): + TElemInfoBase(theMeshInfo, + theNbElem, + theIsElemNum, + theIsElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myNbConn = theNbConn; + myNbFacesIndex = theNbFacesIndex; + myConn.resize(myNbConn); + myFacesIndex.resize(myNbFacesIndex); + myIndex.resize(theNbElem+1); + } + + TTPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFacesIndexes, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()): + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) + { + myTEntity = theTEntity; + myTGeom = theTGeom; + myTConn = theTConn; + myNbConn = theConnectivities.size(); + myNbFacesIndex = theFacesIndexes.size(); + myConn = theConnectivities; + myFacesIndex = theFacesIndexes; + myIndex = theIndexes; + } + }; + + //--------------------------------------------------------------- + template + struct TTCellInfo: TCellInfo, TTElemInfo + { + typedef TTElemInfo TElemInfoBase; TTCellInfo(const PMeshInfo& theMeshInfo, const PCellInfo& theInfo): TElemInfoBase(theMeshInfo,theInfo) @@ -411,11 +539,11 @@ namespace MED{ myTEntity = theInfo->GetEntity(); myTGeom = theInfo->GetGeom(); myTConn = theInfo->GetConn(); - myConnDim = theInfo->GetConnDim(); - myConn.resize(myNbElem*myConnDim); + TInt aConnDim = GetNbConnectivities(myTGeom); + myConn.resize(myNbElem*GetNbConn(myTGeom,myMeshInfo->myDim)); for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ - for(TInt anConnId = 0; anConnId < myConnDim; anConnId++){ + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ SetConn(anElemId,anConnId,theInfo->GetConn(anElemId,anConnId)); } } @@ -436,8 +564,7 @@ namespace MED{ myTEntity = theTEntity; myTGeom = theTGeom; myTConn = theTConn; - myConnDim = GetNbConn(myTEntity,myTGeom,theMeshInfo->myDim); - myConn.resize(theNbElem*myConnDim); + myConn.resize(theNbElem*GetNbConn(theTGeom,theMeshInfo->myDim)); } TTCellInfo(const PMeshInfo& theMeshInfo, @@ -448,28 +575,38 @@ namespace MED{ const TIntVector& theFamilyNums, const TIntVector& theElemNums, const TStringVector& theElemNames = TStringVector()): - TTElemInfo(theMeshInfo, - theFamilyNums, - theElemNums, - theElemNames) + TElemInfoBase(theMeshInfo, + theFamilyNums, + theElemNums, + theElemNames) { myTEntity = theTEntity; myTGeom = theTGeom; myTConn = theTConn; - myConnDim = GetNbConn(myTEntity,myTGeom,theMeshInfo->myDim); - myConn.resize(theConnectivities.size()); - for(TInt anId = 0, anEnd = myConn.size(); anId < anEnd; anId++){ - myConn[anId] = theConnectivities[anId]; + + TInt aConnDim = GetNbConnectivities(myTGeom); + myNbElem = theConnectivities.size() / aConnDim; + myConn.resize(myNbElem*GetNbConn(myTGeom,myMeshInfo->myDim)); + for(TInt anElemId = 0; anElemId < myNbElem; anElemId++){ + for(TInt anConnId = 0; anConnId < aConnDim; anConnId++){ + SetConn(anElemId,anConnId,theConnectivities[anElemId*aConnDim+anConnId]); + } } + + } + + virtual TInt GetConnDim() const { + return GetNbConn(myTGeom,myMeshInfo->myDim); } + }; //--------------------------------------------------------------- - template - struct TTFieldInfo: TFieldInfo, TTNameInfo + template + struct TTFieldInfo: TFieldInfo, TTNameInfo { - typedef TTNameInfo TNameInfoBase; + typedef TTNameInfo TNameInfoBase; TTFieldInfo(const PMeshInfo& theMeshInfo, const PFieldInfo& theInfo): TNameInfoBase(theInfo->GetName()) @@ -532,7 +669,7 @@ namespace MED{ //--------------------------------------------------------------- - template + template struct TTTimeStampInfo: TTimeStampInfo { TTTimeStampInfo(const PFieldInfo& theFieldInfo, const PTimeStampInfo& theInfo) @@ -600,7 +737,7 @@ namespace MED{ //--------------------------------------------------------------- - template + template struct TTTimeStampVal: TTimeStampVal { TTTimeStampVal(const PTimeStampInfo& theTimeStampInfo, const PTimeStampVal& theInfo) diff --git a/src/MEDWrapper/Base/MED_TWrapper.hxx b/src/MEDWrapper/Base/MED_TWrapper.hxx index b5811b09e..e07ae30f8 100644 --- a/src/MEDWrapper/Base/MED_TWrapper.hxx +++ b/src/MEDWrapper/Base/MED_TWrapper.hxx @@ -34,36 +34,42 @@ namespace MED{ - template + template class TTWrapper: public TWrapper{ public: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PMeshInfo CrMeshInfo(TInt theDim = 0, - const std::string& theValue = "", - EMaillage theType = eNON_STRUCTURE, - const std::string& theDesc = "") + virtual + PMeshInfo + CrMeshInfo(TInt theDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = "") { - return PMeshInfo(new TTMeshInfo + return PMeshInfo(new TTMeshInfo (theDim, theValue, theType, theDesc)); } - virtual PMeshInfo CrMeshInfo(const PMeshInfo& theInfo) + virtual + PMeshInfo + CrMeshInfo(const PMeshInfo& theInfo) { - return PMeshInfo(new TTMeshInfo(theInfo)); + return PMeshInfo(new TTMeshInfo(theInfo)); } - + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - TInt theNbGroup = 0, - TInt theNbAttr = 0, - TInt theId = 0, - const std::string& theValue = "") + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = "") { - return PFamilyInfo(new TTFamilyInfo + return PFamilyInfo(new TTFamilyInfo (theMeshInfo, theNbGroup, theNbAttr, @@ -71,15 +77,17 @@ namespace MED{ theValue)); } - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - const std::string& theValue, - TInt theId, - const MED::TStringSet& theGroupNames, - const MED::TStringVector& theAttrDescs = MED::TStringVector(), - const MED::TIntVector& theAttrIds = MED::TIntVector(), - const MED::TIntVector& theAttrVals = MED::TIntVector()) + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const MED::TStringSet& theGroupNames, + const MED::TStringVector& theAttrDescs = MED::TStringVector(), + const MED::TIntVector& theAttrIds = MED::TIntVector(), + const MED::TIntVector& theAttrVals = MED::TIntVector()) { - return PFamilyInfo(new TTFamilyInfo + return PFamilyInfo(new TTFamilyInfo (theMeshInfo, theValue, theId, @@ -89,23 +97,27 @@ namespace MED{ theAttrVals)); } - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - const PFamilyInfo& theInfo) + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const PFamilyInfo& theInfo) { - return PFamilyInfo(new TTFamilyInfo + return PFamilyInfo(new TTFamilyInfo (theMeshInfo, theInfo)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - TInt theNbElem, - ERepere theSystem = eCART, - EBooleen theIsElemNum = eVRAI, - EBooleen theIsElemNames = eVRAI) + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) { - return PNodeInfo(new TTNodeInfo + return PNodeInfo(new TTNodeInfo (theMeshInfo, theNbElem, theSystem, @@ -113,16 +125,18 @@ namespace MED{ theIsElemNames)); } - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - ERepere theSystem, - const TFloatVector& theNodeCoords, - const TStringVector& theCoordNames, - const TStringVector& theCoordUnits, - const TIntVector& theFamilyNums, - const TIntVector& theElemNums, - const TStringVector& theElemNames = TStringVector()) + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + ERepere theSystem, + const TFloatVector& theNodeCoords, + const TStringVector& theCoordNames, + const TStringVector& theCoordUnits, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) { - return PNodeInfo(new TTNodeInfo + return PNodeInfo(new TTNodeInfo (theMeshInfo, theSystem, theNodeCoords, @@ -133,25 +147,146 @@ namespace MED{ theElemNames)); } - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - const PNodeInfo& theInfo) + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const PNodeInfo& theInfo) { - return PNodeInfo(new TTNodeInfo + return PNodeInfo(new TTNodeInfo (theMeshInfo, theInfo)); } + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theNbElem, + theNbConn, + theTEntity, + theTGeom, + theTConn, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theTEntity, + theTGeom, + theTConn, + theConnectivities, + theIndexes, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + const PPolygoneInfo& theInfo) + { + return PPolygoneInfo(new TTPolygoneInfo + (theMeshInfo, + theInfo)); + } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - TInt theNbElem, - EEntiteMaillage theTEntity, - EGeometrieElement theTGeom, - EConnectivite theTConn = eNOD, - EBooleen theIsElemNum = eVRAI, - EBooleen theIsElemNames = eVRAI) + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + TInt theNbFaces, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theNbElem, + theNbConn, + theNbFaces, + theTEntity, + theTGeom, + theTConn, + theIsElemNum, + theIsElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFacesIndexes, + const TIntVector& theIndexes, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theTEntity, + theTGeom, + theTConn, + theConnectivities, + theFacesIndexes, + theIndexes, + theFamilyNums, + theElemNums, + theElemNames)); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + const PPolyedreInfo& theInfo) + { + return PPolyedreInfo(new TTPolyedreInfo + (theMeshInfo, + theInfo)); + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) { - return PCellInfo(new TTCellInfo + return PCellInfo(new TTCellInfo (theMeshInfo, theNbElem, theTEntity, @@ -161,16 +296,18 @@ namespace MED{ theIsElemNames)); } - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - EEntiteMaillage theTEntity, - EGeometrieElement theTGeom, - EConnectivite theTConn, - const TIntVector& theConnectivities, - const TIntVector& theFamilyNums, - const TIntVector& theElemNums, - const TStringVector& theElemNames = TStringVector()) + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) { - return PCellInfo(new TTCellInfo + return PCellInfo(new TTCellInfo (theMeshInfo, theTEntity, theTGeom, @@ -181,24 +318,28 @@ namespace MED{ theElemNames)); } - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - const PCellInfo& theInfo) + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + const PCellInfo& theInfo) { - return PCellInfo(new TTCellInfo + return PCellInfo(new TTCellInfo (theMeshInfo, theInfo)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PFieldInfo CrFieldInfo(const PMeshInfo& theMeshInfo, - TInt theNbComp = 0, - ETypeChamp theType = eFLOAT64, - const std::string& theValue = "", - EBooleen theIsLocal = eVRAI, - TInt theNbRef = 1) + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1) { - return PFieldInfo(new TTFieldInfo + return PFieldInfo(new TTFieldInfo (theMeshInfo, theNbComp, theType, @@ -207,27 +348,31 @@ namespace MED{ theNbRef)); } - virtual PFieldInfo CrFieldInfo(const PMeshInfo& theMeshInfo, - const PFieldInfo& theInfo) + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + const PFieldInfo& theInfo) { - return PFieldInfo(new TTFieldInfo + return PFieldInfo(new TTFieldInfo (theMeshInfo, theInfo)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PTimeStampInfo CrTimeStampInfo(const PFieldInfo& theFieldInfo, - EEntiteMaillage theEntity, - const TGeom& theGeom, - TInt theNbGauss = 0, - TInt theNumDt = 0, - TInt theNumOrd = 0, - TFloat theDt = 0, - const std::string& theUnitDt = "", - const std::string& theGaussName = "") + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom& theGeom, + TInt theNbGauss = 0, + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const std::string& theGaussName = "") { - return PTimeStampInfo(new TTTimeStampInfo + return PTimeStampInfo(new TTTimeStampInfo (theFieldInfo, theEntity, theGeom, @@ -239,30 +384,36 @@ namespace MED{ theGaussName)); } - virtual PTimeStampInfo CrTimeStampInfo(const PFieldInfo& theFieldInfo, - const PTimeStampInfo& theInfo) + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + const PTimeStampInfo& theInfo) { - return PTimeStampInfo(new TTTimeStampInfo + return PTimeStampInfo(new TTTimeStampInfo (theFieldInfo, theInfo)); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PTimeStampVal CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, - const std::string& thePflName = "", - EModeProfil thePflMode = eCOMPACT) + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const std::string& thePflName = "", + EModeProfil thePflMode = eCOMPACT) { - return PTimeStampVal(new TTTimeStampVal + return PTimeStampVal(new TTTimeStampVal (theTimeStampInfo, thePflName, thePflMode)); } - virtual PTimeStampVal CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, - const PTimeStampVal& theInfo) + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampVal& theInfo) { - return PTimeStampVal(new TTTimeStampVal + return PTimeStampVal(new TTTimeStampVal (theTimeStampInfo, theInfo)); } diff --git a/src/MEDWrapper/Base/MED_Utilities.cxx b/src/MEDWrapper/Base/MED_Utilities.cxx index 1454a96f3..5c53a4df2 100644 --- a/src/MEDWrapper/Base/MED_Utilities.cxx +++ b/src/MEDWrapper/Base/MED_Utilities.cxx @@ -77,6 +77,7 @@ bool InitEntity2GeomSet() aGeomFACESet.insert(eQUAD4); aGeomFACESet.insert(eTRIA6); aGeomFACESet.insert(eQUAD8); + aGeomFACESet.insert(ePOLYGONE); TGeomSet& aGeomMAILLESet = Entity2GeomSet[eMAILLE]; aGeomMAILLESet.insert(ePOINT1); @@ -90,6 +91,7 @@ bool InitEntity2GeomSet() aGeomMAILLESet.insert(ePYRA13); aGeomMAILLESet.insert(ePENTA15); aGeomMAILLESet.insert(eHEXA20); + aGeomMAILLESet.insert(ePOLYEDRE); return true; } diff --git a/src/MEDWrapper/Base/MED_Utilities.hxx b/src/MEDWrapper/Base/MED_Utilities.hxx index 96f1b30fc..3c3882cc7 100644 --- a/src/MEDWrapper/Base/MED_Utilities.hxx +++ b/src/MEDWrapper/Base/MED_Utilities.hxx @@ -48,7 +48,7 @@ namespace MED{ }; }; - +//#define _DEBUG_ #ifdef _DEBUG_ #define MSG(deb,msg) if(deb) std::cout<GetName(); + INITMSG(MYDEBUG, + "aFamilyName = '"<GetGroupName(iGroup); + INITMSG(MYDEBUG,"aGroupName = '"<myDim; + TInt aNbElem = anInfo->GetNbElem(); + INITMSG(MYDEBUG,"GetPNodeInfo - aCoords: "<myCoord; + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + for(TInt iDim = 0, anId = iElem*aDim; iDim < aDim; iDim++, anId++){ + ADDMSG(MYVALUEDEBUG,aCoord[anId]<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG,endl); + + BEGMSG(MYDEBUG,"GetPNodeInfo - GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYDEBUG,"GetPNodeInfo - GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + } + + ADDMSG(MYDEBUG,endl); +#endif + return anInfo; } - + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PPolygoneInfo TWrapper::GetPPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn) + { + TInt aNbElem = GetNbPolygones(*theMeshInfo,theEntity,theGeom,theConn); + TInt aNbConn = GetNbPolygoneConn(*theMeshInfo,theEntity,theGeom,theConn); + PPolygoneInfo anInfo = CrPolygoneInfo(theMeshInfo,aNbElem,aNbConn,theEntity,theGeom,theConn); + GetPolygoneInfo(*anInfo); + return anInfo; + } + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PPolyedreInfo TWrapper::GetPPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn) + { + TInt aNbElem = GetNbPolyedres(*theMeshInfo,theEntity,theGeom,theConn); + TInt aNbConn = 0; + TInt aNbFaces = 0; + GetNbPolyedreConnF(*theMeshInfo,theConn,aNbFaces,aNbConn); + PPolyedreInfo anInfo = CrPolyedreInfo(theMeshInfo,aNbElem,aNbConn,aNbFaces,theEntity,theGeom,theConn); + GetPolyedreInfo(*anInfo); + return anInfo; + } + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PCellInfo TWrapper::GetPCellInfo(const PMeshInfo& theMeshInfo, EEntiteMaillage theEntity, EGeometrieElement theGeom, - EConnectivite theConn) + EConnectivite theConn, + TErr* theErr) { TInt aNbElem = GetNbCells(*theMeshInfo,theEntity,theGeom,theConn); PCellInfo anInfo = CrCellInfo(theMeshInfo,aNbElem,theEntity,theGeom,theConn); - GetCellInfo(*anInfo); + GetCellInfo(*anInfo,theErr); + +#ifdef _DEBUG_ + TInt aConnDim = anInfo->GetConnDim(); + INITMSG(MYDEBUG,"GetPCellInfo - theEntity = "<GetConn(iElem,iConn)<<","); + } + ADDMSG(MYVALUEDEBUG," "); + } + ADDMSG(MYDEBUG,endl); + + BEGMSG(MYDEBUG,"GetPCellInfo - GetFamNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetFamNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + + if(anInfo->IsElemNum()){ + BEGMSG(MYDEBUG,"GetPCellInfo - GetElemNum: "); + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + ADDMSG(MYVALUEDEBUG,anInfo->GetElemNum(iElem)<<", "); + } + ADDMSG(MYDEBUG,endl); + } + + ADDMSG(MYDEBUG,endl); +#endif + return anInfo; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - PFieldInfo TWrapper::GetPFieldInfo(const PMeshInfo& theMeshInfo, TInt theId) + PFieldInfo TWrapper::GetPFieldInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr) { TInt aNbComp = GetNbComp(theId); PFieldInfo anInfo = CrFieldInfo(theMeshInfo,aNbComp); - GetFieldInfo(theId,*anInfo); + GetFieldInfo(theId,*anInfo,theErr); return anInfo; } @@ -67,19 +182,21 @@ namespace MED{ PTimeStampInfo TWrapper::GetPTimeStampInfo(const PFieldInfo& theFieldInfo, EEntiteMaillage theEntity, const MED::TGeom& theGeom, - TInt theId) + TInt theId, + TErr* theErr) { PTimeStampInfo anInfo = CrTimeStampInfo(theFieldInfo,theEntity,theGeom); - GetTimeStampInfo(theId,*anInfo); + GetTimeStampInfo(theId,*anInfo,theErr); return anInfo; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - PTimeStampVal TWrapper::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo) + PTimeStampVal TWrapper::GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + TErr* theErr) { PTimeStampVal anInfo = CrTimeStampVal(theTimeStampInfo); - GetTimeStampVal(*anInfo); + GetTimeStampVal(*anInfo,theErr); return anInfo; } } diff --git a/src/MEDWrapper/Base/MED_Wrapper.hxx b/src/MEDWrapper/Base/MED_Wrapper.hxx index 102e38ef1..4865a156e 100644 --- a/src/MEDWrapper/Base/MED_Wrapper.hxx +++ b/src/MEDWrapper/Base/MED_Wrapper.hxx @@ -35,209 +35,452 @@ namespace MED{ struct TWrapper{ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual PMeshInfo CrMeshInfo(TInt theDim = 0, - const std::string& theValue = "", - EMaillage theType = eNON_STRUCTURE, - const std::string& theDesc = "") = 0; - - virtual PMeshInfo CrMeshInfo(const PMeshInfo& theInfo) = 0; - - virtual TInt GetNbMeshes(TErr* theErr = NULL) = 0; + virtual + PMeshInfo + CrMeshInfo(TInt theDim = 0, + const std::string& theValue = "", + EMaillage theType = eNON_STRUCTURE, + const std::string& theDesc = "") = 0; + + virtual + PMeshInfo + CrMeshInfo(const PMeshInfo& theInfo) = 0; + + virtual + TInt + GetNbMeshes(TErr* theErr = NULL) = 0; - virtual void GetMeshInfo(TInt theMeshId, TMeshInfo&, - TErr* theErr = NULL) = 0; - - virtual void SetMeshInfo(const TMeshInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + void + GetMeshInfo(TInt theMeshId, TMeshInfo&, + TErr* theErr = NULL) = 0; + + virtual + void + SetMeshInfo(const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; - virtual PMeshInfo GetPMeshInfo(TInt theId); + virtual + PMeshInfo + GetPMeshInfo(TInt theId, + TErr* theErr = NULL); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbFamilies(const TMeshInfo& theMeshInfo, - TErr* theErr = NULL) = 0; - - virtual TInt GetNbFamAttr(TInt theFamId, - const TMeshInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual TInt GetNbFamGroup(TInt theFamId, - const TMeshInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + TInt + GetNbFamilies(const TMeshInfo& theMeshInfo, + TErr* theErr = NULL) = 0; + + virtual + TInt + GetNbFamAttr(TInt theFamId, + const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; - virtual void GetFamilyInfo(TInt theFamId, - TFamilyInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + TInt + GetNbFamGroup(TInt theFamId, + const TMeshInfo& theInfo, + TErr* theErr = NULL) = 0; - virtual void SetFamilyInfo(const TFamilyInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + void + GetFamilyInfo(TInt theFamId, + TFamilyInfo& theInfo, + TErr* theErr = NULL) = 0; - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - TInt theNbGroup = 0, - TInt theNbAttr = 0, - TInt theId = 0, - const std::string& theValue = "") = 0; + virtual + void + SetFamilyInfo(const TFamilyInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theNbGroup = 0, + TInt theNbAttr = 0, + TInt theId = 0, + const std::string& theValue = "") = 0; + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const std::string& theValue, + TInt theId, + const TStringSet& theGroupNames, + const TStringVector& theAttrDescs = TStringVector(), + const TIntVector& theAttrIds = TIntVector(), + const TIntVector& theAttrVals = TIntVector()) = 0; + + virtual + PFamilyInfo + CrFamilyInfo(const PMeshInfo& theMeshInfo, + const PFamilyInfo& theInfo) = 0; + + PFamilyInfo + GetPFamilyInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr = NULL); - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - const std::string& theValue, - TInt theId, - const TStringSet& theGroupNames, - const TStringVector& theAttrDescs = TStringVector(), - const TIntVector& theAttrIds = TIntVector(), - const TIntVector& theAttrVals = TIntVector()) = 0; - - virtual PFamilyInfo CrFamilyInfo(const PMeshInfo& theMeshInfo, - const PFamilyInfo& theInfo) = 0; - - PFamilyInfo GetPFamilyInfo(const PMeshInfo& theMeshInfo, TInt theId); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbNodes(const TMeshInfo& theMeshInfo, - TErr* theErr = NULL) = 0; + virtual + TInt + GetNbNodes(const TMeshInfo& theMeshInfo, + TErr* theErr = NULL) = 0; - virtual void GetNodeInfo(TNodeInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual void SetNodeInfo(const TNodeInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + void + GetNodeInfo(TNodeInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + void + SetNodeInfo(const TNodeInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + ERepere theSystem = eCART, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) = 0; + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + ERepere theSystem, + const TFloatVector& theNodeCoords, + const TStringVector& theCoordNames, + const TStringVector& theCoordUnits, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) = 0; + + virtual + PNodeInfo + CrNodeInfo(const PMeshInfo& theMeshInfo, + const PNodeInfo& theInfo) = 0; + + PNodeInfo + GetPNodeInfo(const PMeshInfo& theMeshInfo, + TErr* theErr = NULL); - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - TInt theNbElem, - ERepere theSystem = eCART, - EBooleen theIsElemNum = eVRAI, - EBooleen theIsElemNames = eVRAI) = 0; - - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - ERepere theSystem, - const TFloatVector& theNodeCoords, - const TStringVector& theCoordNames, - const TStringVector& theCoordUnits, - const TIntVector& theFamilyNums, - const TIntVector& theElemNums, - const TStringVector& theElemNames = TStringVector()) = 0; - - virtual PNodeInfo CrNodeInfo(const PMeshInfo& theMeshInfo, - const PNodeInfo& theInfo) = 0; - - PNodeInfo GetPNodeInfo(const PMeshInfo& theMeshInfo); - - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TEntityInfo GetEntityInfo(const TMeshInfo& theMeshInfo, - EConnectivite theTConn = eNOD, - TErr* theErr = NULL) = 0; - - virtual TInt GetNbCells(const TMeshInfo& theMeshInfo, - EEntiteMaillage, - EGeometrieElement, - EConnectivite theTConn = eNOD, - TErr* theErr = NULL) = 0; - - virtual void GetCellInfo(TCellInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual void SetCellInfo(const TCellInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - TInt theNbElem, - EEntiteMaillage theTEntity, - EGeometrieElement theTGeom, - EConnectivite theTConn = eNOD, - EBooleen theIsElemNum = eVRAI, - EBooleen theIsElemNames = eVRAI) = 0; - - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - EEntiteMaillage theTEntity, - EGeometrieElement theTGeom, - EConnectivite theTConn, - const TIntVector& theConnectivities, - const TIntVector& theFamilyNums, - const TIntVector& theElemNums, - const TStringVector& theElemNames = TStringVector()) = 0; - - virtual PCellInfo CrCellInfo(const PMeshInfo& theMeshInfo, - const PCellInfo& theInfo) = 0; - - PCellInfo GetPCellInfo(const PMeshInfo& theMeshInfo, - EEntiteMaillage theEntity, - EGeometrieElement theGeom, - EConnectivite theConn = eNOD); - - + virtual + void + GetPolygoneInfo(TPolygoneInfo& theInfo, + TErr* theErr = NULL) + {} + + virtual + void + SetPolygoneInfo(const TPolygoneInfo& theInfo, + TErr* theErr = NULL) + {} + + virtual + TInt + GetNbPolygones(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL) + { return 0;} + + virtual + TInt + GetNbPolygoneConn(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL) + { return 0;} + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolygoneInfo(); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolygoneInfo(); + } + + virtual + PPolygoneInfo + CrPolygoneInfo(const PMeshInfo& theMeshInfo, + const PPolygoneInfo& theInfo) + { + return PPolygoneInfo(); + } + + PPolygoneInfo + GetPPolygoneInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn = eNOD); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbFields(TErr* theErr = NULL) = 0; + virtual + void + GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr = NULL) + {} + + virtual + void + SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr = NULL) + {} - virtual TInt GetNbComp(TInt theFieldId, - TErr* theErr = NULL) = 0; + virtual + TInt + GetNbPolyedres(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL) + { return 0;} + + virtual + void + GetNbPolyedreConnF(const TMeshInfo& theMeshInfo, + EConnectivite theConn, + TInt& nf, + TInt& nc, + TErr* theErr = NULL) + {} - virtual void GetFieldInfo(TInt theFieldId, - TFieldInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual void SetFieldInfo(const TFieldInfo& theInfo, - TErr* theErr = NULL) = 0; + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + TInt theNbConn, + TInt theNbFaces, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) + { + return PPolyedreInfo(); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) + { + return PPolyedreInfo(); + } + + virtual + PPolyedreInfo + CrPolyedreInfo(const PMeshInfo& theMeshInfo, + const PPolyedreInfo& theInfo) + { + return PPolyedreInfo(); + } + + PPolyedreInfo + GetPPolyedreInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn = eNOD); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TEntityInfo + GetEntityInfo(const TMeshInfo& theMeshInfo, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL) = 0; + + virtual + TInt + GetNbCells(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL) = 0; + + virtual + void + GetCellInfo(TCellInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + void + SetCellInfo(const TCellInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + TInt theNbElem, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn = eNOD, + EBooleen theIsElemNum = eVRAI, + EBooleen theIsElemNames = eVRAI) = 0; + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + const TIntVector& theConnectivities, + const TIntVector& theFamilyNums, + const TIntVector& theElemNums, + const TStringVector& theElemNames = TStringVector()) = 0; + + virtual + PCellInfo + CrCellInfo(const PMeshInfo& theMeshInfo, + const PCellInfo& theInfo) = 0; + PCellInfo + GetPCellInfo(const PMeshInfo& theMeshInfo, + EEntiteMaillage theEntity, + EGeometrieElement theGeom, + EConnectivite theConn = eNOD, + TErr* theErr = NULL); - virtual PFieldInfo CrFieldInfo(const PMeshInfo& theMeshInfo, - TInt theNbComp = 0, - ETypeChamp theType = eFLOAT64, - const std::string& theValue = "", - EBooleen theIsLocal = eVRAI, - TInt theNbRef = 1) = 0; - virtual PFieldInfo CrFieldInfo(const PMeshInfo& theMeshInfo, - const PFieldInfo& theInfo) = 0; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbFields(TErr* theErr = NULL) = 0; + + virtual + TInt + GetNbComp(TInt theFieldId, + TErr* theErr = NULL) = 0; + + virtual + void + GetFieldInfo(TInt theFieldId, + TFieldInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + void + SetFieldInfo(const TFieldInfo& theInfo, + TErr* theErr = NULL) = 0; + - PFieldInfo GetPFieldInfo(const PMeshInfo& theMeshInfo, TInt theId); + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + TInt theNbComp = 0, + ETypeChamp theType = eFLOAT64, + const std::string& theValue = "", + EBooleen theIsLocal = eVRAI, + TInt theNbRef = 1) = 0; + + virtual + PFieldInfo + CrFieldInfo(const PMeshInfo& theMeshInfo, + const PFieldInfo& theInfo) = 0; + + PFieldInfo + GetPFieldInfo(const PMeshInfo& theMeshInfo, + TInt theId, + TErr* theErr = NULL); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbTimeStamps(const TFieldInfo& theInfo, - const TEntityInfo& theEntityInfo, - EEntiteMaillage& theEntity, - TGeom& theGeom, - TErr* theErr = NULL) = 0; - - virtual void GetTimeStampInfo(TInt theTimeStampId, - TTimeStampInfo& theInfo, - TErr* theErr = NULL) = 0; - - virtual PTimeStampInfo CrTimeStampInfo(const PFieldInfo& theFieldInfo, - EEntiteMaillage theEntity, - const TGeom& theGeom, - TInt theNbGauss = 0, - TInt theNumDt = 0, - TInt theNumOrd = 0, - TFloat theDt = 0, - const std::string& theUnitDt = "", - const std::string& theGaussName = "") = 0; - - virtual PTimeStampInfo CrTimeStampInfo(const PFieldInfo& theFieldInfo, - const PTimeStampInfo& theInfo) = 0; - - PTimeStampInfo GetPTimeStampInfo(const PFieldInfo& theFieldInfo, - EEntiteMaillage theEntity, - const MED::TGeom& theGeom, - TInt theId); + virtual + TInt + GetNbTimeStamps(const TFieldInfo& theInfo, + const TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom& theGeom, + TErr* theErr = NULL) = 0; + + virtual + void + GetTimeStampInfo(TInt theTimeStampId, + TTimeStampInfo& theInfo, + TErr* theErr = NULL) = 0; + + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const TGeom& theGeom, + TInt theNbGauss = 0, + TInt theNumDt = 0, + TInt theNumOrd = 0, + TFloat theDt = 0, + const std::string& theUnitDt = "", + const std::string& theGaussName = "") = 0; + + virtual + PTimeStampInfo + CrTimeStampInfo(const PFieldInfo& theFieldInfo, + const PTimeStampInfo& theInfo) = 0; + + PTimeStampInfo + GetPTimeStampInfo(const PFieldInfo& theFieldInfo, + EEntiteMaillage theEntity, + const MED::TGeom& theGeom, + TInt theId, + TErr* theErr = NULL); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual void GetTimeStampVal(TTimeStampVal& theVal, - TErr* theErr = NULL) = 0; + virtual + void + GetTimeStampVal(TTimeStampVal& theVal, + TErr* theErr = NULL) = 0; - virtual void SetTimeStamp(const TTimeStampVal& theTimeStampVal, - TErr* theErr = NULL) = 0; - - virtual PTimeStampVal CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, - const std::string& thePflName = "", - EModeProfil thePflMode = eCOMPACT) = 0; - - virtual PTimeStampVal CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, - const PTimeStampVal& theInfo) = 0; - - PTimeStampVal GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo); + virtual + void + SetTimeStamp(const TTimeStampVal& theTimeStampVal, + TErr* theErr = NULL) = 0; + + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const std::string& thePflName = "", + EModeProfil thePflMode = eCOMPACT) = 0; + + virtual + PTimeStampVal + CrTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + const PTimeStampVal& theInfo) = 0; + + PTimeStampVal + GetPTimeStampVal(const PTimeStampInfo& theTimeStampInfo, + TErr* theErr = NULL); }; diff --git a/src/MEDWrapper/Base/Makefile.in b/src/MEDWrapper/Base/Makefile.in index b32b0284a..ae80425cb 100644 --- a/src/MEDWrapper/Base/Makefile.in +++ b/src/MEDWrapper/Base/Makefile.in @@ -46,7 +46,9 @@ EXPORT_HEADERS = \ # Libraries targets LIB = libMEDWrapperBase.la -LIB_SRC = MED_Wrapper.cxx MED_Algorithm.cxx MED_Utilities.cxx +LIB_SRC = \ + MED_Structures.cxx MED_Wrapper.cxx \ + MED_Algorithm.cxx MED_Utilities.cxx # Executables targets BIN = diff --git a/src/MEDWrapper/Factory/MED_Factory.hxx b/src/MEDWrapper/Factory/MED_Factory.hxx index 3bdb2ae72..ba2116894 100644 --- a/src/MEDWrapper/Factory/MED_Factory.hxx +++ b/src/MEDWrapper/Factory/MED_Factory.hxx @@ -33,8 +33,6 @@ namespace MED{ - enum EVersion {eVUnknown = -1, eV2_1, eV2_2}; - EVersion GetVersionId(const std::string& theFileName); PWrapper CrWrapper(const std::string& theFileName); diff --git a/src/MEDWrapper/Factory/MED_Test.cxx b/src/MEDWrapper/Factory/MED_Test.cxx index e7c894090..2167c17cb 100644 --- a/src/MEDWrapper/Factory/MED_Test.cxx +++ b/src/MEDWrapper/Factory/MED_Test.cxx @@ -61,11 +61,11 @@ void CheckMed(const std::string& theFileName) TEntityInfo aEntityInfo = aMed->GetEntityInfo(aMeshInfo); - TCellGroup aCellGroup = GetCellsByEntity(aMed,aMeshInfo,aEntityInfo); + TElemGroup aElemGroup = GetElemsByEntity(aMed,aMeshInfo,aEntityInfo); TFamilyGroup aFamilyGroup = GetFamilies(aMed,aMeshInfo); - TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aCellGroup,aFamilyGroup); + TFamilyByEntity aFamilyByEntity = GetFamiliesByEntity(aMed,aNodeInfo,aElemGroup,aFamilyGroup); TGroupInfo aGroupInfo = GetFamiliesByGroup(aFamilyGroup); @@ -166,6 +166,9 @@ void CopyMed(const PWrapper& theMed, TInt aNbGroup = aFamilyInfo->GetNbGroup(); TInt aNbAttr = aFamilyInfo->GetNbAttr(); TInt anId = aFamilyInfo->GetId(); + if(anId == 0) + continue; + aName = aFamilyInfo->GetName(); INITMSG(MYDEBUG,"aName = '"<GetPNodeInfo(aMeshInfo); - TInt aNbNodes = aNodeInfo->GetNbElem(); - INITMSG(MYDEBUG,"GetNodeInfo - aNbNodes = "<myCoord; - for(TInt iNode = 0; iNode < aNbNodes; iNode++){ - for(TInt iDim = 0, anId = iNode*aDim; iDim < aDim; iDim++, anId++){ - ADDMSG(MYVALUEDEBUG,aCoord[anId]<<","); - aCoord[anId] += theIncr; - } - ADDMSG(MYVALUEDEBUG," "); - } - ADDMSG(MYDEBUG,endl); PNodeInfo aNodeInfo2 = theMed->CrNodeInfo(aMeshInfo2,aNodeInfo); if(MYWRITEDEBUG) theMed2->SetNodeInfo(aNodeInfo2); continue; @@ -214,17 +206,63 @@ void CopyMed(const PWrapper& theMed, const EGeometrieElement& aGeom = anTGeomIter->first; const TInt& aNbElem = anTGeomIter->second; INITMSG(MYDEBUG,"aGeom = "<GetPCellInfo(aMeshInfo,anEntity,aGeom); - TInt aConnDim = aCellInfo->GetConnDim(); - for(TInt iElem = 0; iElem < aNbElem; iElem++){ - for(TInt iConn = 0; iConn < aConnDim; iConn++){ - ADDMSG(MYVALUEDEBUG,aCellInfo->GetConn(iElem,iConn)<<","); + switch(aGeom){ + case ePOLYGONE: + { + PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom); + TElemNum aConn = aPolygoneInfo->GetConnectivite(); + TElemNum aIndex = aPolygoneInfo->GetIndex(); + TInt aNbIndex = aIndex.size(); + TInt aIndex0 = aIndex[0]; + for(TInt iElem = 1; iElem < aNbIndex; iElem++){ + for (TInt i = aIndex0; i < aIndex[iElem];i++) + ADDMSG(MYVALUEDEBUG,aConn[i-1]<<","); + ADDMSG(MYDEBUG," "); + aIndex0 = aIndex[iElem]; + } + ADDMSG(MYDEBUG,endl); + INITMSG(MYDEBUG,"Indexes :"); + for(TInt iElem = 0; iElem < aIndex.size(); iElem++){ + ADDMSG(MYVALUEDEBUG,aIndex[iElem]<<","); + } + ADDMSG(MYDEBUG,endl); + PPolygoneInfo aPolygoneInfo2 = theMed->CrPolygoneInfo(aMeshInfo2,aPolygoneInfo); + if(MYWRITEDEBUG) theMed2->SetPolygoneInfo(aPolygoneInfo2); + break; + } + case ePOLYEDRE: + { + PPolyedreInfo aPolyedreInfo = theMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom); + TElemNum aConn = aPolyedreInfo->GetConnectivite(); + TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex(); + TElemNum aIndex = aPolyedreInfo->GetIndex(); + + TInt aNbIndex = aIndex.size(); + + for (int aNp = 0; aNp < aNbIndex-1;aNp++){ + if (aPolyedreInfo->IsElemNames()) + ADDMSG(MYDEBUG,aPolyedreInfo->GetElemName(aNp)<CrPolyedreInfo(aMeshInfo2,aPolyedreInfo); + if(MYWRITEDEBUG) theMed2->SetPolyedreInfo(aPolyedreInfo2); + break; } - ADDMSG(MYVALUEDEBUG," "); + default: + PCellInfo aCellInfo = theMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); + PCellInfo aCellInfo2 = theMed2->CrCellInfo(aMeshInfo2,aCellInfo); + if(MYWRITEDEBUG) theMed2->SetCellInfo(aCellInfo2); } - ADDMSG(MYDEBUG,endl); - PCellInfo aCellInfo2 = theMed->CrCellInfo(aMeshInfo2,aCellInfo); - if(MYWRITEDEBUG) theMed2->SetCellInfo(aCellInfo2); } } @@ -238,7 +276,7 @@ void CopyMed(const std::string& theFileName, MED::EVersion theVersion, int theNbCopy) { - MSG(MYDEBUG,"CopyMed - theFileName = '"<(theMeshInfo); - return MEDnEntMaa(myFile->Id(), - &aMeshInfo.myName[0], - MED_COOR, - MED_NOEUD, - med_geometrie_element(0), - med_connectivite(0)); + TInt aRet = MEDnEntMaa(myFile->Id(), + &aMeshInfo.myName[0], + MED_COOR, + MED_NOEUD, + med_geometrie_element(0), + med_connectivite(0)); + + ADDMSG(MYDEBUG," nbnodes="< 0){ anInfo[eNOEUD][ePOINT1] = aNbElem; const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); @@ -431,9 +442,9 @@ namespace MED{ TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); for(; anIter2 != anIterEnd2; anIter2++){ const EGeometrieElement& aGeom = *anIter2; - if(TInt aNb = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr)){ - anInfo[anEntity][aGeom] = aNb; - } + aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr); + if(aNbElem > 0) + anInfo[anEntity][aGeom] = aNbElem; } } } @@ -454,9 +465,9 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); - med_connectivite& aConn = static_cast(theTConn); + med_entite_maillage anEntity = med_entite_maillage(theTEntity); + med_geometrie_element aGeom = med_geometrie_element(theTGeom); + med_connectivite aConn = med_connectivite(theTConn); return MEDnEntMaa(myFile->Id(), &aMeshInfo.myName[0], diff --git a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.hxx b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.hxx index 7314d386b..0b903b74e 100644 --- a/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.hxx +++ b/src/MEDWrapper/V2_1/MED_V2_1_Wrapper.hxx @@ -36,19 +36,19 @@ namespace MED{ const TInt PNOM = 8; - typedef MED::TTMeshInfo TVMeshInfo; + typedef MED::TTMeshInfo TVMeshInfo; - typedef MED::TTFamilyInfo TVFamilyInfo; + typedef MED::TTFamilyInfo TVFamilyInfo; - typedef MED::TTNodeInfo TVNodeInfo; + typedef MED::TTNodeInfo TVNodeInfo; - typedef MED::TTCellInfo TVCellInfo; + typedef MED::TTCellInfo TVCellInfo; - typedef MED::TTFieldInfo TVFieldInfo; + typedef MED::TTFieldInfo TVFieldInfo; - typedef MED::TTTimeStampInfo TVTimeStampInfo; + typedef MED::TTTimeStampInfo TVTimeStampInfo; - typedef MED::TTTimeStampVal TVTimeStampVal; + typedef MED::TTTimeStampVal TVTimeStampVal; //--------------------------------------------------------------- class TFile; @@ -57,7 +57,8 @@ namespace MED{ typedef enum {eLECT, eECRI, eREMP} EModeAcces; //--------------------------------------------------------------- - class TVWrapper: public MED::TTWrapper{ + class TVWrapper: public MED::TTWrapper + { TVWrapper(); TVWrapper(const TVWrapper&); TVWrapper& operator=(const TVWrapper&); diff --git a/src/MEDWrapper/V2_1/Makefile.in b/src/MEDWrapper/V2_1/Makefile.in index 32939397b..1cadac2ba 100644 --- a/src/MEDWrapper/V2_1/Makefile.in +++ b/src/MEDWrapper/V2_1/Makefile.in @@ -163,4 +163,6 @@ CPPFLAGS+= $(BOOST_CPPFLAGS) $(HDF5_INCLUDES) -DPCLINUX LDFLAGS+= $(HDF5_LIBS) -lMEDWrapperBase +LDFLAGSFORBIN=$(LDFLAGS) + @CONCLUDE@ diff --git a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx index 2405e7743..60d40d48e 100644 --- a/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx +++ b/src/MEDWrapper/V2_2/MED_V2_2_Wrapper.cxx @@ -424,6 +424,293 @@ namespace MED{ SetNodeInfo(theInfo,eLECTURE_AJOUT,theErr); } + void TVWrapper::GetPolygoneInfo(MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); + med_connectivite& aConn = static_cast(theInfo.myTConn); + + TErr aRet = 0; + + aRet = MEDpolygoneConnLire(myFile->Id(), + &aMeshInfo.myName[0], + &theInfo.myIndex[0], + aNbElem+1, + &theInfo.myConn[0], + anEntity, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)"); + } + + void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + TErr* theErr) + { + SetPolygoneInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + void TVWrapper::SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TPolygoneInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); + med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); + med_connectivite& aConn = static_cast(theInfo.myTConn); + + TErr aRet = MEDpolygoneConnEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myIndex[0], + anInfo.myNbElem+1, + &anInfo.myConn[0], + anEntity, + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolygoneInfo - MEDpolygoneConnEcr(...)"); + + if (anIsElemNames){ + aRet = MEDnomEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNames[0], + anInfo.myElemNames.size(), + anEntity, + MED_POLYGONE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolygoneInfo - MEDnomEcr(...)"); + } + + if (anIsElemNum){ + aRet = MEDnumEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNum[0], + anInfo.myElemNum.size(), + anEntity, + MED_POLYGONE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolygoneInfo - MEDnumEcr(...)"); + } + + aRet = MEDfamEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myFamNum[0], + anInfo.myFamNum.size(), + anEntity, + MED_POLYGONE); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolygoneInfo - MEDfamEcr(...)"); + } + + TInt TVWrapper::GetNbPolygones(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr); + } + + TInt TVWrapper::GetNbPolygoneConn(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return 0; + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + + med_entite_maillage& anEntity = static_cast(theTEntity); + med_connectivite& aConn = static_cast(theTConn); + + med_int taille = 0; + + TErr aRet = MEDpolygoneInfo(myFile->Id(), + &aMeshInfo.myName[0], + anEntity, + aConn, + &taille); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolygoneInfo(...)"); + + return TInt(taille); + } + + void TVWrapper::GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) + return; + + MED::TMeshInfo& aMeshInfo = *theInfo.myMeshInfo; + TInt aNbElem = theInfo.myElemNum.size(); + + med_connectivite& aConn = static_cast(theInfo.myTConn); + + TErr aRet = 0; + + aRet = MEDpolyedreConnLire(myFile->Id(), + &aMeshInfo.myName[0], + &theInfo.myIndex[0], + aNbElem+1, + &theInfo.myFacesIndex[0], + theInfo.myNbFacesIndex, + &theInfo.myConn[0], + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreConnLire(...)"); + } + + void TVWrapper::SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr) + { + SetPolyedreInfo(theInfo,eLECTURE_ECRITURE,theErr); + } + + void TVWrapper::SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,theMode,theErr); + + if(theErr && !*theErr) + return; + + MED::TPolyedreInfo& anInfo = const_cast(theInfo); + MED::TMeshInfo& aMeshInfo = *anInfo.myMeshInfo; + + med_booleen& anIsElemNames = static_cast(theInfo.myIsElemNames); + med_booleen& anIsElemNum = static_cast(theInfo.myIsElemNum); + med_entite_maillage& anEntity = static_cast(theInfo.myTEntity); + med_connectivite& aConn = static_cast(theInfo.myTConn); + + TErr aRet = MEDpolyedreConnEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myIndex[0], + anInfo.myNbElem+1, + &anInfo.myFacesIndex[0], + anInfo.myNbFacesIndex, + &anInfo.myConn[0], + aConn); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDpolyedreConnEcr(...)"); + + if (anIsElemNames){ + aRet = MEDnomEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNames[0], + anInfo.myElemNames.size(), + anEntity, + MED_POLYEDRE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnomEcr(...)"); + } + + if (anIsElemNum){ + aRet = MEDnumEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myElemNum[0], + anInfo.myElemNum.size(), + anEntity, + MED_POLYEDRE); + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDnumEcr(...)"); + } + + + aRet = MEDfamEcr(myFile->Id(), + &aMeshInfo.myName[0], + &anInfo.myFamNum[0], + anInfo.myFamNum.size(), + anEntity, + MED_POLYEDRE); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"SetPolyedreInfo - MEDfamEcr(...)"); + } + + TInt TVWrapper::GetNbPolyedres(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage theTEntity, + EGeometrieElement theTGeom, + EConnectivite theTConn, + TErr* theErr) + { + return GetNbCells(theMeshInfo,theTEntity,theTGeom,theTConn,theErr); + } + + void TVWrapper::GetNbPolyedreConnF(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn, + TInt& nf, + TInt& nc, + TErr* theErr) + { + TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); + + if(theErr && !*theErr) EXCEPTION(runtime_error,"GetPolyedreInfo - (...)"); + + MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); + med_connectivite& aConn = static_cast(theTConn); + + TErr aRet = MEDpolyedreInfo(myFile->Id(), + &aMeshInfo.myName[0], + aConn, + &nf, + &nc); + + if(theErr) + *theErr = aRet; + else if(aRet < 0) + EXCEPTION(runtime_error,"GetPolygoneInfo - MEDpolyedreInfo(...)"); + + } TEntityInfo TVWrapper::GetEntityInfo(const MED::TMeshInfo& theMeshInfo, EConnectivite theTConn, @@ -433,10 +720,11 @@ namespace MED{ TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); - if(theErr && !*theErr) + if(theErr && *theErr < 0) return anInfo; - if(TInt aNbElem = GetNbNodes(theMeshInfo)){ + TInt aNbElem = GetNbNodes(theMeshInfo); + if(aNbElem > 0){ anInfo[eNOEUD][ePOINT1] = aNbElem; const TEntity2GeomSet& anEntity2GeomSet = GetEntity2GeomSet(); TEntity2GeomSet::const_iterator anIter = anEntity2GeomSet.begin(); @@ -448,9 +736,9 @@ namespace MED{ TGeomSet::const_iterator anIterEnd2 = aGeomSet.end(); for(; anIter2 != anIterEnd2; anIter2++){ const EGeometrieElement& aGeom = *anIter2; - if(TInt aNb = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr)){ - anInfo[anEntity][aGeom] = aNb; - } + aNbElem = GetNbCells(theMeshInfo,anEntity,aGeom,theTConn,theErr); + if(aNbElem > 0) + anInfo[anEntity][aGeom] = aNbElem; } } } @@ -471,9 +759,9 @@ namespace MED{ MED::TMeshInfo& aMeshInfo = const_cast(theMeshInfo); - med_entite_maillage& anEntity = static_cast(theTEntity); - med_geometrie_element& aGeom = static_cast(theTGeom); - med_connectivite& aConn = static_cast(theTConn); + med_entite_maillage anEntity = med_entite_maillage(theTEntity); + med_geometrie_element aGeom = med_geometrie_element(theTGeom); + med_connectivite aConn = med_connectivite(theTConn); return MEDnEntMaa(myFile->Id(), &aMeshInfo.myName[0], @@ -485,7 +773,7 @@ namespace MED{ void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, - TErr* theErr) + TErr* theErr) { TFileWrapper aFileWrapper(myFile,eLECTURE,theErr); @@ -558,7 +846,7 @@ namespace MED{ if(theErr) *theErr = aRet; else if(aRet < 0) - EXCEPTION(runtime_error,"GetCellInfo - MEDelementsLire(...)"); + EXCEPTION(runtime_error,"SetCellInfo - MEDelementsLire(...)"); } @@ -681,13 +969,15 @@ namespace MED{ TGeom::const_iterator anGeomIter = aTGeom.begin(); for(; anGeomIter != aTGeom.end(); anGeomIter++){ const med_geometrie_element& aGeom = static_cast(anGeomIter->first); - aNbTimeStamps = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); - if(aNbTimeStamps){ + TInt aTmp = MEDnPasdetemps(myFile->Id(),&anInfo.myName[0],anEntity,aGeom); + aNbTimeStamps = max(aTmp,aNbTimeStamps); + BEGMSG(MYDEBUG,"GetNbTimeStamps aNbTimeStamps="<second; } } - if(aNbTimeStamps) + if(!theGeom.empty()) break; } return aNbTimeStamps; @@ -810,8 +1100,10 @@ namespace MED{ aTimeStampInfo.myNumDt, aTimeStampInfo.myNumOrd); if(aRet >= 0) - for(TInt i = 0; i < iEnd; i++) + for(TInt i = 0; i < iEnd; i++) { aValue[i] = anArray[i]; + MSG(MYDEBUG," "< TVMeshInfo; + typedef MED::TTMeshInfo TVMeshInfo; - typedef MED::TTFamilyInfo TVFamilyInfo; + typedef MED::TTFamilyInfo TVFamilyInfo; - typedef MED::TTNodeInfo TVNodeInfo; + typedef MED::TTNodeInfo TVNodeInfo; - typedef MED::TTCellInfo TVCellInfo; + typedef MED::TTCellInfo TVCellInfo; - typedef MED::TTFieldInfo TVFieldInfo; + typedef MED::TTFieldInfo TVFieldInfo; - typedef MED::TTTimeStampInfo TVTimeStampInfo; + typedef MED::TTTimeStampInfo TVTimeStampInfo; - typedef MED::TTTimeStampVal TVTimeStampVal; + typedef MED::TTTimeStampVal TVTimeStampVal; //--------------------------------------------------------------- class TFile; @@ -58,7 +58,7 @@ namespace MED{ typedef enum {eLECTURE, eLECTURE_ECRITURE, eLECTURE_AJOUT, eCREATION} EModeAcces; //--------------------------------------------------------------- - class TVWrapper: public MED::TTWrapper{ + class TVWrapper: public MED::TTWrapper{ TVWrapper(); TVWrapper(const TVWrapper&); TVWrapper& operator=(const TVWrapper&); @@ -67,119 +67,233 @@ namespace MED{ TVWrapper(const std::string& theFileName); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbMeshes(TErr* theErr = NULL); + virtual + TInt + GetNbMeshes(TErr* theErr = NULL); - virtual void GetMeshInfo(TInt theMeshId, MED::TMeshInfo&, + virtual + void + GetMeshInfo(TInt theMeshId, MED::TMeshInfo&, TErr* theErr = NULL); - virtual void SetMeshInfo(const MED::TMeshInfo& theInfo, - TErr* theErr = NULL); + virtual + void + SetMeshInfo(const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); void SetMeshInfo(const MED::TMeshInfo& theInfo, EModeAcces theMode, TErr* theErr = NULL); - + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbFamilies(const MED::TMeshInfo& theMeshInfo, - TErr* theErr = NULL); + virtual + TInt + GetNbFamilies(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); - virtual TInt GetNbFamAttr(TInt theFamId, - const MED::TMeshInfo& theInfo, - TErr* theErr = NULL); - - virtual TInt GetNbFamGroup(TInt theFamId, - const MED::TMeshInfo& theInfo, - TErr* theErr = NULL); + virtual + TInt + GetNbFamAttr(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); - virtual void GetFamilyInfo(TInt theFamId, - MED::TFamilyInfo& theInfo, - TErr* theErr = NULL); - - virtual void SetFamilyInfo(const MED::TFamilyInfo& theInfo, - TErr* theErr = NULL); + virtual + TInt + GetNbFamGroup(TInt theFamId, + const MED::TMeshInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetFamilyInfo(TInt theFamId, + MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + TErr* theErr = NULL); + + void + SetFamilyInfo(const MED::TFamilyInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); - void SetFamilyInfo(const MED::TFamilyInfo& theInfo, - EModeAcces theMode, - TErr* theErr = NULL); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbNodes(const MED::TMeshInfo& theMeshInfo, - TErr* theErr = NULL); + virtual + TInt + GetNbNodes(const MED::TMeshInfo& theMeshInfo, + TErr* theErr = NULL); - virtual void GetNodeInfo(MED::TNodeInfo& theInfo, - TErr* theErr = NULL); + virtual + void + GetNodeInfo(MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + TErr* theErr = NULL); + + void + SetNodeInfo(const MED::TNodeInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + void + GetPolygoneInfo(TPolygoneInfo& theInfo, + TErr* theErr = NULL); - virtual void SetNodeInfo(const MED::TNodeInfo& theInfo, - TErr* theErr = NULL); + virtual + void + SetPolygoneInfo(const TPolygoneInfo& theInfo, + TErr* theErr = NULL); - void SetNodeInfo(const MED::TNodeInfo& theInfo, - EModeAcces theMode, - TErr* theErr = NULL); + void + SetPolygoneInfo(const MED::TPolygoneInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + virtual + TInt + GetNbPolygones(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + virtual + TInt + GetNbPolygoneConn(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TEntityInfo GetEntityInfo(const MED::TMeshInfo& theMeshInfo, - EConnectivite theTConn = eNOD, - TErr* theErr = NULL); + virtual + void + GetPolyedreInfo(TPolyedreInfo& theInfo, + TErr* theErr = NULL); - virtual TInt GetNbCells(const MED::TMeshInfo& theMeshInfo, - EEntiteMaillage, - EGeometrieElement, - EConnectivite theTConn = eNOD, - TErr* theErr = NULL); + virtual + void + SetPolyedreInfo(const TPolyedreInfo& theInfo, + TErr* theErr = NULL); - virtual void GetCellInfo(MED::TCellInfo& theInfo, - TErr* theErr = NULL); - - virtual void SetCellInfo(const MED::TCellInfo& theInfo, - TErr* theErr = NULL); + void + SetPolyedreInfo(const MED::TPolyedreInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); - void SetCellInfo(const MED::TCellInfo& theInfo, - EModeAcces theMode, - TErr* theErr = NULL); - + virtual + TInt + GetNbPolyedres(const TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite, + TErr* theErr = NULL); + + virtual + void + GetNbPolyedreConnF(const TMeshInfo& theMeshInfo, + EConnectivite, + TInt& nf, + TInt& nc, + TErr* theErr = NULL); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbFields(TErr* theErr = NULL); + virtual + TEntityInfo + GetEntityInfo(const MED::TMeshInfo& theMeshInfo, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); - virtual TInt GetNbComp(TInt theFieldId, - TErr* theErr = NULL); + virtual + TInt + GetNbCells(const MED::TMeshInfo& theMeshInfo, + EEntiteMaillage, + EGeometrieElement, + EConnectivite theTConn = eNOD, + TErr* theErr = NULL); - virtual void GetFieldInfo(TInt theFieldId, - MED::TFieldInfo& theInfo, - TErr* theErr = NULL); + virtual + void + GetCellInfo(MED::TCellInfo& theInfo, + TErr* theErr = NULL); - virtual void SetFieldInfo(const MED::TFieldInfo& theInfo, - TErr* theErr = NULL); + virtual + void + SetCellInfo(const MED::TCellInfo& theInfo, + TErr* theErr = NULL); + + void + SetCellInfo(const MED::TCellInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); - void SetFieldInfo(const MED::TFieldInfo& theInfo, - EModeAcces theMode, - TErr* theErr = NULL); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - virtual TInt GetNbTimeStamps(const MED::TFieldInfo& theInfo, - const MED::TEntityInfo& theEntityInfo, - EEntiteMaillage& theEntity, - TGeom& theGeom, - TErr* theErr = NULL); + virtual + TInt + GetNbFields(TErr* theErr = NULL); - virtual void GetTimeStampInfo(TInt theTimeStampId, - MED::TTimeStampInfo& theInfo, - TErr* theErr = NULL); - - virtual void GetTimeStampVal(MED::TTimeStampVal& theVal, - TErr* theErr = NULL); + virtual + TInt + GetNbComp(TInt theFieldId, + TErr* theErr = NULL); - virtual void SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, - TErr* theErr = NULL); + virtual + void + GetFieldInfo(TInt theFieldId, + MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + TErr* theErr = NULL); + + void + SetFieldInfo(const MED::TFieldInfo& theInfo, + EModeAcces theMode, + TErr* theErr = NULL); + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + virtual + TInt + GetNbTimeStamps(const MED::TFieldInfo& theInfo, + const MED::TEntityInfo& theEntityInfo, + EEntiteMaillage& theEntity, + TGeom& theGeom, + TErr* theErr = NULL); + + virtual + void + GetTimeStampInfo(TInt theTimeStampId, + MED::TTimeStampInfo& theInfo, + TErr* theErr = NULL); + + virtual + void + GetTimeStampVal(MED::TTimeStampVal& theVal, + TErr* theErr = NULL); + + virtual + void + SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + TErr* theErr = NULL); + + void + SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, + EModeAcces theMode, + TErr* theErr = NULL); - void SetTimeStamp(const MED::TTimeStampVal& theTimeStampVal, - EModeAcces theMode, - TErr* theErr = NULL); - protected: PFile myFile; }; diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index ad729c45a..73e9ffaa0 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -40,7 +40,7 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, PortableServer::POA_ptr poa, char * containerName, int argc, char *argv[]) - : Engines_Container_i(orb,poa,containerName,argc,argv,false,false), MPIObject_i(nbproc,numproc) + : Engines_Container_i(orb,poa,containerName,argc,argv,false), MPIObject_i(nbproc,numproc) { MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); diff --git a/src/MSG2QM/Makefile.in b/src/MSG2QM/Makefile.in index 0cf36702e..a77f47893 100644 --- a/src/MSG2QM/Makefile.in +++ b/src/MSG2QM/Makefile.in @@ -38,5 +38,6 @@ BIN_SRC = CPPFLAGS+=$(QT_INCLUDES) $(OGL_INCLUDES) LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) +LDFLAGSFORBIN=$(LDFLAGS) @CONCLUDE@ diff --git a/src/Makefile.in b/src/Makefile.in index 2cca687df..91f81257e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -36,7 +36,7 @@ ifeq (@WITHIHM@,yes) SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch PatchQt \ GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ - Notification NOTIFICATION_SWIG \ + ResourcesManager Notification NOTIFICATION_SWIG \ Container TestContainer LifeCycleCORBA HDFPersist Prs \ VTKFilter OBJECT \ TOOLSDS SALOMEDS Event \ @@ -50,7 +50,7 @@ ifeq (@WITHIHM@,no) SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch \ GenericObj NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ - Notification NOTIFICATION_SWIG \ + ResourcesManager Notification NOTIFICATION_SWIG \ Container TestContainer LifeCycleCORBA HDFPersist Prs \ TOOLSDS SALOMEDS Event \ SALOME_SWIG_WITHOUTIHM ModuleGenerator Loader Communication diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index 0ba61bbaa..bc4a90bab 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -62,6 +62,7 @@ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) -LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 9a5fb15ce..ad8cdd43d 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -48,7 +48,7 @@ int main(int argc,char **argv) // initialize POA // - long TIMESleep = 250000000; + long TIMESleep = 500000000; int NumberOfTries = 40; int a; timespec ts_req; diff --git a/src/NamingService/NamingService_WaitForServerReadiness.cxx b/src/NamingService/NamingService_WaitForServerReadiness.cxx index b2ba19a51..7cb1a6bce 100644 --- a/src/NamingService/NamingService_WaitForServerReadiness.cxx +++ b/src/NamingService/NamingService_WaitForServerReadiness.cxx @@ -37,7 +37,7 @@ using namespace std; * \param serverName name of the server to find. * \param NS SALOME_NamingService object * Wait until the given server is ready i.e. is name is found in namingService. - * Try 40 times, with 250 ms sleep between each try. + * Try 40 times, with 500 ms sleep between each try. * If Logger is used for traces, it must be ready before this call, because * SALOME_NamingService client uses SALOME traces. So, Logger readiness must be * checked in Launch script before execution of WaitForServerReadiness. @@ -48,8 +48,8 @@ using namespace std; void NamingService_WaitForServerReadiness(SALOME_NamingService* NS, string serverName) { - long TIMESleep = 250000000; // 250 ms. - int NumberOfTries = 40; // total wait = 10 s. + long TIMESleep = 500000000; // 500 ms. + int NumberOfTries = 40; // total wait = 20 s. int found = 0; timespec ts_req; diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 07b0e9342..2db7a59b5 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -645,7 +645,7 @@ char* SALOME_NamingService::Current_Directory() // the directories length_path = length_path + strlen(result_path[k]) + 1; } - char* return_Path = new char[length_path +1]; + char* return_Path = new char[length_path +2]; return_Path[0] = '/' ; return_Path[1] = '\0' ; for (int k = 0 ; k SALOME_NamingService::list_directory() return _list; } +//---------------------------------------------------------------------- +/*! Function : list_directory_recurs + * Purpose : method to get all the contexts contained in the current + * directory + * Get only objects and is recursive + * If the NamingService is out, the exception ServiceUnreachable is thrown + */ +//---------------------------------------------------------------------- +vector SALOME_NamingService::list_directory_recurs() + throw(ServiceUnreachable) +{ + vector _list ; + char *currentDir=Current_Directory(); + _list_directory_recurs(_list,0,currentDir); + delete [] currentDir; + return _list; +} //---------------------------------------------------------------------- /*! Function : Destroy_Name @@ -1310,4 +1327,58 @@ SALOME_NamingService::_current_directory(char** result_path, // We go to the last directory where an occurence was found _current_context = _ref_context ; } + + +//---------------------------------------------------------------------- +/*! Function :_list_directory_recurs. + * Purpose : method to list recursively all the objects contained in the tree of absCurDirectory/relativeSubDir. + * \param myList The list that will be filled. + * \param relativeSubDir The directory from absCurDirectory in which the objects are found. + * \param absCurDirectory The directory in ABSOLUTE form. + * _current_context must refer to absCurDirectory. + */ +//---------------------------------------------------------------------- +void SALOME_NamingService::_list_directory_recurs(vector& myList, const char *relativeSubDir,const char *absCurDirectory) +{ + CosNaming::BindingList_var _binding_list; + CosNaming::BindingIterator_var _binding_iterator; + unsigned long nb=0 ; // for using only the BindingIterator to access the bindings + CosNaming::Binding_var _binding ; + char *absDir; + + CosNaming::NamingContext_var _ref_context = _current_context; + if(relativeSubDir) + { + Change_Directory(relativeSubDir); + absDir=new char[strlen(absCurDirectory)+2+strlen(relativeSubDir)]; + strcpy(absDir,absCurDirectory); + strcat(absDir,relativeSubDir); + strcat(absDir,"/"); + } + else + absDir=(char *)absCurDirectory; + _current_context->list(nb, _binding_list, _binding_iterator) ; + + while (_binding_iterator->next_one(_binding)) { + CosNaming::Name _bindingName = _binding->binding_name; + if (_binding->binding_type == CosNaming::ncontext) { + _list_directory_recurs(myList,_bindingName[0].id,absDir); + } + else if (_binding->binding_type == CosNaming::nobject) { + char *elt=new char[strlen(absDir)+2+strlen(_bindingName[0].id)]; + strcpy(elt,absDir); + strcat(elt,_bindingName[0].id); + myList.push_back(elt); + delete [] elt; + } + } + if(relativeSubDir) + { + _current_context = _ref_context ; + delete [] absDir; + } + + _binding_iterator->destroy(); +} + //---------------------------------------------------------------------- diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 4504e6ec7..e6ee89213 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -84,6 +84,10 @@ public: // Get only objects, isn't iterative std::vector list_directory() throw(ServiceUnreachable); + + //!methods that lists all objects RECUSIVELY in the current directory + std::vector list_directory_recurs() + throw(ServiceUnreachable); //! method to destroy an association Path-Object Reference void Destroy_Name(const char* Path) @@ -120,6 +124,10 @@ protected: int& length_result, CosNaming::NamingContext_var context_to_found, CORBA::Boolean& _continue); + + //! internal method to list all (recursively) the objects contains in absCurDirectory/relativeSubDir. + void _list_directory_recurs(std::vector& myList, const char *relativeSubDir,const char *absCurDirectory); + }; #endif // SALOME_NAMINGSERVICE_H diff --git a/src/OCCViewer/Makefile.in b/src/OCCViewer/Makefile.in index 55719f6e8..669b4f8ca 100644 --- a/src/OCCViewer/Makefile.in +++ b/src/OCCViewer/Makefile.in @@ -39,6 +39,7 @@ LIB_MOC = \ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl diff --git a/src/Plot2d/Makefile.in b/src/Plot2d/Makefile.in index 375a786b0..ca9f91bf1 100644 --- a/src/Plot2d/Makefile.in +++ b/src/Plot2d/Makefile.in @@ -43,6 +43,7 @@ LIB_MOC = \ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in index cbcbf3931..8b5eb524c 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -53,6 +53,8 @@ BIN = SALOME_Registry_Server BIN_SRC = BIN_SERVER_IDL = SALOME_Registry.idl -LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace + +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in index b43546776..17f8c42af 100644 --- a/src/RessourcesCatalog/Makefile.in +++ b/src/RessourcesCatalog/Makefile.in @@ -54,7 +54,8 @@ BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in index 41c222733..5a4adbf4e 100644 --- a/src/SALOMEDS/Makefile.in +++ b/src/SALOMEDS/Makefile.in @@ -113,14 +113,14 @@ LIB_SRC = \ # Executables targets BIN = SALOMEDS_Server SALOMEDS_Client BIN_SRC = -LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl +LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_ContainerManager.idl BIN_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl BIN_CLIENT_IDL = LIB_CLIENT_IDL = SALOME_Component.idl SALOME_GenericObj.idl CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA +LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOMELocalTrace $(CAS_LDPATH) -lTKCAF -lTKBO -lTKStdSchema -lSalomeGenericObj -lSalomeLifeCycleCORBA -lSalomeContainer -lSalomeResourcesManager # _CS_gbo_090604 Ajout Spécifique Calibre 3, pour l'utilisation de la version 5.12 de la bibliothèque OCC. # La bibliothèque OCC5.12 a été compilée sur Calibre 3 avec l'extention Xmu (impossible de compiler sans). @@ -129,7 +129,7 @@ LDFLAGS+= $(HDF5_LIBS) -lTOOLSDS -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSALOME # LDXMUFLAGS= -L/usr/X11R6/lib -lXmu LDFLAGS+=$(LDXMUFLAGS) - +LDFLAGSFORBIN= $(LDFLAGS) -lRegistry -lSalomeNotification -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx index be6969df4..dec61d358 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx @@ -44,13 +44,12 @@ char* SALOMEDS_AttributeIOR_i::Value() void SALOMEDS_AttributeIOR_i::SetValue(const char* value) { CheckLocked(); - const CORBA::ORB_var& anORB = _mySObject->GetORB(); - SALOMEDS::Study_var aStudy = SALOMEDS_Study_i::GetStudy(_myAttr->Label(),anORB); + SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant(); aStudy->AddCreatedPostponed(value); aStudy->AddPostponed(Value()); CORBA::String_var Str = CORBA::string_dup(value); Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); - SALOMEDS_Study_i::IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr),anORB); + aStudy->IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr)); } diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx index 6396ada74..d256bb669 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@ -46,8 +46,6 @@ SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(SALOMEDS_Study_i* theStudy, _lab(theLabel), _study(theStudy) { - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theLabel,anEntry); } //============================================================================ @@ -66,7 +64,7 @@ SALOMEDS_ChildIterator_i::~SALOMEDS_ChildIterator_i() //============================================================================ void SALOMEDS_ChildIterator_i::Init() { - _it.Initialize (_lab); + _it.Initialize(_lab); } //============================================================================ @@ -74,9 +72,9 @@ void SALOMEDS_ChildIterator_i::Init() * */ //============================================================================ -void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean allLevels) +void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean theIsAllLevels) { - _it.Initialize (_lab, allLevels); + _it.Initialize(_lab,theIsAllLevels); } //============================================================================ @@ -97,8 +95,6 @@ CORBA::Boolean SALOMEDS_ChildIterator_i::More() void SALOMEDS_ChildIterator_i::Next() { _it.Next(); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(_it.Value(),anEntry); } @@ -113,3 +109,7 @@ SALOMEDS::SObject_ptr SALOMEDS_ChildIterator_i::Value() return SALOMEDS_SObject_i::NewRef(_study,_it.Value())._retn(); } +SALOMEDS_SObject_i* SALOMEDS_ChildIterator_i::GetValue() +{ + return SALOMEDS_SObject_i::NewPtr(_study,_it.Value()); +} diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx index 083fd9935..dc7cfbe9c 100644 --- a/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx @@ -38,6 +38,7 @@ #include class SALOMEDS_Study_i; +class SALOMEDS_SObject_i; class SALOMEDS_ChildIterator_i: public POA_SALOMEDS::ChildIterator, public PortableServer::RefCountServantBase @@ -57,7 +58,7 @@ public: ~SALOMEDS_ChildIterator_i(); - TDF_Label GetValue() { return _it.Value();} + SALOMEDS_SObject_i* GetValue(); virtual void Init(); virtual void InitEx(CORBA::Boolean); diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.cxx b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx index f71b538fd..b749c5464 100644 --- a/src/SALOMEDS/SALOMEDS_IORAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx @@ -26,10 +26,12 @@ // Module : SALOME // $Header$ -#include "SALOMEDS_IORAttribute.ixx" #include #include + +#include "SALOMEDS_IORAttribute.ixx" #include "SALOMEDS_Study_i.hxx" + using namespace std; //======================================================================= @@ -52,7 +54,7 @@ const Standard_GUID& SALOMEDS_IORAttribute::GetID () Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L, const TCollection_ExtendedString& S, - CORBA::ORB_ptr orb) + SALOMEDS_Study_i* theStudy) { Handle(SALOMEDS_IORAttribute) A; if (!L.FindAttribute(SALOMEDS_IORAttribute::GetID(),A)) { @@ -61,7 +63,7 @@ Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L, } (Handle(TDataStd_Comment)::DownCast(A))->Set (S); - SALOMEDS_Study_i::IORUpdated(A,orb); + theStudy->IORUpdated(A); return A; } diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.hxx b/src/SALOMEDS/SALOMEDS_IORAttribute.hxx index 5bd63c9ad..8f9fd314a 100644 --- a/src/SALOMEDS/SALOMEDS_IORAttribute.hxx +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.hxx @@ -54,7 +54,7 @@ class TDF_Label; class TCollection_ExtendedString; class TDF_Attribute; class TDF_RelocationTable; - +class SALOMEDS_Study_i; class SALOMEDS_IORAttribute : public TDataStd_Comment { @@ -79,7 +79,9 @@ public: // Methods PUBLIC // Standard_EXPORT static const Standard_GUID& GetID() ; -Standard_EXPORT static Handle_SALOMEDS_IORAttribute Set(const TDF_Label& label,const TCollection_ExtendedString& string, CORBA::ORB_ptr orb) ; +Standard_EXPORT static Handle_SALOMEDS_IORAttribute Set(const TDF_Label& label, + const TCollection_ExtendedString& string, + SALOMEDS_Study_i* theStudy) ; Standard_EXPORT SALOMEDS_IORAttribute(); Standard_EXPORT const Standard_GUID& ID() const; Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 5d6e16382..5f5ddded8 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -286,12 +286,14 @@ SALOMEDS_SObject_i::New(SALOMEDS_Study_i* theStudy, if(anIter != anSObjectMap.end()) aSObjectHolder = anIter->second; else{ - TCollection_AsciiString anEntry; - TDF_Tool::Entry(theLabel,anEntry); SALOMEDS_SObject_i* aSObject = new SALOMEDS_SObject_i(theStudy,theLabel); aSObjectHolder.first = aSObject; aSObjectHolder.second = aSObject->_this(); anSObjectMap[theLabel] = aSObjectHolder; + + //TCollection_AsciiString anEntry; + //TDF_Tool::Entry(theLabel,anEntry); + //cout<<"APO - SALOMEDS_SObject_i::New - anEntry = "<ID(); TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID); - if(anIter != __GUID2AttrIDMap__.end()) - { - const ::TAttributeID& anAttributeID = anIter->second; - TAttrMap::const_iterator anIter = myAttrMap.find(anAttributeID); - if(anIter != myAttrMap.end()) - anGenAttr = anIter->second; - - if(anGenAttr != NULL){ - if(anGenAttr->GetAttribute() != theAttr) - anGenAttr->SetAttribute(theAttr); - }else{ - anGenAttr = _CreateGenAttribute(theAttr,anAttributeID.c_str()); - } + if(anIter != __GUID2AttrIDMap__.end()){ + const TAttributeID& anAttributeID = anIter->second; + anGenAttr = _FindGenAttribute(anAttributeID.c_str()); } return anGenAttr; @@ -559,10 +551,12 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() Standard_Integer i = 0; for(TDF_AttributeIterator iter(_lab); iter.More(); iter.Next()) { Handle(TDF_Attribute) anAttr = iter.Value(); - if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(anAttr)) + TAttrHolder anAttrHolder = _FindGenAttribute(anAttr); + SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second; + if(!anGenAttr->_is_nil()) { aSeqOfAttr->length(++i); - aSeqOfAttr[i-1] = anGenAttr->_this(); + aSeqOfAttr[i-1] = anGenAttr._retn(); } } } @@ -576,11 +570,11 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() * Purpose : Find attribute of given type on this SObject */ //============================================================================ -SALOMEDS_GenericAttribute_i* +SALOMEDS_SObject_i::TAttrHolder SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr, const char* theType) { - + SALOMEDS_GenericAttribute_i* anAttr; TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType); if(anIter != __AttrID2FunMap__.end()){ const TAttrID2FunMap::data_type& aValue = anIter->second; @@ -588,56 +582,66 @@ SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr, if(aValue.myIsCheckLockedStudy()) _study->CheckLocked(); - return aValue.myNewInstance(theAttr,this); + anAttr = aValue.myNewInstance(theAttr,this); + return TAttrHolder(anAttr,anAttr->_this()); } if(strncmp(theType,"AttributeTreeNode",17) == 0){ - return new SALOMEDS_AttributeTreeNode_i(theAttr,this); + anAttr = new SALOMEDS_AttributeTreeNode_i(theAttr,this); + return TAttrHolder(anAttr,anAttr->_this()); } if(strncmp(theType,"AttributeUserID",15) == 0){ - return new SALOMEDS_AttributeUserID_i(theAttr,this); + anAttr = new SALOMEDS_AttributeUserID_i(theAttr,this); + return TAttrHolder(anAttr,anAttr->_this()); } - return NULL; + return TAttrHolder(); } -SALOMEDS_GenericAttribute_i* +SALOMEDS_SObject_i::TAttrHolder SALOMEDS_SObject_i::_FindGenAttribute(const char* theType) { - SALOMEDS_GenericAttribute_i* anGenAttr = NULL; + TAttrHolder anAttrHolder; TAttrMap::const_iterator anIter = myAttrMap.find(theType); if(anIter != myAttrMap.end()) - anGenAttr = anIter->second; + anAttrHolder = anIter->second; Standard_GUID aGUID = ::GetGUID(theType); Handle(TDF_Attribute) anAttr; if(_lab.FindAttribute(aGUID,anAttr)){ - if(anGenAttr != NULL){ - if(anGenAttr->GetAttribute() != anAttr) - anGenAttr->SetAttribute(anAttr); + SALOMEDS_GenericAttribute_i* aGenAttr = anAttrHolder.first; + if(aGenAttr != NULL){ + if(aGenAttr->GetAttribute() != anAttr) + aGenAttr->SetAttribute(anAttr); }else{ - anGenAttr = _CreateGenAttribute(anAttr,theType); + anAttrHolder = _CreateGenAttribute(anAttr,theType); } - if(anGenAttr != NULL) - myAttrMap[theType] = anGenAttr; + aGenAttr = anAttrHolder.first; + if(aGenAttr != NULL) + myAttrMap[theType] = anAttrHolder; }else{ - myAttrMap.erase(theType); + //myAttrMap.erase(theType); //if(anGenAttr != NULL) // anGenAttr->Destroy(); + return TAttrHolder(); } - return anGenAttr; + return anAttrHolder; } SALOMEDS::GenericAttribute_ptr SALOMEDS_SObject_i::_FindCORBAAttribute(const char* theType) { - if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType)) - return anGenAttr->_this(); + TAttrHolder anAttr = _FindGenAttribute(theType); + SALOMEDS::GenericAttribute_var anGenAttr = anAttr.second; + if(!CORBA::is_nil(anGenAttr)){ + return anGenAttr._retn(); + } + return SALOMEDS::GenericAttribute::_nil(); } @@ -707,14 +711,19 @@ Handle(TDF_Attribute) SALOMEDS::GenericAttribute_ptr SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType) { - if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType)) - return anGenAttr->_this(); + TAttrHolder anAttrHolder = _FindGenAttribute(theType); + SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second; + if(!anGenAttr->_is_nil()) + return anGenAttr._retn(); + Handle(TDF_Attribute) anAttr = _AddAttribute(theType); if(!anAttr.IsNull()){ - if(SALOMEDS_GenericAttribute_i* anGenAttr = _CreateGenAttribute(anAttr,theType)){ - return anGenAttr->_this(); - } + anAttrHolder = _CreateGenAttribute(anAttr,theType); + anGenAttr = anAttrHolder.second; + if(!anGenAttr->_is_nil()) + return anGenAttr._retn(); } + return SALOMEDS::GenericAttribute::_nil(); } @@ -736,8 +745,28 @@ void SALOMEDS_SObject_i::RemoveAttribute(const char* theType) } TAttrMap::iterator anIter = myAttrMap.find(theType); if(anIter != myAttrMap.end()){ - myAttrMap.erase(anIter); + //myAttrMap.erase(anIter); } _lab.ForgetAttribute(::GetGUID(theType)); } + +void SALOMEDS_SObject_i::OnRemove() +{ + Handle(TDF_Reference) aReference; + if(_lab.FindAttribute(TDF_Reference::GetID(),aReference)){ + Handle(SALOMEDS_TargetAttribute) aTarget; + if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) + aTarget->Remove(_lab); + } + + Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects + if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){ + _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); + } + + //myAttrMap.clear(); + + //SALOMEDS_Study_i::TSObjectMap& anSObjectMap = _study->GetSObjectMap(); + //anSObjectMap.erase(_lab); +} diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx index 2f28e74c2..a4c73ce43 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -105,9 +105,12 @@ public: FindOrCreateAttribute(const char* theTypeOfAttribute); void RemoveAttribute(const char* theTypeOfAttribute); + void OnRemove(); SALOMEDS_Study_i* GetStudyServant(){ return _study;} + TDF_Label GetLabel(){ return _lab;} + CORBA::ORB_var GetORB() const; PortableServer::POA_var GetPOA() const; @@ -115,14 +118,19 @@ public: protected: friend class SALOMEDS_GenericAttribute_i; - SALOMEDS_GenericAttribute_i* + typedef std::string TAttributeID; + typedef std::pair TAttrHolder; + typedef std::map TAttrMap; + TAttrMap myAttrMap; + + TAttrHolder _FindGenAttribute(const Handle(TDF_Attribute)& theAttr); - SALOMEDS_GenericAttribute_i* + TAttrHolder _CreateGenAttribute(const Handle(TDF_Attribute)& theAttr, const char* theTypeOfAttribute); - SALOMEDS_GenericAttribute_i* + TAttrHolder _FindGenAttribute(const char* theTypeOfAttribute); SALOMEDS::GenericAttribute_ptr @@ -135,11 +143,6 @@ protected: std::string _name; TDF_Label _lab; - typedef std::string TAttributeID; - typedef SALOMEDS_GenericAttribute_i* TAttrHolder; - typedef std::map TAttrMap; - TAttrMap myAttrMap; - SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy, const TDF_Label& theLabel); diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index b0e8863bd..70919bba0 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -57,7 +57,7 @@ int main(int argc, char** argv) omniORB::MaxMessageSize(100 * 1024 * 1024); // Obtain a reference to the root POA. // - long TIMESleep = 250000000; + long TIMESleep = 500000000; int NumberOfTries = 40; int a; timespec ts_req; diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx index 143d3c0b7..c6b74d131 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -32,6 +32,7 @@ #include "SALOMEDS_SObject_i.hxx" #include "SALOMEDS_SComponent_i.hxx" +#include "SALOMEDS_ChildIterator_i.hxx" #include "SALOMEDS_TargetAttribute.hxx" #include "SALOMEDS_IORAttribute.hxx" @@ -158,7 +159,7 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr t //add theObject definition aString = GetORB()->object_to_string(theObject); - SALOMEDS_IORAttribute::Set(Lab,const_cast(aString.in()),GetORB()); + SALOMEDS_IORAttribute::Set(Lab,const_cast(aString.in()),_study); } //============================================================================ @@ -246,31 +247,26 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject) { - CheckLocked(); - - if(CORBA::is_nil(theSObject)) - return; - - OnRemoveSObject(theSObject); - - TDF_Label Lab; - CORBA::String_var aString(theSObject->GetID()); - TDF_Tool::Label(_doc->GetData(),const_cast(aString.in()),Lab); + RemoveSObject(theSObject); +} - Handle(TDF_Reference) aReference; - if(Lab.FindAttribute(TDF_Reference::GetID(),aReference)){ - Handle(SALOMEDS_TargetAttribute) aTarget; - if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) - aTarget->Remove(Lab); - } +SALOMEDS_SObject_i* +SALOMEDS_StudyBuilder_i::RemoveSObject(SALOMEDS::SObject_ptr theSObject, + bool theIsForgetAllAttributes) +{ + CheckLocked(); - Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects - if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){ - SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB()); - aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); + if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theSObject)){ + OnRemoveSObject(theSObject); + aSObject->OnRemove(); + if(theIsForgetAllAttributes){ + TDF_Label aLabel = aSObject->GetLabel(); + aLabel.ForgetAllAttributes(); + } + return aSObject; } - Lab.ForgetAllAttributes(); + return NULL; } //============================================================================ @@ -280,48 +276,15 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject) //============================================================================ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr theSObject) { - CheckLocked(); - - if(CORBA::is_nil(theSObject)) - return; - - OnRemoveSObject(theSObject); - - TDF_Label Lab; - CORBA::String_var aString(theSObject->GetID()); - TDF_Tool::Label(_doc->GetData(),aString,Lab); - - Handle(TDF_Reference) aReference; - if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) { - Handle(SALOMEDS_TargetAttribute) aTarget; - if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) - aTarget->Remove(Lab); - } - - Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects - if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){ - SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB()); - aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); - } - - TDF_ChildIterator it(Lab, Standard_True); - for(;it.More();it.Next()) { - TDF_Label aLabel = it.Value(); - - if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) { - Handle(SALOMEDS_TargetAttribute) aTarget; - if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget)) - aTarget->Remove(aLabel); - } - - Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects - if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){ - SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB()); - aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); + if(SALOMEDS_SObject_i* aSObject = RemoveSObject(theSObject,false)){ + SALOMEDS_ChildIterator_i aChildIter(_study,aSObject->GetLabel(),true); + for(; aChildIter.More(); aChildIter.Next()){ + if(SALOMEDS_SObject_i* aSObj = aChildIter.GetValue()) + aSObj->OnRemove(); } + TDF_Label aLabel = aSObject->GetLabel(); + aLabel.ForgetAllAttributes(Standard_True); } - - Lab.ForgetAllAttributes(Standard_True); } //============================================================================ @@ -331,7 +294,6 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr the //============================================================================ static void Translate_persistentID_to_IOR(TDF_Label theLabel, SALOMEDS::Driver_ptr theDriver, - CORBA::ORB_ptr theORB, SALOMEDS_Study_i* theStudy, CORBA::Boolean theIsMultiFile, CORBA::Boolean theIsASCII) @@ -354,10 +316,10 @@ static void Translate_persistentID_to_IOR(TDF_Label theLabel, CORBA::String_var anIOR = theDriver->LocalPersistentIDToIOR(aSObject,ch.ToCString(),theIsMultiFile,theIsASCII); - SALOMEDS_IORAttribute::Set (aCurrentLabel,const_cast(anIOR.in()),theORB); + SALOMEDS_IORAttribute::Set(aCurrentLabel,const_cast(anIOR.in()),theStudy); } - Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theORB,theStudy,theIsMultiFile,theIsASCII); + Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theStudy,theIsMultiFile,theIsASCII); } } @@ -387,14 +349,14 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent, if(CORBA::is_nil(theDriver)) return; - int aLocked = theSComponent->GetStudy()->GetProperties()->IsLocked(); + int aLocked = _study->GetProperties()->IsLocked(); if(aLocked) - theSComponent->GetStudy()->GetProperties()->SetLocked(false); + _study->GetProperties()->SetLocked(false); // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), Att)) { if(aLocked) - theSComponent->GetStudy()->GetProperties()->SetLocked(true); + _study->GetProperties()->SetLocked(true); return; } DefineComponentInstance (theSComponent,theDriver); @@ -496,21 +458,21 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent, SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true); } if(aLocked) - theSComponent->GetStudy()->GetProperties()->SetLocked(true); + _study->GetProperties()->SetLocked(true); THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM); } try { - Translate_persistentID_to_IOR(Lab,theDriver,GetORB(),_study, aMultifileState[0]=='M', ASCIIfileState[0] == 'A'); + Translate_persistentID_to_IOR(Lab,theDriver,_study,aMultifileState[0]=='M',ASCIIfileState[0] == 'A'); } catch (SALOME::SALOME_Exception) { INFOS("Can't translate PersRef to IOR"); if (aLocked) - theSComponent->GetStudy()->GetProperties()->SetLocked(true); + _study->GetProperties()->SetLocked(true); THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM); // throw HDFexception("Unable to load component data"); } if(aLocked) - theSComponent->GetStudy()->GetProperties()->SetLocked(true); + _study->GetProperties()->SetLocked(true); } else MESSAGE("No persistent file Name"); } @@ -536,15 +498,9 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr theObject, const char* theTypeOfAttribute) { - if(!CORBA::is_nil(theObject)){ - PortableServer::POA_var aPOA = GetPOA(); - PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,aPOA); - if(aServant.in() != NULL){ - if(SALOMEDS_SObject_i* anSObject = dynamic_cast(aServant.in())){ - return anSObject->FindOrCreateAttribute(theTypeOfAttribute); - } - } - } + if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject)) + return aSObject->FindOrCreateAttribute(theTypeOfAttribute); + return SALOMEDS::GenericAttribute::_nil(); } @@ -558,14 +514,9 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr theO SALOMEDS::GenericAttribute_out theAttr, const char* theTypeOfAttribute) { - if(!CORBA::is_nil(theObject)){ - PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,GetPOA()); - if(aServant.in() != NULL){ - if(SALOMEDS_SObject_i* anSObject = dynamic_cast(aServant.in())){ - return anSObject->FindAttribute(theAttr,theTypeOfAttribute); - } - } - } + if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject)) + return aSObject->FindAttribute(theAttr,theTypeOfAttribute); + return Standard_False; } @@ -590,8 +541,9 @@ void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr theSObject, if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects Handle(SALOMEDS_IORAttribute) anAttr; if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) - SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); - else return; + _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString()); + else + return; } Lab.ForgetAttribute(SALOMEDS::GetGUID(aTypeOfAttribute)); @@ -668,10 +620,9 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) Handle(TDataStd_Name) aName; TDF_Label aLabel; SALOMEDS::SObject_var anObject = SALOMEDS_SObject_i::NewRef(_study,_doc->Main()); - SALOMEDS::Study_var aStudy = anObject->GetStudy(); try { - anObject = aStudy->FindObjectByPath(thePath); //Check if the directory already exists + anObject = _study->FindObjectByPath(thePath); //Check if the directory already exists } catch(...) { } @@ -679,7 +630,7 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) if(aPath.Value(1) != '/') { //Relative path aPath.Prepend('/'); - aPath = TCollection_AsciiString(aStudy->GetContext()) + aPath; + aPath = TCollection_AsciiString(_study->GetContext()) + aPath; } TCollection_AsciiString aToken = aPath.Token("/", 1); @@ -696,7 +647,7 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) anObject = SALOMEDS::SObject::_nil(); try { - anObject = aStudy->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists + anObject = _study->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists } catch(...) { ; } if(anObject->_is_nil()) @@ -792,7 +743,7 @@ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::Loc AbortCommand(); throw SALOMEDS::StudyBuilder::LockProtection(); } else { - SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->RemovePostponed(_doc->GetUndoLimit()); + _study->RemovePostponed(_doc->GetUndoLimit()); int aModif = anAttr->GetModified(); if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero @@ -818,7 +769,7 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() //============================================================================ void SALOMEDS_StudyBuilder_i::AbortCommand() { - SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(0); + _study->UndoPostponed(0); _doc->AbortCommand(); } @@ -840,7 +791,7 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti MESSAGE("Locked document modification !!!"); throw SALOMEDS::StudyBuilder::LockProtection(); } else { - SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(1); + _study->UndoPostponed(1); _doc->Undo(); anAttr->SetModified(anAttr->GetModified()-1); } @@ -865,7 +816,7 @@ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtecti throw SALOMEDS::StudyBuilder::LockProtection(); } else { _doc->Redo(); - SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(-1); + _study->UndoPostponed(-1); anAttr->SetModified(anAttr->GetModified()+1); } } @@ -1010,5 +961,5 @@ void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* th TDF_Label aLabel; CORBA::String_var aSOID = theSO->GetID(); TDF_Tool::Label(_doc->GetData(), aSOID, aLabel); - SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),GetORB()); + SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),_study); } diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx index b2bddafa5..38f29b440 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -38,6 +38,7 @@ #include class SALOMEDS_Study_i; +class SALOMEDS_SObject_i; class SALOMEDS_Callback_i; class SALOMEDS_StudyBuilder_i: public virtual POA_SALOMEDS::StudyBuilder, @@ -110,6 +111,8 @@ public: throw(SALOME::SALOME_Exception); virtual void Load(SALOMEDS::SObject_ptr sco); + SALOMEDS_SObject_i* RemoveSObject(SALOMEDS::SObject_ptr theSObject, + bool theIsForgetAllAttributes = true); virtual void RemoveObject(SALOMEDS::SObject_ptr anObject); virtual void RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject); diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 5030d0880..614ca3611 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -49,8 +49,10 @@ #include "SALOMEDS_StudyManager_i.hxx" #include "SALOME_LifeCycleCORBA.hxx" -#include "SALOMEDS_SObject_i.hxx" + #include "SALOMEDS_Study_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_StudyBuilder_i.hxx" #include "SALOMEDS_IORAttribute.hxx" #include "SALOMEDS_PersRefAttribute.hxx" @@ -112,9 +114,11 @@ namespace SALOMEDS{ //=========================================================================== //Function : LoadAttributes //=========================================================================== -static void ReadAttributes(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr aSO, - HDFdataset* hdf_dataset) +static +void +ReadAttributes(SALOMEDS_Study_i* theStudy, + SALOMEDS::SObject_ptr aSO, + HDFdataset* hdf_dataset) { hdf_dataset->OpenOnDisk(); @@ -124,15 +128,15 @@ static void ReadAttributes(SALOMEDS::Study_ptr theStudy, hdf_dataset->ReadFromDisk(current_string); if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { - anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); + anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, "AttributeComment"); } else if (!strcmp(hdf_dataset->GetName(),"Reference")) { - theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string)); + theStudy->GetBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string)); delete(current_string); hdf_dataset->CloseOnDisk(); return; } else { MESSAGE("Read attribute "<GetName()) - anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); + anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName()); } if (!CORBA::is_nil(anAttr)) { @@ -149,18 +153,18 @@ static void ReadAttributes(SALOMEDS::Study_ptr theStudy, //============================================================================ //Function : Translate_IOR_to_persistentID //============================================================================ -static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_ptr theBuilder, - SALOMEDS::SObject_ptr theSObject, - SALOMEDS::Driver_ptr theEngine, - CORBA::Boolean theIsMultiFile, - CORBA::Boolean theIsASCII) +static void Translate_IOR_to_persistentID(SALOMEDS_Study_i* theStudy, + SALOMEDS_StudyBuilder_i* theBuilder, + SALOMEDS::SObject_ptr theSObject, + SALOMEDS::Driver_ptr theEngine, + CORBA::Boolean theIsMultiFile, + CORBA::Boolean theIsASCII) { MESSAGE("In Translate_IOR_to_persistentID"); - SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject); - for (; anIter->More(); anIter->Next()){ + SALOMEDS_ChildIterator_i anIter = theStudy->GetChildIterator(theSObject); + for(; anIter.More(); anIter.Next()){ SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::SObject_var aSObject = anIter->Value(); + SALOMEDS::SObject_var aSObject = anIter.Value(); if(aSObject->FindAttribute(anAttr,"AttributeIOR")){ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); CORBA::String_var aString = anIOR->Value(); @@ -178,7 +182,9 @@ static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr theStudy, //============================================================================ //Function : BuildlTree //============================================================================ -static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group) +static +void +BuildTree(SALOMEDS_Study_i* theStudy, HDFgroup* hdf_current_group) { hdf_current_group->OpenOnDisk(); @@ -210,7 +216,7 @@ static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group) else if (type == HDF_GROUP) { MESSAGE( "--> Group: Internal Object Name : " << name); HDFgroup* new_group = new HDFgroup(name,hdf_current_group); - BuildTree (theStudy, new_group); + BuildTree(theStudy, new_group); new_group = 0; // will be deleted by father destructor } } @@ -247,6 +253,18 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i() _name_service.Destroy_Directory("/Study"); } +SALOMEDS_Study_i* +SALOMEDS_StudyManager_i::DownCast(SALOMEDS::Study_ptr theStudy) const +{ + if(!CORBA::is_nil(theStudy)){ + PortableServer::POA_var aPOA = GetPOA(); + PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theStudy,aPOA); + if(aServant.in()) + return dynamic_cast(aServant.in()); + } + return NULL; +} + //============================================================================ /*! Function : register_name * Purpose : Register the study Manager in the naming service under the @@ -286,7 +304,9 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* theStudyName) // Assign the value of the IOR in the study->root CORBA::String_var anIOR = _orb->object_to_string(aStudy); - SALOMEDS_IORAttribute::Set(aDocument->Main().Root(),const_cast(anIOR.in()),_orb); + SALOMEDS_IORAttribute::Set(aDocument->Main().Root(), + const_cast(anIOR.in()), + aStudyServant); // set Study properties SALOMEDS::AttributeStudyProperties_var aProp = aStudyServant->GetProperties(); @@ -350,12 +370,14 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* theURL) aStudy->StudyId( _IDcounter ); // Assign the value of the URL in the study object - aStudy->URL(theURL); + aStudyServant->URL(theURL); SCRUTE(theURL); // Assign the value of the IOR in the study->root CORBA::String_var anIOR = _orb->object_to_string(aStudy); - SALOMEDS_IORAttribute::Set(Doc->Main().Root(),const_cast(anIOR.in()),_orb); + SALOMEDS_IORAttribute::Set(Doc->Main().Root(), + const_cast(anIOR.in()), + aStudyServant); SALOMEDS_PersRefAttribute::Set(Doc->Main(),const_cast(theURL)); @@ -370,7 +392,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* theURL) Handle(TDF_Data) DF = Doc->GetData(); try{ - BuildTree (aStudy,hdf_group_study_structure); + BuildTree(aStudyServant,hdf_group_study_structure); }catch(HDFexception){ std::ostringstream aStream; aStream<<"Can't open file "<Name()); + CORBA::String_var aString(aStudyServant->Name()); _name_service.Register(aStudy,aString.in()); } @@ -590,12 +612,10 @@ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject * Purpose : save the study properties in HDF file */ //============================================================================ -void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group) +void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group) { // add modifications list (user and date of save) - SALOMEDS::AttributeStudyProperties_ptr aProp = aStudy->GetProperties(); - SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder(); -// SB->NewCommand(); + SALOMEDS::AttributeStudyProperties_ptr aProp = theStudy->GetProperties(); int aLocked = aProp->IsLocked(); if (aLocked) aProp->SetLocked(Standard_False); @@ -609,7 +629,6 @@ void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgro CORBA::Long(aDate.Year())); if(aLocked) aProp->SetLocked(Standard_True); -// SB->CommitCommand(); SALOMEDS::StringSeq_var aNames; SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; @@ -647,7 +666,7 @@ void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgro */ //============================================================================ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, - SALOMEDS::Study_ptr aStudy, + SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile, CORBA::Boolean theASCII) { @@ -657,72 +676,66 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, // * Study Structure -> Exactly what is contained in OCAF document // Informations in data group hdf_group_study_structure - HDFfile *hdf_file=0; - HDFgroup *hdf_group_study_structure =0; - HDFgroup *hdf_sco_group =0; - HDFgroup *hdf_sco_group2 =0; + if(SALOMEDS_Study_i* aStudy = DownCast(theStudy)){ + HDFfile *hdf_file=0; + HDFgroup *hdf_group_study_structure =0; + HDFgroup *hdf_sco_group =0; + HDFgroup *hdf_sco_group2 =0; - HDFgroup *hdf_group_datacomponent =0; - HDFdataset *hdf_dataset =0; - hdf_size size[1]; - hdf_int32 name_len = 0; - - int aLocked = aStudy->GetProperties()->IsLocked(); - if (aLocked) aStudy->GetProperties()->SetLocked(false); - - SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder(); + HDFgroup *hdf_group_datacomponent =0; + HDFdataset *hdf_dataset =0; + hdf_size size[1]; + hdf_int32 name_len = 0; + + int aLocked = aStudy->GetProperties()->IsLocked(); + if(aLocked) + aStudy->GetProperties()->SetLocked(false); - ASSERT(!CORBA::is_nil(aStudy)); - try - { + SALOMEDS_StudyBuilder_i* SB= aStudy->GetBuilder(); + try{ // mpv 15.12.2003: for saving components we have to load all data from all modules - - SALOMEDS::SComponentIterator_var itcomponent1 = aStudy->NewComponentIterator(); - for (; itcomponent1->More(); itcomponent1->Next()) - { - SALOMEDS::SComponent_var sco = itcomponent1->Value(); - // if there is an associated Engine call its method for saving - CORBA::String_var IOREngine; - try { + SALOMEDS_SComponentIterator_i aComponentIter = aStudy->GetComponentIterator(); + for(; aComponentIter.More(); aComponentIter.Next()){ + SALOMEDS::SComponent_var sco = aComponentIter.Value(); + // if there is an associated Engine call its method for saving + CORBA::String_var IOREngine; + try{ + if(!sco->ComponentIOR(IOREngine)){ + SALOMEDS::GenericAttribute_var aGeneric; + SALOMEDS::AttributeName_var aName; + if(sco->FindAttribute(aGeneric, "AttributeName")) + aName = SALOMEDS::AttributeName::_narrow(aGeneric); - if (!sco->ComponentIOR(IOREngine)) { - SALOMEDS::GenericAttribute_var aGeneric; - SALOMEDS::AttributeName_var aName; - if(sco->FindAttribute(aGeneric, "AttributeName")) - aName = SALOMEDS::AttributeName::_narrow(aGeneric); - - if (!aName->_is_nil()) { - - CORBA::String_var aCompType = aName->Value(); - - - CORBA::String_var aFactoryType; - if (strcmp(aCompType, "SUPERV") == 0) aFactoryType = "SuperVisionContainer"; - else aFactoryType = "FactoryServer"; + if(!aName->_is_nil()){ + CORBA::String_var aCompType = aName->Value(); + + CORBA::String_var aFactoryType; + if(strcmp(aCompType, "SUPERV") == 0) + aFactoryType = "SuperVisionContainer"; + else + aFactoryType = "FactoryServer"; + + Engines::Component_var aComp = + SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType); + if(aComp->_is_nil()){ Engines::Component_var aComp = - SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType); - - if (aComp->_is_nil()) { - Engines::Component_var aComp = - SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType); - } + SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType); + } - if (!aComp->_is_nil()) { - SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp); - if (!CORBA::is_nil(aDriver)) { - SB->LoadWith(sco, aDriver); - } + if(!aComp->_is_nil()){ + SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp); + if (!CORBA::is_nil(aDriver)) { + SB->LoadWith(sco, aDriver); } } } - } catch(...) { - MESSAGE("Can not restore information to resave it"); - return; } + }catch(...){ + MESSAGE("Can not restore information to resave it"); + return; } - - + } CORBA::String_var anOldName = aStudy->Name(); aStudy->URL(aUrl); @@ -739,116 +752,112 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file); hdf_group_datacomponent->CreateOnDisk(); - SALOMEDS::SComponentIterator_var itcomponent = aStudy->NewComponentIterator(); - //SRN: Added 17 Nov, 2003 SALOMEDS::SObject_var anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG); //SRN: End - for (; itcomponent->More(); itcomponent->Next()) - { - SALOMEDS::SComponent_var sco = itcomponent->Value(); + aComponentIter.Init(); + for(; aComponentIter.More(); aComponentIter.Next()){ + SALOMEDS::SComponent_var sco = aComponentIter.Value(); - CORBA::String_var scoid = sco->GetID(); - hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent); - hdf_sco_group->CreateOnDisk(); - - CORBA::String_var componentDataType = sco->ComponentDataType(); - MESSAGE ( "Look for an engine for data type :"<< componentDataType); - - //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save - if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)) { - - SALOMEDS::GenericAttribute_var aGeneric; - SALOMEDS::AttributeTableOfString_var aTable; - if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")) { - aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric); - Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; - if(nbRows > 0 && aTable->GetNbColumns() > 1) { - - SALOMEDS::StringSeq_var aRow; - for(k=1; k<=nbRows; k++) { - aRow = aTable->GetRow(k); - if (strcmp(aRow[0], componentDataType) == 0) { - CORBA::String_var anEntry = CORBA::string_dup(aRow[1]); - SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry); - if(!CORBA::is_nil(aCompSpecificSO)) { - SALOMEDS::AttributeInteger_var anInteger; - if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) { - anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric); - anInteger->SetValue(-1); - while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; } - } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) - } // if(!CORBA::is_nil(aCompSpecificSO)) - } // if (strcmp(aRow[0], componentDataType) == 0) - } // for - - } // if(nbRows > 0 && aTable->GetNbColumns() > 1) - - } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString") - - } // if(SB->IsGUID(AUTO_SAVE_GUID) - - //SRN: End - - CORBA::String_var IOREngine; - if (sco->ComponentIOR(IOREngine)) - { - // we have found the associated engine to write the data - MESSAGE ( "We have found an engine for data type :"<< componentDataType); - CORBA::Object_var obj = _orb->string_to_object(IOREngine); - SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + CORBA::String_var scoid = sco->GetID(); + hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent); + hdf_sco_group->CreateOnDisk(); + + CORBA::String_var componentDataType = sco->ComponentDataType(); + MESSAGE ( "Look for an engine for data type :"<< componentDataType); + + //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save + if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)){ + SALOMEDS::GenericAttribute_var aGeneric; + SALOMEDS::AttributeTableOfString_var aTable; + if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")){ + aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric); + Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0; + if(nbRows > 0 && aTable->GetNbColumns() > 1) { + SALOMEDS::StringSeq_var aRow; + for(k=1; k<=nbRows; k++){ + aRow = aTable->GetRow(k); + if(strcmp(aRow[0], componentDataType) == 0){ + CORBA::String_var anEntry = CORBA::string_dup(aRow[1]); + SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry); + if(!CORBA::is_nil(aCompSpecificSO)) { + SALOMEDS::AttributeInteger_var anInteger; + if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) { + anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric); + anInteger->SetValue(-1); + while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; } + } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger")) + } // if(!CORBA::is_nil(aCompSpecificSO)) + } // if (strcmp(aRow[0], componentDataType) == 0) + } // for - if (!CORBA::is_nil(Engine)) - { - MESSAGE ( "Save the data of type:"<< componentDataType); - MESSAGE("Engine :"<ComponentDataType()); - - SALOMEDS::TMPFile_var aStream; - - if (theASCII) aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile); - else aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile); - - HDFdataset *hdf_dataset; - hdf_size aHDFSize[1]; - if(aStream->length() > 0) { //The component saved some auxiliary files, then put them into HDF file - - aHDFSize[0] = aStream->length(); - - HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file - hdf_dataset->CloseOnDisk(); - } - // store multifile state - aHDFSize[0] = 2; - hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor - - // store ASCII state - aHDFSize[0] = 2; - hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor - - Translate_IOR_to_persistentID (aStudy,SB,sco,Engine,theMultiFile, theASCII); - MESSAGE("After Translate_IOR_to_persistentID"); - - // Creation of the persistance reference attribute - } + } // if(nbRows > 0 && aTable->GetNbColumns() > 1) + + } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString") + + } // if(SB->IsGUID(AUTO_SAVE_GUID) + + //SRN: End + + CORBA::String_var IOREngine; + if(sco->ComponentIOR(IOREngine)){ + // we have found the associated engine to write the data + MESSAGE ( "We have found an engine for data type :"<< componentDataType); + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + + if(!CORBA::is_nil(Engine)){ + MESSAGE ( "Save the data of type:"<< componentDataType); + MESSAGE("Engine :"<ComponentDataType()); + + SALOMEDS::TMPFile_var aStream; + + if(theASCII) + aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile); + else + aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile); + + HDFdataset *hdf_dataset; + hdf_size aHDFSize[1]; + if(aStream->length() > 0){ //The component saved some auxiliary files, then put them into HDF file + + aHDFSize[0] = aStream->length(); + + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); } - hdf_sco_group->CloseOnDisk(); - hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor + // store multifile state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + + // store ASCII state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + + Translate_IOR_to_persistentID(aStudy,SB,sco,Engine,theMultiFile, theASCII); + MESSAGE("After Translate_IOR_to_persistentID"); + + // Creation of the persistance reference attribute + } } + hdf_sco_group->CloseOnDisk(); + hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor + } hdf_group_datacomponent->CloseOnDisk(); hdf_group_datacomponent =0; // will be deleted by hdf_file destructor - - + + //----------------------------------------------------------------------- //3 - Write the Study Structure //----------------------------------------------------------------------- @@ -856,36 +865,35 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, hdf_group_study_structure->CreateOnDisk(); // save component attributes - SALOMEDS::SComponentIterator_var itcomp = aStudy->NewComponentIterator(); - for (; itcomp->More(); itcomp->Next()) - { - SALOMEDS::SComponent_var SC = itcomp->Value(); - - CORBA::String_var scid = SC->GetID(); - hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure); - hdf_sco_group2->CreateOnDisk(); - SaveAttributes(SC, hdf_sco_group2); - // ComponentDataType treatment - CORBA::String_var component_name = SC->ComponentDataType(); - MESSAGE("Component data type " << component_name << " treated"); - - name_len = (hdf_int32) strlen(component_name.in()); - size[0] = name_len +1 ; - hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); - hdf_dataset->CreateOnDisk(); - hdf_dataset->WriteOnDisk(const_cast(component_name.in())); - MESSAGE("component name " << component_name << " wrote on file"); - hdf_dataset->CloseOnDisk(); - hdf_dataset=0; //will be deleted by hdf_sco_group destructor - _SaveObject(aStudy, SC, hdf_sco_group2); - hdf_sco_group2->CloseOnDisk(); - hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor - } + aComponentIter.Init(); + for(; aComponentIter.More(); aComponentIter.Next()){ + SALOMEDS::SComponent_var SC = aComponentIter.Value(); + + CORBA::String_var scid = SC->GetID(); + hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure); + hdf_sco_group2->CreateOnDisk(); + SaveAttributes(SC, hdf_sco_group2); + // ComponentDataType treatment + CORBA::String_var component_name = SC->ComponentDataType(); + MESSAGE("Component data type " << component_name << " treated"); + + name_len = (hdf_int32) strlen(component_name.in()); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(const_cast(component_name.in())); + MESSAGE("component name " << component_name << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + _SaveObject(aStudy, SC, hdf_sco_group2); + hdf_sco_group2->CloseOnDisk(); + hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor + } //----------------------------------------------------------------------- //4 - Write the Study UseCases Structure //----------------------------------------------------------------------- SALOMEDS::SObject_var aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID); - if (!aSO->_is_nil()) { + if(!aSO->_is_nil()){ HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure); hdf_soo_group->CreateOnDisk(); SaveAttributes(aSO, hdf_soo_group); @@ -895,7 +903,8 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor } - if (aLocked) aStudy->GetProperties()->SetLocked(true); + if (aLocked) + aStudy->GetProperties()->SetLocked(true); //----------------------------------------------------------------------- //5 - Write the Study Properties //----------------------------------------------------------------------- @@ -916,18 +925,17 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, _name_service.Change_Directory("/Study"); _name_service.Destroy_Name(anOldName); - _name_service.Register(aStudy, aStudy->Name()); + _name_service.Register(theStudy, aStudy->Name()); aStudy->IsSaved(true); hdf_group_study_structure =0; // will be deleted by hdf_file destructor delete hdf_file; // recursively deletes all hdf objects... + }catch(HDFexception){ + MESSAGE( "HDFexception ! " ); } - catch (HDFexception) - { - MESSAGE( "HDFexception ! " ) + if(theASCII){ // save file in ASCII format + HDFascii::ConvertFromHDFToASCII(aUrl, true); } - if (theASCII) { // save file in ASCII format - HDFascii::ConvertFromHDFToASCII(aUrl, true); } } @@ -936,8 +944,8 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, * Purpose : */ //============================================================================ -void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, - SALOMEDS::SObject_ptr SC, +void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS_Study_i* theStudy, + SALOMEDS::SObject_ptr theSObject, HDFgroup *hdf_group_datatype) { // Write in group hdf_group_datatype all informations of SObject SC @@ -945,36 +953,37 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, SALOMEDS::SObject_var RefSO; HDFgroup *hdf_group_sobject = 0; - SALOMEDS::ChildIterator_var itchild = aStudy->NewChildIterator(SC); - for (; itchild->More(); itchild->Next()) - { - SALOMEDS::SObject_var SO = itchild->Value(); - - // mpv: don't save empty labels - if (SO->GetAllAttributes()->length() == 0 && !SO->ReferencedObject(RefSO)) { - SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC); - if (!subchild->More()) { - continue; - } - subchild->InitEx(true); - bool anEmpty = true; - for (; subchild->More() && anEmpty; subchild->Next()) - if (subchild->Value()->GetAllAttributes()->length() != 0 || - subchild->Value()->ReferencedObject(RefSO)) anEmpty = false; - if (anEmpty) { - continue; - } + SALOMEDS_ChildIterator_i aChildIter = theStudy->GetChildIterator(theSObject); + for(; aChildIter.More(); aChildIter.Next()){ + SALOMEDS::SObject_var aSObject = aChildIter.Value(); + SALOMEDS::ListOfAttributes_var anAllAttributes = aSObject->GetAllAttributes(); + + // mpv: don't save empty labels + if(anAllAttributes->length() == 0 && !aSObject->ReferencedObject(RefSO)){ + SALOMEDS_ChildIterator_i aSubChildIter = theStudy->GetChildIterator(theSObject); + if(!aSubChildIter.More()) + continue; + + aSubChildIter.InitEx(true); + bool anEmpty = true; + for(; aSubChildIter.More() && anEmpty; aSubChildIter.Next()){ + SALOMEDS::SObject_var aSObj = aSubChildIter.Value(); + SALOMEDS::ListOfAttributes_var anAllAttr = aSObj->GetAllAttributes(); + if(anAllAttr->length() != 0 || aSObj->ReferencedObject(RefSO)) + anEmpty = false; } - - CORBA::String_var scoid(SO->GetID()); - hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype); - hdf_group_sobject->CreateOnDisk(); - SaveAttributes(SO, hdf_group_sobject); - _SaveObject(aStudy,SO, hdf_group_sobject); - hdf_group_sobject->CloseOnDisk(); - hdf_group_sobject =0; // will be deleted by father hdf object destructor - + if(anEmpty) + continue; } + + CORBA::String_var scoid(aSObject->GetID()); + hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype); + hdf_group_sobject->CreateOnDisk(); + SaveAttributes(aSObject, hdf_group_sobject); + _SaveObject(theStudy,aSObject, hdf_group_sobject); + hdf_group_sobject->CloseOnDisk(); + hdf_group_sobject =0; // will be deleted by father hdf object destructor + } } //============================================================================ diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 7b11df5ef..a6e4c9e6c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -87,13 +87,13 @@ private: CORBA::Boolean theMultiFile, CORBA::Boolean theASCII); // _SaveObject private function called by _SaveAs - virtual void _SaveObject(SALOMEDS::Study_ptr aStudy, - SALOMEDS::SObject_ptr SC, - HDFgroup *hdf_group_datatype); + void _SaveObject(SALOMEDS_Study_i* theStudy, + SALOMEDS::SObject_ptr SC, + HDFgroup *hdf_group_datatype); // _SubstituteSlash function called by Open and GetStudyByName virtual std::string _SubstituteSlash(const char *aUrl); - virtual void _SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group); + void _SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group); public: //! standard constructor @@ -106,6 +106,8 @@ public: PortableServer::POA_var GetPOA() const { return _poa; } + SALOMEDS_Study_i* DownCast(SALOMEDS::Study_ptr theStudy) const; + //! method to Register study Manager in the naming service /*! \param char* arguments, the context to register the study manager in the NS diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 934598800..1f8e0aa75 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -162,6 +162,19 @@ PortableServer::POA_var SALOMEDS_Study_i::GetPOA() const return _StudyManager->GetPOA(); } + +SALOMEDS_SObject_i* +SALOMEDS_Study_i::DownCast(SALOMEDS::SObject_ptr theSObject) const +{ + if(!CORBA::is_nil(theSObject)){ + PortableServer::POA_var aPOA = GetPOA(); + PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theSObject,aPOA); + if(aServant.in()) + return dynamic_cast(aServant.in()); + } + return NULL; +} + //============================================================================ /*! Function : SetOnAddSObject * Purpose : @@ -443,14 +456,18 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* theObjectIOR) { // firstly searching in the datamap for optimization char* anIOR = const_cast(theObjectIOR); - if (myIORLabels.IsBound(anIOR)) { - SALOMEDS::SObject_var aResult = SALOMEDS_SObject_i::NewRef(this,myIORLabels.Find(anIOR)); + if(myIORLabels.IsBound(anIOR)){ + TDF_Label aLabel = myIORLabels.Find(anIOR); + TSObjectHolder aSObjectHolder = SALOMEDS_SObject_i::New(this,aLabel); + SALOMEDS_SObject_i* aSObjectPtr = aSObjectHolder.first; + SALOMEDS::SObject_var aSObject = aSObjectHolder.second; // 11 oct 2002: forbidden attributes must be checked here SALOMEDS::GenericAttribute_var anAttr; - if (!aResult->FindAttribute(anAttr,"AttributeIOR")) { + if(!aSObjectPtr->FindAttribute(anAttr,"AttributeIOR")){ myIORLabels.UnBind(anIOR); - } else - return aResult._retn(); + }else{ + return aSObject._retn(); + } } // Iterate to all components defined in the study @@ -782,29 +799,43 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theCont * Purpose : Create a ChildIterator from an SObject */ //============================================================================ -SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr aSO) +SALOMEDS::ChildIterator_ptr +SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSObject) { - //Convert aSO->GetID in TDF_Label. - TDF_Label Lab; - TDF_Tool::Label(_doc->GetData(), aSO->GetID(), Lab); + SALOMEDS_ChildIterator_i* aServant = + new SALOMEDS_ChildIterator_i(GetChildIterator(theSObject)); - //Create iterator - SALOMEDS_ChildIterator_i* aServant = new SALOMEDS_ChildIterator_i(this,Lab); return aServant->_this(); } +SALOMEDS_ChildIterator_i +SALOMEDS_Study_i::GetChildIterator(SALOMEDS::SObject_ptr theSObject) +{ + TDF_Label aLab; + TDF_Tool::Label(_doc->GetData(),theSObject->GetID(),aLab); + return SALOMEDS_ChildIterator_i(this,aLab); +} //============================================================================ /*! Function : NewComponentIterator * Purpose : Create a SComponentIterator */ //============================================================================ -SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() +SALOMEDS::SComponentIterator_ptr +SALOMEDS_Study_i::NewComponentIterator() { - SALOMEDS_SComponentIterator_i* aServant = new SALOMEDS_SComponentIterator_i(this,_doc); + SALOMEDS_SComponentIterator_i* aServant = + new SALOMEDS_SComponentIterator_i(GetComponentIterator()); + return aServant->_this(); } +SALOMEDS_SComponentIterator_i +SALOMEDS_Study_i::GetComponentIterator() +{ + return SALOMEDS_SComponentIterator_i(this,_doc); +} + //============================================================================ /*! Function : GetUseCaseBuilder * Purpose : Returns a UseCase builder @@ -820,9 +851,14 @@ SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() * Purpose : Create a StudyBuilder */ //============================================================================ +SALOMEDS_StudyBuilder_i* SALOMEDS_Study_i::GetBuilder() +{ + return _Builder; +} + SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() { - return _Builder->_this(); + return GetBuilder()->_this(); } //============================================================================ @@ -994,25 +1030,11 @@ void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel); } -SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb) { - Handle(SALOMEDS_IORAttribute) Att; - if (theLabel.Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ - char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Get()).ToCString()); - CORBA::Object_var obj = orb->string_to_object(IOR); - SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ; - ASSERT(!CORBA::is_nil(aStudy)); - return SALOMEDS::Study::_duplicate(aStudy); - } else { - MESSAGE("GetStudy: Problem to get study"); - } - return SALOMEDS::Study::_nil(); -} - -void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb) { +void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute) { TCollection_AsciiString aString; - TDF_Tool::Entry(theAttribute->Label(), aString); - GetStudy(theAttribute->Label(), orb)->UpdateIORLabelMap(TCollection_AsciiString(theAttribute->Get()).ToCString(), - aString.ToCString()); + TDF_Tool::Entry(theAttribute->Label(),aString); + TCollection_AsciiString aValue(theAttribute->Get()); + UpdateIORLabelMap(aValue.ToCString(),aString.ToCString()); } SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) { @@ -1026,9 +1048,12 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObj } -SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties() { - SALOMEDS::GenericAttribute_ptr anAttr = NewBuilder()->FindOrCreateAttribute(FindObjectID("0:1"), - "AttributeStudyProperties"); +SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(){ + SALOMEDS::SObject_var aSObject = FindObjectID("0:1"); + + SALOMEDS::GenericAttribute_var anAttr = + GetBuilder()->FindOrCreateAttribute(aSObject,"AttributeStudyProperties"); + return SALOMEDS::AttributeStudyProperties::_narrow(anAttr); } @@ -1111,7 +1136,7 @@ void SALOMEDS_Study_i::Close() */ //============================================================================ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { - if (!NewBuilder()->HasOpenCommand()) return; + if (!GetBuilder()->HasOpenCommand()) return; try { CORBA::Object_var obj = GetORB()->string_to_object(theIOR); if (!CORBA::is_nil(obj)) { @@ -1127,7 +1152,7 @@ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) { } void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) { - if (!NewBuilder()->HasOpenCommand()) return; + if (!GetBuilder()->HasOpenCommand()) return; try { CORBA::Object_var obj = GetORB()->string_to_object(theIOR); if (!CORBA::is_nil(obj)) { diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index bbb151bab..18b9ef8fb 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -49,6 +49,9 @@ #include "SALOMEDS_DataMapStringLabel.hxx" #include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_SComponentIterator_i.hxx" +#include "SALOMEDS_ChildIterator_i.hxx" + class SALOMEDS_StudyManager_i; class SALOMEDS_UseCaseBuilder_i; class SALOMEDS_StudyBuilder_i; @@ -82,7 +85,9 @@ public: CORBA::ORB_var GetORB() const; PortableServer::POA_var GetPOA() const; - + + SALOMEDS_SObject_i* DownCast(SALOMEDS::SObject_ptr theSObject) const; + SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback); SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback); @@ -220,17 +225,20 @@ public: \return ChildIterator_ptr arguments, the created ChildIterator */ virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO); + SALOMEDS_ChildIterator_i GetChildIterator(SALOMEDS::SObject_ptr theSObject); //! method to Create a SComponentIterator /*! \return SComponentIterator_ptr arguments, the created SComponentIterator */ virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator(); + SALOMEDS_SComponentIterator_i GetComponentIterator(); //! method to Create a StudyBuilder /*! \return StudyBuilder_ptr arguments, the created StudyBuilder */ + SALOMEDS_StudyBuilder_i* GetBuilder(); virtual SALOMEDS::StudyBuilder_ptr NewBuilder(); //! method to get study name @@ -278,9 +286,7 @@ public: virtual CORBA::Short StudyId(); virtual void StudyId(CORBA::Short id); - static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb); - - static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb); + void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute); virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel); diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po index 6b3b993b9..a4695f62b 100644 --- a/src/SALOMEGUI/CLIENT_msg_en.po +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -20,7 +20,7 @@ msgstr "" #--------------- msgid "INF_VERSION" -msgstr "Version 2.1.0" +msgstr "Version 2.2.0" msgid "INF_COPYRIGHT" msgstr "Copyright (C) 2003-2004 OPEN CASCADE, EADS/CCR, LIP6,\nCEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS" @@ -38,8 +38,8 @@ msgstr "salome" #: QAD_Application.cxx:133 msgid "QAD_Application::APP_DEFAULTTITLE" -msgstr "SALOME 2.1.0" +msgstr "SALOME 2.2.0" #: QAD_Desktop.cxx:424 msgid "QAD_Desktop::DESK_DEFAULTTITLE" -msgstr "SALOME 2.1.0" +msgstr "SALOME 2.2.0" diff --git a/src/SALOMEGUI/Makefile.in b/src/SALOMEGUI/Makefile.in index f3d426d18..d3acbc362 100644 --- a/src/SALOMEGUI/Makefile.in +++ b/src/SALOMEGUI/Makefile.in @@ -218,6 +218,7 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx index 199381a54..d54652baa 100644 --- a/src/SALOMEGUI/PyInterp_base.cxx +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -253,6 +253,16 @@ int PyInterp_base::run(const char *command) _atFirst = false; return ret; } + ret = simpleRun("from salome import salome_init"); + if (ret) { + _atFirst = false; + return ret; + } + ret = simpleRun("salome_init()"); + if (ret) { + _atFirst = false; + return ret; + } ret = simpleRun("import salome"); if (ret) { _atFirst = false; diff --git a/src/SALOMELocalTrace/Makefile.in b/src/SALOMELocalTrace/Makefile.in index 8d2beb1d5..7894a23c0 100644 --- a/src/SALOMELocalTrace/Makefile.in +++ b/src/SALOMELocalTrace/Makefile.in @@ -47,6 +47,8 @@ LIB = libSALOMELocalTrace.la LIB_SRC = LocalTraceCollector.cxx \ LocalTraceBufferPool.cxx -LDFLAGS+= +LIBS= @LIBS@ +#LDFLAGS+= + @CONCLUDE@ diff --git a/src/SALOME_PY/Makefile.in b/src/SALOME_PY/Makefile.in index f99d2e4ed..9b8cf7e33 100644 --- a/src/SALOME_PY/Makefile.in +++ b/src/SALOME_PY/Makefile.in @@ -41,6 +41,7 @@ LIB_SRC = SalomePy.cxx LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) -DHAVE_CONFIG_H diff --git a/src/SALOME_PYQT/Makefile.in b/src/SALOME_PYQT/Makefile.in index 7c1de51a1..6797d4dbf 100644 --- a/src/SALOME_PYQT/Makefile.in +++ b/src/SALOME_PYQT/Makefile.in @@ -47,7 +47,7 @@ LIB_MOC = SALOME_PYQT_GUI.h EXPORT_SHAREDPYSCRIPTS = SalomePyQt.py -LIB_CLIENT_IDL = SALOME_Exception.idl +LIB_CLIENT_IDL = SALOME_Exception.idl SALOME_ContainerManager.idl CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(SIP_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) LIBS+= $(PYTHON_LIBS) $(SIP_LIBS) $(PYQT_LIBS) $(VTK_LIBS) $(OGL_LIBS) diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome.py b/src/SALOME_SWIG_WITHOUTIHM/salome.py index 0beae6343..25ccbfbaa 100755 --- a/src/SALOME_SWIG_WITHOUTIHM/salome.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome.py @@ -28,5 +28,16 @@ from salome_kernel import * from salome_study import * from salome_iapp import * -IN_SALOME_GUI=sg.hasDesktop() +salome_initial=1 +def salome_init(): + global salome_initial + global orb, lcc, naming_service, cm + global sg + global myStudyManager, myStudyId, myStudy, myStudyName + + if salome_initial: + salome_initial=0 + orb, lcc, naming_service, cm = salome_kernel_init() + sg = salome_iapp_init() + myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init() diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py b/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py index d89536cff..33e47811e 100644 --- a/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_iapp.py @@ -51,6 +51,16 @@ class SalomeGUI(SALOMEGUI_Swig): #-------------------------------------------------------------------------- -# create an SALOMEGUI_Swig instance -sg = SalomeGUI() +salome_iapp_initial = 1 +def salome_iapp_init(): + global salome_iapp_initial + global sg,IN_SALOME_GUI + + if salome_iapp_initial: + salome_iapp_initial=0 + + # create an SALOMEGUI_Swig instance + sg = SalomeGUI() + IN_SALOME_GUI=sg.hasDesktop() + return sg diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_kernel.py b/src/SALOME_SWIG_WITHOUTIHM/salome_kernel.py index 27c4e58b0..93be05fb1 100644 --- a/src/SALOME_SWIG_WITHOUTIHM/salome_kernel.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_kernel.py @@ -28,12 +28,28 @@ from omniORB import CORBA from LifeCycleCORBA import * from SALOME_NamingServicePy import * from SALOME_utilities import * +import Engines -# initialise the ORB -orb = CORBA.ORB_init([''], CORBA.ORB_ID) +salome_kernel_initial=1 -# create an LifeCycleCORBA instance -lcc = LifeCycleCORBA(orb) +def salome_kernel_init(): + global salome_kernel_initial + global orb, lcc, naming_service, cm + + if salome_kernel_initial: + salome_kernel_initial = 0 + + # initialise the ORB + orb = CORBA.ORB_init([''], CORBA.ORB_ID) -#create an naming service instance -naming_service = SALOME_NamingServicePy_i(orb) + # create an LifeCycleCORBA instance + lcc = LifeCycleCORBA(orb) + + #create an naming service instance + naming_service = SALOME_NamingServicePy_i(orb) + + # get Container Manager + obj = naming_service.Resolve('/ContainerManager') + cm = obj._narrow(Engines.ContainerManager) + + return orb, lcc, naming_service, cm diff --git a/src/SALOME_SWIG_WITHOUTIHM/salome_study.py b/src/SALOME_SWIG_WITHOUTIHM/salome_study.py index 954830e24..ecc76728c 100644 --- a/src/SALOME_SWIG_WITHOUTIHM/salome_study.py +++ b/src/SALOME_SWIG_WITHOUTIHM/salome_study.py @@ -24,9 +24,9 @@ # Module : SALOME # $Header$ -from salome_iapp import sg -from salome_kernel import * +import salome_kernel import SALOMEDS +import salome_iapp #-------------------------------------------------------------------------- @@ -106,7 +106,9 @@ salome_study_ID = -1 def getActiveStudy(): global salome_study_ID + print "getActiveStudy" + sg = salome_iapp.salome_iapp_init() if salome_study_ID == -1: if sg.hasDesktop(): print "---in gui" @@ -132,6 +134,7 @@ def createNewStudy(): nameAlreadyInUse=0 else: i = i+1 + theStudy = myStudyManager.NewStudy(aStudyName) theStudyId = theStudy._get_StudyId() print aStudyName, theStudyId @@ -139,17 +142,29 @@ def createNewStudy(): #-------------------------------------------------------------------------- -# get Study Manager reference -print "looking for studyManager ..." -obj = naming_service.Resolve('myStudyManager') -myStudyManager = obj._narrow(SALOMEDS.StudyManager) -print "studyManager found" - -# get active study Id, ref and name -myStudyId = getActiveStudy() -print "myStudyId",myStudyId -myStudy = myStudyManager.GetStudyByID(myStudyId) -myStudyName = myStudy._get_Name() - +salome_study_initial = 1 +def salome_study_init(): + global salome_study_initial + global myStudyManager, myStudyId, myStudy, myStudyName + global orb, lcc, naming_service, cm + + if salome_study_initial: + salome_study_initial = 0 + + orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init() + + # get Study Manager reference + print "looking for studyManager ..." + obj = naming_service.Resolve('myStudyManager') + myStudyManager = obj._narrow(SALOMEDS.StudyManager) + print "studyManager found" + + # get active study Id, ref and name + myStudyId = getActiveStudy() + print "myStudyId",myStudyId + myStudy = myStudyManager.GetStudyByID(myStudyId) + myStudyName = myStudy._get_Name() + + return myStudyManager, myStudyId, myStudy, myStudyName diff --git a/src/SUPERVGraph/Makefile.in b/src/SUPERVGraph/Makefile.in index 3edb511e4..b108204d7 100644 --- a/src/SUPERVGraph/Makefile.in +++ b/src/SUPERVGraph/Makefile.in @@ -22,6 +22,7 @@ LIB_MOC = SUPERVGraph_moc.cxx \ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 45ce4c82b..499b7705f 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -49,12 +49,12 @@ LIB_SRC=\ BIN = SALOME_Session_Server BIN_SRC = BIN_SERVER_IDL = SALOME_Session.idl -BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Exception.idl +BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_ContainerManager.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Exception.idl CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSALOMETraceCollector -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent -lSalomePrs $(CAS_LDPATH) -lTKBO -lCASCatch - +LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent -lSalomePrs $(CAS_LDPATH) -lTKBO -lCASCatch -lSalomeResourcesManager +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/Session/Session_ServerLauncher.cxx b/src/Session/Session_ServerLauncher.cxx index 82a8c6733..6b9f4b92e 100644 --- a/src/Session/Session_ServerLauncher.cxx +++ b/src/Session/Session_ServerLauncher.cxx @@ -181,6 +181,17 @@ void Session_ServerLauncher::CheckArgs() void Session_ServerLauncher::ActivateAll() { + + // Always launch ContainerManager + + char** argv = new char* [1]; + argv[0] = "ContainerManager"; + Session_SessionThread* aServerThread2 + = new Session_SessionThread(1, argv, _orb,_root_poa,_GUIMutex,_ServerLaunch); + _serverThreads.push_front(aServerThread2); + + aServerThread2->Init(); + list::iterator itServ; for (itServ = _argServToLaunch.begin(); itServ !=_argServToLaunch.end(); itServ++) { @@ -205,7 +216,7 @@ void Session_ServerLauncher::ActivateAll() // Always launch Session Server int argc=1; - char** argv = new char*[argc]; + argv = new char*[argc]; argv[0] = "Session"; Session_SessionThread* aServerThread = new Session_SessionThread(argc, argv, _orb,_root_poa,_GUIMutex,_ServerLaunch); diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index a4fb054cc..9fa3e76af 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -33,6 +33,7 @@ #include "Session_ServerThread.hxx" #include "SALOME_Container_i.hxx" +#include "SALOME_ContainerManager.hxx" #include "SALOMEDS_StudyManager_i.hxx" #include "SALOME_ModuleCatalog_impl.hxx" #include "RegistryService.hxx" @@ -50,12 +51,13 @@ using namespace std; -const int Session_ServerThread::NB_SRV_TYP = 5; +const int Session_ServerThread::NB_SRV_TYP = 6; const char* Session_ServerThread::_serverTypes[NB_SRV_TYP] = {"Container", "ModuleCatalog", "Registry", "SALOMEDS", - "Session"}; + "Session", + "ContainerManager"}; //============================================================================= /*! @@ -124,6 +126,7 @@ void Session_ServerThread::Init() case 0: // Container { NamingService_WaitForServerReadiness(_NS,"/Registry"); + NamingService_WaitForServerReadiness(_NS,"/ContainerManager"); ActivateContainer(_argc, _argv); break; } @@ -155,6 +158,12 @@ void Session_ServerThread::Init() ActivateSession(_argc, _argv); break; } + case 5: // Container Manager + { + NamingService_WaitForServerReadiness(_NS,""); + ActivateContainerManager(_argc, _argv); + break; + } default: { ASSERT(0); @@ -324,6 +333,44 @@ void Session_ServerThread::ActivateRegistry(int argc, */ //============================================================================= +void Session_ServerThread::ActivateContainerManager(int argc, + char ** argv) +{ + try + { + PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); + cout << "ActivateContainerManager ......!!!! " << endl; + SALOME_ContainerManager * myContainer + = new SALOME_ContainerManager(_orb); + } + catch(CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException."); + } + catch(PortableServer::POA::WrongPolicy&) + { + INFOS("Caught CORBA::WrongPolicyException."); + } + catch(PortableServer::POA::ServantAlreadyActive&) + { + INFOS("Caught CORBA::ServantAlreadyActiveException"); + } + catch(CORBA::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(...) + { + INFOS("Caught unknown exception."); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + void Session_ServerThread::ActivateContainer(int argc, char ** argv) { diff --git a/src/Session/Session_ServerThread.hxx b/src/Session/Session_ServerThread.hxx index e67ee7fe8..9293cd4d2 100644 --- a/src/Session/Session_ServerThread.hxx +++ b/src/Session/Session_ServerThread.hxx @@ -58,6 +58,8 @@ protected: char ** argv); void ActivateContainer(int argc, char ** argv); + void ActivateContainerManager(int argc, + char ** argv); virtual void ActivateSession(int argc, char ** argv); diff --git a/src/TOOLSGUI/Makefile.in b/src/TOOLSGUI/Makefile.in index 73a914c7f..d41cb3724 100644 --- a/src/TOOLSGUI/Makefile.in +++ b/src/TOOLSGUI/Makefile.in @@ -51,7 +51,7 @@ LIB_SRC = ToolsGUI.cxx \ LIB_MOC = ToolsGUI_CatalogGeneratorDlg_moc.cxx LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl \ - SALOME_Component.idl SALOME_Exception.idl + SALOME_Component.idl SALOME_ContainerManager.idl SALOME_Exception.idl # additionnal information to compil and link file diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in index b16797b1f..c5b22b104 100644 --- a/src/TestContainer/Makefile.in +++ b/src/TestContainer/Makefile.in @@ -45,7 +45,8 @@ LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl BIN = TestContainer TestLogger BIN_SRC = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSalomeResourcesManager +LDFLAGSFORBIN= $(LDFLAGS) -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index 43786ab25..f5e06c1ed 100644 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -69,11 +69,12 @@ LIB_MOC = \ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ + SALOME_ContainerManager.idl \ SALOME_Exception.idl CPPFLAGS+=$(QT_INCLUDES) $(OGL_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) -LDFLAGS+=$(VTK_LIBS) $(OGL_LIBS) $(QT_MT_LIBS) -lSalomePrs -lSalomeGUI +LDFLAGS+=$(VTK_LIBS) $(OGL_LIBS) $(QT_MT_LIBS) -lSalomePrs -lSalomeGUI -lToolsGUI @CONCLUDE@ -- 2.39.2