From: vsr Date: Tue, 29 Sep 2015 12:34:12 +0000 (+0300) Subject: Implement a way to re-arrange modules order in study dump X-Git-Tag: V7_7_0rc1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac6d547502bd1beccfc5fc37a745a78c490e45e3;p=modules%2Fkernel.git Implement a way to re-arrange modules order in study dump --- diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 6fe45d9a7..0fc9172e4 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -44,6 +44,7 @@ #include #include +#include // comment out the following define to enable \t symbols in in the python dump files #define WITHOUT_TABS @@ -1226,12 +1227,31 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath, for (; itcomponent.More(); itcomponent.Next()) { SALOMEDSImpl_SComponent sco = itcomponent.Value(); aCompType = sco.ComponentDataType(); - //GEOM and MED are independent components - if (aCompType == "GEOM" || aCompType == "MED") + if (aCompType == "GEOM") aSeq.insert(aSeq.begin(), aCompType); else aSeq.push_back(aCompType); } + // re-arrange modules in the sequence, if specific order is given via SALOME_MODULES_ORDER environment variable. + if ( getenv("SALOME_MODULES_ORDER") != 0 ) { + std::string order = getenv("SALOME_MODULES_ORDER"); + std::vector mlist; + while ( !order.empty() ) { + size_t idx = order.find( "," ); + std::string m = order.substr(0, idx); + order = order.substr( ( idx == std::string::npos ) ? order.size() : idx+1 ); + if ( m.empty() || std::find( mlist.begin(), mlist.end(), m ) != mlist.end() ) continue; + mlist.push_back( m ); + } + + for ( std::vector::reverse_iterator mit = mlist.rbegin(); mit != mlist.rend(); ++mit ) { + std::vector::iterator it = std::find( aSeq.begin(), aSeq.end(), *mit ); + if ( it != aSeq.end() ) { + aSeq.erase( it ); + aSeq.insert( aSeq.begin(), *mit ); + } + } + } #ifdef WIN32 std::string aFileName =