1 # Copyright (C) 2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 from collections import OrderedDict
28 def IntToStr(i,prefix=""):
30 return prefix+chr( ord('A')+i )
32 factor = (i//26)-1 ; remain = i%26
33 return IntToStr(factor,prefix)+IntToStr(remain)
35 def GenerateSimplifiedOne(p0):
36 children = p0.getChildren()
41 for i,c in enumerate(children):
43 #if newName in ["R","A"]:
45 dico[c.getName()] = newName
46 revDico[newName] = c.getName()
49 newProc = r.createProc("TOP")
50 for k,v in dico.items():
51 node = r.createScriptNode("Salome",v)#createProc
52 newProc.edAddChild(node)
55 if c.getName() not in dico:
58 sn = newProc.getChildByName( dico[ c.getName() ] )
59 outg = len( og.edMapInGate() )
61 print( "More than one link ( {} ) for {} !".format( outg, dico[c.getName()] ) )
62 for ol in og.edMapInGate():
63 en = newProc.getChildByName( dico[ ol[0].getNode().getName() ])
64 newProc.edAddCFLink(sn,en)
65 return newProc, dico, revDico
68 SALOMERuntime.RuntimeSALOME.setRuntime()
69 r = SALOMERuntime.getSALOMERuntime()
70 l = loader.YACSLoader()
73 p0 = p.getChildren()[0]
74 newProc, dico, revDico = GenerateSimplifiedOne( p0 )
75 newProc.saveSchema( dbgFname )
77 indepGraphs = newProc.splitIntoIndependantGraph()
79 if len(indepGraphs) != 1:
80 raise RuntimeError("Ooops !")
82 sop = pilot.SetOfPoints(indepGraphs[0])