From 8d56c9427dd70b1c996d63404747beb86438e111 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 8 Oct 2019 15:05:50 +0200 Subject: [PATCH] [EDF20032] : Useful tool for debugging --- src/engine_swig/GraphForSOPDbg.py | 83 +++++++++++++++++++++++++++++++ src/engine_swig/pilot.i | 4 ++ 2 files changed, 87 insertions(+) create mode 100644 src/engine_swig/GraphForSOPDbg.py diff --git a/src/engine_swig/GraphForSOPDbg.py b/src/engine_swig/GraphForSOPDbg.py new file mode 100644 index 000000000..11b60d67c --- /dev/null +++ b/src/engine_swig/GraphForSOPDbg.py @@ -0,0 +1,83 @@ +# Copyright (C) 2019 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import pilot +import SALOMERuntime +import loader +from collections import OrderedDict + +fname = "graph.xml" +dbgFname = "dbg.xml" + +def IntToStr(i,prefix=""): + if i<26: + return prefix+chr( ord('A')+i ) + else: + factor = (i//26)-1 ; remain = i%26 + return IntToStr(factor,prefix)+IntToStr(remain) + +def GenerateSimplifiedOne(p0): + children = p0.getChildren() + + dico = OrderedDict() + revDico = {} + + for i,c in enumerate(children): + newName = IntToStr(i) + #if newName in ["R","A"]: + # continue + dico[c.getName()] = newName + revDico[newName] = c.getName() + pass + + newProc = r.createProc("TOP") + for k,v in dico.items(): + node = r.createScriptNode("Salome",v)#createProc + newProc.edAddChild(node) + + for c in children: + if c.getName() not in dico: + continue + og = c.getOutGate() + sn = newProc.getChildByName( dico[ c.getName() ] ) + outg = len( og.edMapInGate() ) + if outg > 1: + print( "More than one link ( {} ) for {} !".format( outg, dico[c.getName()] ) ) + for ol in og.edMapInGate(): + en = newProc.getChildByName( dico[ ol[0].getNode().getName() ]) + newProc.edAddCFLink(sn,en) + return newProc, dico, revDico + + +SALOMERuntime.RuntimeSALOME.setRuntime() +r = SALOMERuntime.getSALOMERuntime() +l = loader.YACSLoader() +p = l.load(fname) + +p0 = p.getChildren()[0] +newProc, dico, revDico = GenerateSimplifiedOne( p0 ) +newProc.saveSchema( dbgFname ) + +indepGraphs = newProc.splitIntoIndependantGraph() + +if len(indepGraphs) != 1: + raise RuntimeError("Ooops !") + +sop = pilot.SetOfPoints(indepGraphs[0]) +sop.simplify() diff --git a/src/engine_swig/pilot.i b/src/engine_swig/pilot.i index 94b114efd..9a4c6b805 100644 --- a/src/engine_swig/pilot.i +++ b/src/engine_swig/pilot.i @@ -66,6 +66,7 @@ #include "NotSimpleCasePoint.hxx" #include "ElementaryPoint.hxx" #include "ObserverAsPlugin.hxx" +#include "InGate.hxx" using namespace YACS::ENGINE; @@ -113,6 +114,7 @@ using namespace YACS::ENGINE; %template() std::pair; %template() std::pair; %template() std::pair< std::string, int >; +%template() std::pair< YACS::ENGINE::InGate *, bool>; %template(ItPy3TC) IteratorPy3; //%template(TCmap) std::map; REFCOUNT_TEMPLATE(TCmap,YACS::ENGINE::TypeCode) @@ -140,6 +142,8 @@ REFCOUNT_TEMPLATE(CONTAINmap,YACS::ENGINE::Container) %template() std::pair; %template(propmap) std::map; %template(ItPy3Comp) IteratorPy3; +%template(listpairingatebool) std::list< std::pair< YACS::ENGINE::InGate *, bool> >; + REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance) %include "exception.i" -- 2.30.2