Salome HOME
Copyrights update 2015.
[samples/datafiles.git] / Superv / Python / TestSupervMedfieldLoopForiVisu.py
1 # Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 # Generated python file of Graph TestSupervMedfieldLoopForiVisu
24 #
25 from SuperV import *
26
27 # Graph creation of TestSupervMedfieldLoopForiVisu
28 def DefTestSupervMedfieldLoopForiVisu() :
29     TestSupervMedfieldLoopForiVisu = Graph( 'TestSupervMedfieldLoopForiVisu' )
30     TestSupervMedfieldLoopForiVisu.SetName( 'TestSupervMedfieldLoopForiVisu' )
31     TestSupervMedfieldLoopForiVisu.SetAuthor( '' )
32     TestSupervMedfieldLoopForiVisu.SetComment( '' )
33     TestSupervMedfieldLoopForiVisu.Coords( 0 , 0 )
34     
35     # Creation of Factory Nodes
36     
37     Mul = TestSupervMedfieldLoopForiVisu.FNode( 'Calculator' , 'Calculator' , 'Mul' )
38     Mul.SetName( 'Mul' )
39     Mul.SetAuthor( 'LD' )
40     Mul.SetContainer( 'localhost/FactoryServer' )
41     Mul.SetComment( 'Multiply a field by a constant' )
42     Mul.Coords( 387 , 104 )
43     IMulfield1 = Mul.GetInPort( 'field1' )
44     IMulx1 = Mul.GetInPort( 'x1' )
45     IMulGate = Mul.GetInPort( 'Gate' )
46     OMulreturn = Mul.GetOutPort( 'return' )
47     OMulGate = Mul.GetOutPort( 'Gate' )
48     
49     # Creation of InLine Nodes
50     PyInitDisplay = []
51     PyInitDisplay.append( 'from LifeCycleCORBA import *   ' )
52     PyInitDisplay.append( 'from VISU import *   ' )
53     PyInitDisplay.append( 'def InitDisplay():   ' )
54     PyInitDisplay.append( '    # initialize the ORB     ' )
55     PyInitDisplay.append( '    orb = CORBA.ORB_init([], CORBA.ORB_ID)   ' )
56     PyInitDisplay.append( '    # create an LifeCycleCORBA instance        ' )
57     PyInitDisplay.append( '    lcc = LifeCycleCORBA(orb)                  ' )
58     PyInitDisplay.append( '    # -----------------------------------------    ' )
59     PyInitDisplay.append( '    # loading visu component                       ' )
60     PyInitDisplay.append( '    aVisu = lcc.FindOrLoadComponent("FactoryServer","VISU")    ' )
61     PyInitDisplay.append( '    print "InitDisplay --> aVisu        = ",aVisu    ' )
62     PyInitDisplay.append( '    aViewManager = aVisu.GetViewManager()           ' )
63     PyInitDisplay.append( '    print "InitDisplay --> aViewManager = ",aViewManager    ' )
64     PyInitDisplay.append( '    # aView = aViewManager.GetCurrentView()        ' )
65     PyInitDisplay.append( '    aView = aViewManager.Create3DView()             ' )
66     PyInitDisplay.append( '    print "InitDisplay --> aView        = ",aView    ' )
67     PyInitDisplay.append( '    return aVisu,aView   ' )
68     InitDisplay = TestSupervMedfieldLoopForiVisu.INode( 'InitDisplay' , PyInitDisplay )
69     InitDisplay.SetName( 'InitDisplay' )
70     InitDisplay.SetAuthor( '' )
71     InitDisplay.SetComment( 'Compute Node' )
72     InitDisplay.Coords( 0 , 163 )
73     IInitDisplayGate = InitDisplay.GetInPort( 'Gate' )
74     OInitDisplayaVisu = InitDisplay.OutPort( 'aVisu' , 'objref' )
75     OInitDisplayaView = InitDisplay.OutPort( 'aView' , 'objref' )
76     OInitDisplayGate = InitDisplay.GetOutPort( 'Gate' )
77     
78     PyDisplayMed = []
79     PyDisplayMed.append( 'import os  ' )
80     PyDisplayMed.append( 'import SALOME_MED  ' )
81     PyDisplayMed.append( 'from VISU import *  ' )
82     PyDisplayMed.append( 'from LifeCycleCORBA import *  ' )
83     PyDisplayMed.append( 'def DisplayMed(medfield,index,aVisu,aView):     ' )
84     PyDisplayMed.append( '    # initialize the ORB                    ' )
85     PyDisplayMed.append( '    orb = CORBA.ORB_init([''], CORBA.ORB_ID)                      ' )
86     PyDisplayMed.append( '    # create an LifeCycleCORBA instance                   ' )
87     PyDisplayMed.append( '    lcc = LifeCycleCORBA(orb)                   ' )
88     PyDisplayMed.append( '    print " "  ' )
89     PyDisplayMed.append( '    print "***************************************************************"  ' )
90     PyDisplayMed.append( '    calc = lcc.FindOrLoadComponent("FactoryServer", "Calculator")   ' )
91     PyDisplayMed.append( '    print "-----> calc  = ",calc  ' )
92     PyDisplayMed.append( '    medfilename = "/tmp/LoopGraphFile" + str(index) + ".med"  ' )
93     PyDisplayMed.append( '    print "-----> Writing Med field in temporary file : ",medfilename  ' )
94     PyDisplayMed.append( '    calc.writeMEDfile(medfield,medfilename)  ' )
95     PyDisplayMed.append( '    print "-----> calc  = ",calc  ' )
96     PyDisplayMed.append( '    print "***************************************************************"  ' )
97     PyDisplayMed.append( '    myResult1   = aVisu.ImportFile(medfilename)  ' )
98     PyDisplayMed.append( '    print "-----> myResult1 = ",myResult1  ' )
99     PyDisplayMed.append( '    field_name = medfield.getName()  ' )
100     PyDisplayMed.append( '    print "-----> field_name = ",field_name  ' )
101     PyDisplayMed.append( '    mesh_name = medfield.getSupport().getMesh().getName()  ' )
102     PyDisplayMed.append( '    print "-----> mesh_name = ",mesh_name  ' )
103     PyDisplayMed.append( '    aMesh1      = aVisu.MeshOnEntity(myResult1,mesh_name,CELL)  ' )
104     PyDisplayMed.append( '    print "-----> aMesh1 = ",aMesh1  ' )
105     PyDisplayMed.append( '    aScalarMap1 = aVisu.ScalarMapOnField(myResult1,mesh_name,NODE,field_name,1)  ' )
106     PyDisplayMed.append( '    print "-----> aScalarMap1 = ",aScalarMap1  ' )
107     PyDisplayMed.append( '    aView.DisplayOnly(aScalarMap1)  ' )
108     PyDisplayMed.append( '    aView.FitAll()  ' )
109     PyDisplayMed.append( '    command = "rm " + medfilename  ' )
110     PyDisplayMed.append( '    os.system(command)  ' )
111     PyDisplayMed.append( '    print "-----> Delete temporary Med file : ",medfilename  ' )
112     PyDisplayMed.append( '    print "***************************************************************"  ' )
113     PyDisplayMed.append( '    print " "  ' )
114     PyDisplayMed.append( '    return medfield ' )
115     DisplayMed = TestSupervMedfieldLoopForiVisu.INode( 'DisplayMed' , PyDisplayMed )
116     DisplayMed.SetName( 'DisplayMed' )
117     DisplayMed.SetAuthor( '' )
118     DisplayMed.SetComment( 'Compute Node' )
119     DisplayMed.Coords( 594 , 105 )
120     IDisplayMedINmedfield = DisplayMed.InPort( 'INmedfield' , 'objref' )
121     IDisplayMedindex = DisplayMed.InPort( 'index' , 'long' )
122     IDisplayMedaVisu = DisplayMed.InPort( 'aVisu' , 'objref' )
123     IDisplayMedaView = DisplayMed.InPort( 'aView' , 'objref' )
124     IDisplayMedGate = DisplayMed.GetInPort( 'Gate' )
125     ODisplayMedOUTmedfield = DisplayMed.OutPort( 'OUTmedfield' , 'objref' )
126     ODisplayMedGate = DisplayMed.GetOutPort( 'Gate' )
127     
128     # Creation of Loop Nodes
129     PyInit = []
130     PyInit.append( 'def Init(index,min,max,medfield,x1,aVisu,aView):  ' )
131     PyInit.append( '    if max >= min :  ' )
132     PyInit.append( '           index = min  ' )
133     PyInit.append( '    else : ' )
134     PyInit.append( '        index = max  ' )
135     PyInit.append( '    print "Init --> index      = ",index   ' )
136     PyInit.append( '    print "         min        = ",min   ' )
137     PyInit.append( '    print "         max        = ",max   ' )
138     PyInit.append( '    print "         medfield   = ",medfield   ' )
139     PyInit.append( '    return index,min,max,medfield,x1,aVisu,aView  ' )
140     PyMoreInit = []
141     PyMoreInit.append( 'def More(index,min,max,medfield,x1,aVisu,aView):  ' )
142     PyMoreInit.append( '    if max >= index :   ' )
143     PyMoreInit.append( '        DoLoop = 1   ' )
144     PyMoreInit.append( '    else :   ' )
145     PyMoreInit.append( '        DoLoop = 0   ' )
146     PyMoreInit.append( '    print "More --> DoLoop      = ",DoLoop   ' )
147     PyMoreInit.append( '    print "         index       = ",index   ' )
148     PyMoreInit.append( '    print "         min         = ",min   ' )
149     PyMoreInit.append( '    print "         max         = ",max   ' )
150     PyMoreInit.append( '    print "         medfield    = ",medfield   ' )
151     PyMoreInit.append( '    return DoLoop,index,min,max,medfield,x1,aVisu,aView  ' )
152     PyNextInit = []
153     PyNextInit.append( 'def Next(index,min,max,medfield,x1,aVisu,aView):  ' )
154     PyNextInit.append( '    index = index + 1  ' )
155     PyNextInit.append( '    print "Next --> index      = ",index   ' )
156     PyNextInit.append( '    print "         min        = ",min   ' )
157     PyNextInit.append( '    print "         max        = ",max   ' )
158     PyNextInit.append( '    print "         medfield   = ",medfield   ' )
159     PyNextInit.append( '    return index,min,max,medfield,x1,aVisu,aView  ' )
160     Init,EndInit = TestSupervMedfieldLoopForiVisu.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit )
161     EndInit.SetName( 'EndInit' )
162     EndInit.SetAuthor( 'LD' )
163     EndInit.SetComment( 'no comment' )
164     EndInit.Coords( 776 , 64 )
165     PyEndInit = []
166     EndInit.SetPyFunction( '' , PyEndInit )
167     IInitDoLoop = Init.GetInPort( 'DoLoop' )
168     IInitindex = Init.InPort( 'index' , 'long' )
169     IInitmin = Init.InPort( 'min' , 'long' )
170     IInitmax = Init.InPort( 'max' , 'long' )
171     IInitmedfield = Init.InPort( 'medfield' , 'objref' )
172     IInitx1 = Init.InPort( 'x1' , 'double' )
173     IInitaVisu = Init.InPort( 'aVisu' , 'objref' )
174     IInitaView = Init.InPort( 'aView' , 'objref' )
175     IInitGate = Init.GetInPort( 'Gate' )
176     OInitDoLoop = Init.GetOutPort( 'DoLoop' )
177     OInitindex = Init.GetOutPort( 'index' )
178     OInitmin = Init.GetOutPort( 'min' )
179     OInitmax = Init.GetOutPort( 'max' )
180     OInitmedfield = Init.GetOutPort( 'medfield' )
181     OInitx1 = Init.GetOutPort( 'x1' )
182     OInitaVisu = Init.GetOutPort( 'aVisu' )
183     OInitaView = Init.GetOutPort( 'aView' )
184     IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' )
185     IEndInitindex = EndInit.GetInPort( 'index' )
186     IEndInitmin = EndInit.GetInPort( 'min' )
187     IEndInitmax = EndInit.GetInPort( 'max' )
188     IEndInitmedfield = EndInit.GetInPort( 'medfield' )
189     IEndInitx1 = EndInit.GetInPort( 'x1' )
190     IEndInitaVisu = EndInit.GetInPort( 'aVisu' )
191     IEndInitaView = EndInit.GetInPort( 'aView' )
192     IEndInitGate = EndInit.GetInPort( 'Gate' )
193     OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' )
194     OEndInitindex = EndInit.GetOutPort( 'index' )
195     OEndInitmin = EndInit.GetOutPort( 'min' )
196     OEndInitmax = EndInit.GetOutPort( 'max' )
197     OEndInitmedfield = EndInit.GetOutPort( 'medfield' )
198     OEndInitx1 = EndInit.GetOutPort( 'x1' )
199     OEndInitaVisu = EndInit.GetOutPort( 'aVisu' )
200     OEndInitaView = EndInit.GetOutPort( 'aView' )
201     OEndInitGate = EndInit.GetOutPort( 'Gate' )
202     Init.SetName( 'Init' )
203     Init.SetAuthor( 'LD' )
204     Init.SetComment( 'no comment' )
205     Init.Coords( 205 , 63 )
206     
207     # Creation of Links
208     LInitDisplayaVisuInitaVisu = TestSupervMedfieldLoopForiVisu.Link( OInitDisplayaVisu , IInitaVisu )
209     
210     LInitDisplayaViewInitaView = TestSupervMedfieldLoopForiVisu.Link( OInitDisplayaView , IInitaView )
211     
212     LInitindexEndInitindex = TestSupervMedfieldLoopForiVisu.Link( OInitindex , IEndInitindex )
213     
214     LInitindexDisplayMedindex = TestSupervMedfieldLoopForiVisu.Link( OInitindex , IDisplayMedindex )
215     LInitindexDisplayMedindex.AddCoord( 1 , 566 , 215 )
216     LInitindexDisplayMedindex.AddCoord( 2 , 566 , 96 )
217     
218     LInitminEndInitmin = TestSupervMedfieldLoopForiVisu.Link( OInitmin , IEndInitmin )
219     
220     LInitmaxEndInitmax = TestSupervMedfieldLoopForiVisu.Link( OInitmax , IEndInitmax )
221     
222     LInitmedfieldMulfield1 = TestSupervMedfieldLoopForiVisu.Link( OInitmedfield , IMulfield1 )
223     
224     LInitx1EndInitx1 = TestSupervMedfieldLoopForiVisu.Link( OInitx1 , IEndInitx1 )
225     
226     LInitx1Mulx1 = TestSupervMedfieldLoopForiVisu.Link( OInitx1 , IMulx1 )
227     
228     LInitaVisuEndInitaVisu = TestSupervMedfieldLoopForiVisu.Link( OInitaVisu , IEndInitaVisu )
229     
230     LInitaVisuDisplayMedaVisu = TestSupervMedfieldLoopForiVisu.Link( OInitaVisu , IDisplayMedaVisu )
231     LInitaVisuDisplayMedaVisu.AddCoord( 1 , 570 , 242 )
232     LInitaVisuDisplayMedaVisu.AddCoord( 2 , 569 , 263 )
233     LInitaVisuDisplayMedaVisu.AddCoord( 3 , 377 , 264 )
234     LInitaVisuDisplayMedaVisu.AddCoord( 4 , 376 , 242 )
235     
236     LInitaViewEndInitaView = TestSupervMedfieldLoopForiVisu.Link( OInitaView , IEndInitaView )
237     
238     LInitaViewDisplayMedaView = TestSupervMedfieldLoopForiVisu.Link( OInitaView , IDisplayMedaView )
239     
240     LMulreturnDisplayMedINmedfield = TestSupervMedfieldLoopForiVisu.Link( OMulreturn , IDisplayMedINmedfield )
241     
242     LDisplayMedOUTmedfieldEndInitmedfield = TestSupervMedfieldLoopForiVisu.Link( ODisplayMedOUTmedfield , IEndInitmedfield )
243     
244     # Input datas
245     IInitindex.Input( 0 )
246     IInitmin.Input( 0 )
247     IInitmax.Input( 4 )
248     IInitx1.Input( 2 )
249     
250     # Input Ports of the graph
251     #IInitmedfield = Init.GetInPort( 'medfield' )
252     
253     # Output Ports of the graph
254     #OEndInitindex = EndInit.GetOutPort( 'index' )
255     #OEndInitmin = EndInit.GetOutPort( 'min' )
256     #OEndInitmax = EndInit.GetOutPort( 'max' )
257     #OEndInitmedfield = EndInit.GetOutPort( 'medfield' )
258     #OEndInitx1 = EndInit.GetOutPort( 'x1' )
259     #OEndInitaVisu = EndInit.GetOutPort( 'aVisu' )
260     #OEndInitaView = EndInit.GetOutPort( 'aView' )
261     return TestSupervMedfieldLoopForiVisu
262
263
264 TestSupervMedfieldLoopForiVisu = DefTestSupervMedfieldLoopForiVisu()