1 # Copyright (C) 2010-2016 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
20 # This case corresponds to: /visu/bugs2/C5 case
25 from paravistest import datadir
26 from presentations import *
33 Create 3D presentations on entities on a given med file and mesh
35 def __init__(self, medFile=None, meshName=None, myEntity=None):
36 if ( medFile is not None and meshName is not None and myEntity is not None):
37 self.loadData(medFile, meshName, myEntity)
45 def loadData(self, medFile, meshName=None, myEntity=EntityType.NODE):
46 self.medFile = medFile
47 pvsimple.OpenDataFile(medFile)
48 self.myData = pvsimple.GetActiveSource()
49 self.myEntity = myEntity
50 if meshName is not None:
51 self.setMesh(meshName)
57 if ( self.myData is None or self.myMesh is None ):
61 def setMesh(self,meshName):
62 self.meshName = meshName
63 self.myMesh = MeshOnEntity(self.myData,
66 self.myMesh.Representation = 'Surface'
68 def DisplayMap(self, aView, aMap, title, aDelay=0):
70 print "Null scalar map is created"
71 display_only(aMap, aView)
75 def ScalarMap(self, aView, fieldName, iteration, title , delay=0):
76 if not self.checkData(): return
77 aMap = ScalarMapOnField(self.myData, self.myEntity, fieldName, iteration)
78 self.DisplayMap(aView, aMap, title, delay)
80 def DeformedShape(self, aView, fieldName, iteration, title , delay=0):
81 if not self.checkData(): return
82 aMap = DeformedShapeOnField(self.myData, self.myEntity, fieldName, iteration)
84 aMap.ColorArrayName = ("CELLS", fieldName)
85 self.DisplayMap(aView, aMap, title, delay)
87 def Vectors(self, aView, fieldName, iteration, title , delay=0):
88 if not self.checkData(): return
89 aMap = VectorsOnField(self.myData, self.myEntity, fieldName, iteration)
91 aMap.ColorArrayName = ("CELLS", fieldName)
92 self.DisplayMap(aView, aMap, title, delay)
94 def IsoSurfaces(self, aView, fieldName, iteration, title , delay=0):
95 if not self.checkData(): return
96 aMap = IsoSurfacesOnField(self.myData, self.myEntity, fieldName, iteration)
97 self.DisplayMap(aView, aMap, title, delay)
99 def Animation(self, aView, theObj, theDuration, NbOfLoops, title, aPath=""):
103 print "Define save path"
106 scene = pvsimple.AnimateReader(theObj, aView, path)
108 print "Start Animation"
110 scene.Duration = theDuration
111 NbOfFrames = len(scene.TimeKeeper.TimestepValues)
112 NbOfIter = NbOfFrames-1
114 reset_view(view=aView)
117 while ind < NbOfLoops:
121 print "Stop Animation"
126 def XYPlot(self, myView, txtFile, theTableName, theDelay, theColor):
127 table = TableReader(FileName=txtFile)
130 myView = CreateXYPlotView()
131 myCurve = Show(table, view = myView)
134 aView=pvsimple.GetRenderView()
138 theEntity = EntityType.CELL
139 theMedFile = "TETRA_domaine_fluide.med"
140 theMedFile = os.path.join(medPath,theMedFile)
141 theMeshName = "Domaine_fluide"
142 theFieldName = "TempC"
145 #thePath = os.getenv("TMP_DIR")
146 thePrefix = "TestPngFromAnim"
147 thePath = os.path.join("/tmp", thePrefix)
150 displayMng = DisplayManager()
151 displayMng.loadData(theMedFile,theMeshName,theEntity)
152 ScalarMapOnField(displayMng.getData(), theEntity, theFieldName, 1)
154 myView = createView()
155 displayMng.Animation(myView, displayMng.getData(), theDuration, NbOfLoops, "", thePath)