This file is indexed.

/usr/lib/aster/Templates/salomeParaviz.py is in code-aster 11.5.0+dfsg2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# coding=utf-8
# ======================================================================
# COPYRIGHT (C) 1991 - 2013  EDF R&D                  WWW.CODE-ASTER.ORG
# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY  
# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY  
# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR     
# (AT YOUR OPTION) ANY LATER VERSION.                                                  
#                                                                       
# THIS PROGRAM 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      
# GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              
#                                                                       
# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     
# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,         
#    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        
# ======================================================================
#
import os

# Donnees utilisateur
#
# Pour isovaleurs
# INPUTFILE1 : Fichier de resultat MED
# CHOIX = 'DEPL', 'ISO', 'GAUSS', 'ON_DEFORMED'
#
# Pour courbes
# INPUTFILE1 : Fichier de resultat TXT
# CHOIX = 'COURBE'


#%====================Choix et fichier================================%
# CHOIX = DEPL, GAUSS, ISO, COURBE
# Cette partie est modifiee automatiquement par Stanley

INPUTFILE1  = '/tmp/mon-fichier.med'
OUTPUTFILE1 = ''
STUDY       = ''
CHOIX       = 'DEPL'

#%=================================================================%

if CHOIX not in ['DEPL','ISO','GAUSS','COURBE', 'ON_DEFORMED']: raise Exception("Erreur de type de visualisation!")
if not os.path.isfile(INPUTFILE1): raise Exception("Fichier %s non present!" % INPUTFILE1)

#%====================Initialisation Salome================================%
import sys
import salome
import SALOMEDS
import salome_kernel
orb, lcc, naming_service, cm = salome_kernel.salome_kernel_init()
obj = naming_service.Resolve('myStudyManager')
myStudyManager = obj._narrow(SALOMEDS.StudyManager)

root=os.path.normpath(os.path.dirname(os.path.abspath(os.path.realpath(sys.argv[0]))))
INPUTFILE2 = os.path.join(root,INPUTFILE1)
if not os.path.isfile(INPUTFILE2): raise Exception("Fichier %s non present!" % INPUTFILE1)

#%====================Initialisation etude================================%
if STUDY:
    # Si on a le nom de l'etude
    study=myStudyManager.GetStudyByName(STUDY)
    salome.salome_init(study._get_StudyId())

else:
    # Sinon on choisit etude courante
    salome.salome_init()

#%=================== Initialisation paravis ============================%
try: pvsimple
except:from pvsimple import*

#%===================Construction courbe======================%

# selection de la vue adequate 
view=None
try : 
     # Cas vue active OK
     v=GetActiveView()
     if CHOIX =='COURBE' :
          if v.GetProperty('AxisBehavior'):
             view=v
     else :
          if v.GetProperty('CenterAxesVisibility'):
             view=v
     SetActiveView(view)
     L=view.Representations
     for i in L :i.Visibility = 0
     pass

except :
     try :
       # Cas plusieurs vues 
       anim = GetAnimationScene()
       liste_view = anim.ViewModules
       for v in liste_view :
         if CHOIX == 'COURBE':
            if v.GetProperty('AxisBehavior'):
               view=v
         else :
            if v.GetProperty('CenterAxesVisibility'):
               view=v
       SetActiveView(view)
       L=view.Representations
       for i in L :i.Visibility = 0
       pass     

     except :pass
if view==None and CHOIX == 'COURBE' : view = CreateXYPlotView()

if CHOIX == 'COURBE' :
     CHOIXF = 'COURBE'

     # reader Table
     myResult = TableReader(FileName=INPUTFILE2)
     if myResult is None : raise "Erreur de fichier"
     myResult.FirstStringAsTitles = 0
     courbe=PlotData()

     display=Show()
     display.AttributeType = 'Row Data'
     display.UseIndexForXAxis = 0
     Render()
     NAME_X = display.GetProperty('SeriesNamesInfo')[0]
     # NAME_X = 'ABSC_CURV'
     display.XArrayName = NAME_X
     display.UseIndexForXAxis = 0
     display.SeriesVisibility = ['vtkOriginalIndices', '0', NAME_X, '0']
     Render()

#%====================Construction isovaleurs====================%
    
if CHOIX != 'COURBE' :

     myResult = MEDReader(FileName=INPUTFILE2)
     if myResult is None : raise Exception("Erreur de fichier MED")


     # Recuperation du nom des champs
     L_POIN = myResult.GetProperty('PointFieldsArrayInfo')
     L_CELL = myResult.GetProperty('CellFieldsArrayInfo')
     L_ELNO = myResult.GetProperty('ElnoFieldsArrayInfo')
     L_ELGA = myResult.GetProperty('QuadratureFieldsArrayInfo')
     #print 'L_POIN',L_POIN,'L_CELL',L_CELL,'L_ELNO',L_ELNO,'L_ELGA',L_ELGA
     NB_CHAMP = len(L_POIN)+len(L_CELL)+len(L_ELNO)+len(L_ELGA)
     # On ne considere pas ELNO et ON_DEFORMED (comme Gauss)
     if len(L_ELNO) > 0 :
         CHOIXF ='ELNO'
     else :
         CHOIXF = CHOIX  
     #print 'NB_CHAMP=',NB_CHAMP

     # Champ variable ou non

     NB_ORDRE = len(myResult.GetPropertyValue('TimestepValues'))

if CHOIXF == 'ISO' :

     # Recuperation du champ et application filtre ELNO si necessaire
     myResult.GenerateVectors = 0

     resu = myResult
     
     if len (L_POIN) > 0 : 
          NOM_CHAMP = L_POIN[0]
          pd = resu.PointData
     if len (L_CELL) > 0 : 
          NOM_CHAMP = L_CELL[0]
          pd = resu.CellData

     # Recuperation des informations du champ
     for i in range(len(pd)):
          if pd.values()[i-1].GetName()== NOM_CHAMP :
               NB_CMP = pd.values()[i-1].GetNumberOfComponents()
               NOM_CMP = pd.values()[i-1].GetComponentName(0)
               RANGE_CMP = pd.values()[i-1].GetRange()

     # Attributs de visualisation
     CMP = 'Component'
     TYPE = 'Surface With Edges'


if CHOIXF == 'ELNO' :

     # Recuperation du champ et application filtre ELNO si necessaire
     # choix de visualiser les ELNO en ELGA
     myResult.GenerateVectors = 0
     
     resu = ELNOPoints()
     resu.SelectSourceArray = ['POINTS', 'ELNO']
     
     
     if len (L_ELNO) > 0 : 
          NOM_CHAMP = L_ELNO[0]
          pd = resu.PointData


     # Recuperation des informations du champ
     for i in range(len(pd)):
          if pd.values()[i-1].GetName()== NOM_CHAMP :
               NB_CMP = pd.values()[i-1].GetNumberOfComponents()
               NOM_CMP = pd.values()[i-1].GetComponentName(0)
               RANGE_CMP = pd.values()[i-1].GetRange()

     # Attributs de visualisation
     CMP = 'Component'     
     TYPE = 'Point Sprite'


if CHOIXF == 'GAUSS' :

     # Application filtre ELGA
     myResult.GenerateVectors = 0
     resu = GaussPoints()
     resu.SelectSourceArray = ['CELLS', 'ELGA']
     if len (L_ELGA) > 0 :
          NOM_CHAMP = L_ELGA[0]
          pd = resu.PointData

     # Recuperation des informations du champ
     for i in range(len(pd)):
          if pd.values()[i-1].GetName()== NOM_CHAMP :
               NB_CMP = pd.values()[i-1].GetNumberOfComponents()
               NOM_CMP = pd.values()[i-1].GetComponentName(0)
               RANGE_CMP = pd.values()[i-1].GetRange()
               #print NB_CMP, NOM_CMP, RANGE_CMP

     # Attributs de visualisation
     CMP = 'Component'
     TYPE = 'Point Sprite'


if CHOIXF == 'DEPL' :

     # Generation des vecteurs et filtre WarpByVector
     myResult.GenerateVectors = 1
     resu = WarpByVector()
     pd = resu.PointData

     # Recuperation des informations du champ
     for i in range(len(pd)):
          if pd.values()[i-1].GetNumberOfComponents() == 3 :
               NOM_CHAMP = pd.values()[i-1].GetName()
               NB_CMP = pd.values()[i-1].GetNumberOfComponents()
               RANGE_CMP = pd.values()[i-1].GetRange()
               #print NB_CMP, RANGE_CMP, 
               #print NOM_CHAMP

     NOM_CHAMP_DEF = NOM_CHAMP
     MAX_CMP = max(abs(RANGE_CMP[0]),abs(RANGE_CMP[1]))
     if MAX_CMP == 0. : MAX_CMP = 1.
     SCALE_FACTOR = 1. / MAX_CMP

     # Attributs de visualisation
     CMP = 'Magnitude'
     TYPE = 'Surface With Edges'
     NOM_CMP =''
     


if CHOIXF =='ON_DEFORMED' :

     # Generation des vecteurs et filtre WarpByVector
     myResult.GenerateVectors = 1
     resu = myResult
     
     #resu = WarpByVector()
     #pd = resu.PointData
     
     # Recuperation des informations du champ
     if len(L_CELL) > 0 : 
        NOM_CHAMP = L_CELL[0]
        pd = resu.CellData
     else : 
        NOM_CHAMP = L_POIN[2]
        pd = resu.PointData

     for i in range(len(pd)) :
         #print i, pd.values()[i-1].GetName(),pd.values()[i-1].GetNumberOfComponents()
         if pd.values()[i-1].GetName() == NOM_CHAMP :
             #print pd.values()[i-1].GetName(),'COLOR'
             NOM_CMP = pd.values()[i-1].GetComponentName(0)
             NB_CMP = pd.values()[i-1].GetNumberOfComponents()
             RANGE_CMP = pd.values()[i-1].GetRange()
  
     # Recuperation des informations du champ DEPL
     resu = WarpByVector()
     pd1 = resu.PointData
     for i in range(len(pd1)) :
         # On ne considere pas le champ vecteur autre que DEPL
         if NOM_CHAMP not in pd1.values()[i-1].GetName() and pd1.values()[i-1].GetNumberOfComponents() == 3 :
              NOM_CHAMP_DEF = pd1.values()[i-1].GetName()
              RANGE_CMP_DEF = pd1.values()[i-1].GetRange()       
     
     MAX_CMP = max(abs(RANGE_CMP_DEF[0]),abs(RANGE_CMP_DEF[1]))
     if MAX_CMP == 0. : MAX_CMP = 1.
     SCALE_FACTOR = 1. / MAX_CMP
     
     # Attributs de visualisation
     CMP = 'Component'
     TYPE = 'Surface With Edges'


#%=============== Affichage ============================%
     
if CHOIXF != 'COURBE' :

     # Visualisation
     if NB_ORDRE > 1 :
          anim = GetAnimationScene()
          anim.Loop=1
          #anim.PlayMode = 'Sequence'
          #anim.NumberOfFrames = 50


     if CHOIXF == 'DEPL' or CHOIXF == 'ON_DEFORMED' :
          resu.Vectors = ['POINTS', NOM_CHAMP_DEF]
          resu.ScaleFactor = SCALE_FACTOR

     display = Show()
     display.ColorArrayName = NOM_CHAMP
     display.Representation = TYPE
     CH_PVLookupTable = GetLookupTableForArray( NOM_CHAMP, NB_CMP, VectorMode = CMP, RGBPoints=[RANGE_CMP[0], 0.0, 0.0, 1.0, RANGE_CMP[1], 1.0, 0.0, 0.0], ScalarRangeInitialized=1.0)
     display.LookupTable = CH_PVLookupTable
     display.LookupTable = CH_PVLookupTable

     if CHOIXF == 'GAUSS' or CHOIXF =='ELNO' :
          display.RadiusArray = [None, NOM_CHAMP]
          display.RadiusMode = 'Scalar'
          display.RadiusScalarRange = RANGE_CMP   

     scalarbar = CreateScalarBar(Title =NOM_CHAMP, ComponentTitle = NOM_CMP, LookupTable=CH_PVLookupTable, TitleFontSize=12 , LabelFontSize=12)
     view.Representations.append(scalarbar)


     Render()
     ResetCamera()
     if NB_ORDRE > 1 :
          anim.Play()

#%==================FIN ================================%