/usr/lib/aster/Templates/salomeScript.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 | # coding=utf-8
# CONFIGURATION MANAGEMENT OF EDF VERSION
# ======================================================================
# COPYRIGHT (C) 1991 - 2012 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())
import visu_gui
import VISU
import visu
myVisu = visu_gui.myVisu
myVisu.SetCurrentStudy(study)
else:
# Sinon on choisit etude courante
salome.salome_init()
import visu_gui
import VISU
import visu
myVisu = visu_gui.myVisu
myVisu.SetCurrentStudy(salome.myStudy)
# ou la premiere detectee ?
#Liste_Study = salome.myStudyManager.GetOpenStudies()
#NOM = Liste_Study[0]
#myVisu.SetCurrentStudy(salome.myStudyManager.GetStudyByName(NOM))
myViewManager = myVisu.GetViewManager()
if myViewManager is None : raise Exception("Erreur de creation de study")
#%===================Construction courbe======================%
if CHOIX=='COURBE':
table_txt = myVisu.ImportTables(INPUTFILE2,0)
if table_txt :
IsFound,aSObject = table_txt.FindSubObject(1)
if IsFound :
anID = aSObject.GetID()
table = myVisu.CreateTable(anID)
NRow = table.GetNbRows()
myContainer = myVisu.CreateContainer()
for i in range(2,NRow+1):
resu = myVisu.CreateCurve(table,1,i)
myContainer.AddCurve(resu)
#%====================Construction isovaleurs====================%
else :
myResult = myVisu.ImportFile(INPUTFILE2)
if myResult is None : raise Exception("Erreur de fichier MED")
MAILLAGE = myResult.GetMeshNames()[0]
LISTE_CHAMP_CELL = myResult.GetFields(MAILLAGE,VISU.CELL)
LISTE_CHAMP_NODE = myResult.GetFields(MAILLAGE,VISU.NODE)
resu=[]
resuanim=[]
# Si on n'est pas en DEPL, on a une visualisation par composante
# Si on est en DEPL, on a une visualisation de la deformee
# Si on a plusieurs instants, on a visualisation de type Presentation animee
if CHOIX =='ON_DEFORMED' :
if LISTE_CHAMP_NODE ==[] : raise Exception("Erreur de champ")
TYPE_ENTITE=VISU.NODE
NOM_CHAMP = LISTE_CHAMP_NODE[0]
NUM_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)[0]
L_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
nINST = len(L_INST)
if LISTE_CHAMP_CELL ==[] :
TYPE_SCAL=VISU.NODE
NOM_CHAMP_SCAL = LISTE_CHAMP_NODE[1]
else :
TYPE_SCAL=VISU.CELL
NOM_CHAMP_SCAL = LISTE_CHAMP_CELL[0]
nCMP=myResult.GetNumberOfComponents(MAILLAGE,TYPE_SCAL,NOM_CHAMP_SCAL)
name0=NOM_CHAMP_SCAL.rstrip('_')+'_'
name=MAILLAGE+'_'+NOM_CHAMP.rstrip('_')+'_'
for i in range(1,nCMP+1) :
if nINST == 1:
res = myVisu.DeformedShapeAndScalarMapOnField(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
res.SetScalarField(TYPE_SCAL,NOM_CHAMP_SCAL,NUM_INST)
res.SetTitle(name0+str(i))
res.SetScalarMode(i)
resu.append(res)
else :
res=VISU.ColoredPrs3dHolder.BasicInput(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
MyPres=myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
resanim = MyPres.CreateHolder(VISU.TDEFORMEDSHAPEANDSCALARMAP,res)
visu.SetName(resanim,name+str(i))
resanim.GetDevice().SetScalarField(TYPE_SCAL,NOM_CHAMP_SCAL,NUM_INST)
resanim.GetDevice().SetTitle(name0+str(i))
resanim.GetDevice().SetScalarMode(i)
resu.append(res)
resuanim.append(resanim)
if CHOIX == 'DEPL' :
TYPE_ENTITE=VISU.NODE
if LISTE_CHAMP_NODE ==[] : raise Exception("Erreur de champ")
NOM_CHAMP = LISTE_CHAMP_NODE[0]
NUM_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)[0]
L_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
nINST = len(L_INST)
nCMP=1
name0=NOM_CHAMP.rstrip('_')
name=MAILLAGE+'_'+name0
if nINST ==1:
res = myVisu.DeformedShapeOnField(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
res.ShowColored(True)
res.SetTitle(name0)
resu.append(res)
else :
res=VISU.ColoredPrs3dHolder.BasicInput(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
MyPres=myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
resanim = MyPres.CreateHolder(VISU.TDEFORMEDSHAPE,res)
visu.SetName(resanim,name)
resanim.GetDevice().ShowColored(True)
resanim.GetDevice().SetTitle(name0)
resu.append(res)
resuanim.append(resanim)
if CHOIX == 'GAUSS' :
TYPE_ENTITE=VISU.CELL
if LISTE_CHAMP_CELL ==[] : raise Exception("Erreur de champ")
NOM_CHAMP = LISTE_CHAMP_CELL[0]
NUM_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)[0]
L_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
nINST = len(L_INST)
nCMP=myResult.GetNumberOfComponents(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
name0=NOM_CHAMP.rstrip('_')+'_'
name=MAILLAGE+'_'+name0
for i in range(1,nCMP+1) :
if nINST == 1:
res = myVisu.GaussPointsOnField(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
res.SetIsDispGlobalScalarBar(False)
res.SetScalarMode(i)
res.SetTitle(name0+str(i))
resu.append(res)
else :
res=VISU.ColoredPrs3dHolder.BasicInput(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
MyPres=myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
resanim = MyPres.CreateHolder(VISU.TGAUSSPOINTS,res)
visu.SetName(resanim,name+str(i))
resanim.GetDevice().SetIsDispGlobalScalarBar(False)
resanim.GetDevice().SetScalarMode(i)
resanim.GetDevice().SetTitle(name0+str(i))
resu.append(res)
resuanim.append(resanim)
if CHOIX == 'ISO' :
if LISTE_CHAMP_CELL ==[] :
TYPE_ENTITE = VISU.NODE
if LISTE_CHAMP_NODE == [] : raise Exception("Erreur de champ")
NOM_CHAMP = LISTE_CHAMP_NODE[0]
else :
TYPE_ENTITE=VISU.CELL
NOM_CHAMP = LISTE_CHAMP_CELL[0]
NUM_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)[0]
L_INST = myResult.GetTimeStampNumbers(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
nINST = len(L_INST)
nCMP=myResult.GetNumberOfComponents(MAILLAGE,TYPE_ENTITE,NOM_CHAMP)
name0=NOM_CHAMP.rstrip('_')+'_'
name=MAILLAGE+'_'+name0
for i in range(1,nCMP+1) :
if nINST == 1:
res= myVisu.ScalarMapOnField(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
res.SetScalarMode(i)
res.SetTitle(name0+str(i))
resu.append(res)
else :
res=VISU.ColoredPrs3dHolder.BasicInput(myResult,MAILLAGE,TYPE_ENTITE,NOM_CHAMP,NUM_INST)
MyPres=myVisu.GetColoredPrs3dCache(myVisu.GetCurrentStudy())
resanim = MyPres.CreateHolder(VISU.TSCALARMAP,res)
visu.SetName(resanim,name+str(i))
resanim.GetDevice().SetScalarMode(i)
resanim.GetDevice().SetTitle(name0+str(i))
resu.append(res)
resuanim.append(resanim)
#%=============== Affichage ============================%
myView1 = myViewManager.GetCurrentView()
if CHOIX=='COURBE':
myView1 = myViewManager.CreateXYPlot()
myView1.Display(myContainer)
session = naming_service.Resolve('/Kernel/Session')
session.emitMessageOneWay("updateObjBrowser")
else :
if myView1 is None :
myView1 = myViewManager.Create3DView()
else :
if myView1.GetType() != VISU.TVIEW3D :
myView1 = myViewManager.Create3DView()
if myView1 is None : raise Exception("Erreur de vue VTK")
if nINST == 1 :
myView1.DisplayOnly(resu[nCMP-1])
myView1.FitAll()
else :
myView1.EraseAll()
#for anInfo in range(1,nINST+1) :
# resu[nCMP-1].myTimeStampNumber = anInfo
# resuanim[nCMP-1].Apply(resuanim[nCMP-1].GetDevice(),resu[nCMP-1], myView1)
resu[nCMP-1].myTimeStampNumber = nINST
resuanim[nCMP-1].Apply(resuanim[nCMP-1].GetDevice(),resu[nCMP-1], myView1)
myView1.FitAll()
#%==================FIN ================================%
|