1 # Copyright (C) 2010-2014 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 *
30 my_paravis = paravis.myParavis
36 Create 3D presentations on entities on a given med file and mesh
38 def __init__(self, medFile=None, meshName=None, myEntity=None):
39 if ( medFile is not None and meshName is not None and myEntity is not None):
40 self.loadData(medFile, meshName, myEntity)
48 def loadData(self, medFile, meshName=None, myEntity=EntityType.NODE):
49 self.medFile = medFile
50 my_paravis.ImportFile(medFile)
51 self.myData = pvsimple.GetActiveSource()
52 self.myEntity = myEntity
53 if meshName is not None:
54 self.setMesh(meshName)
60 if ( self.myData is None or self.myMesh is None ):
64 def setMesh(self,meshName):
65 self.meshName = meshName
66 self.myMesh = MeshOnEntity(self.myData,
69 self.myMesh.Representation = 'Surface'
71 def DisplayMap(self, aView, aMap, title, aDelay=0):
73 print "Null scalar map is created"
74 display_only(aMap, aView)
78 def ScalarMap(self, aView, fieldName, iteration, title , delay=0):
79 if not self.checkData(): return
80 aMap = ScalarMapOnField(self.myData, self.myEntity, fieldName, iteration)
81 self.DisplayMap(aView, aMap, title, delay)
83 def DeformedShape(self, aView, fieldName, iteration, title , delay=0):
84 if not self.checkData(): return
85 aMap = DeformedShapeOnField(self.myData, self.myEntity, fieldName, iteration)
87 aMap.ColorArrayName = fieldName
88 self.DisplayMap(aView, aMap, title, delay)
90 def Vectors(self, aView, fieldName, iteration, title , delay=0):
91 if not self.checkData(): return
92 aMap = VectorsOnField(self.myData, self.myEntity, fieldName, iteration)
94 aMap.ColorArrayName = fieldName
95 self.DisplayMap(aView, aMap, title, delay)
97 def IsoSurfaces(self, aView, fieldName, iteration, title , delay=0):
98 if not self.checkData(): return
99 aMap = IsoSurfacesOnField(self.myData, self.myEntity, fieldName, iteration)
100 self.DisplayMap(aView, aMap, title, delay)
102 def Animation(self, aView, theObj, theDuration, NbOfLoops, title, aPath=""):
106 print "Define save path"
109 scene = pvsimple.AnimateReader(theObj, aView, path)
111 print "Start Animation"
113 scene.Duration = theDuration
114 NbOfFrames = len(scene.TimeKeeper.TimestepValues)
115 NbOfIter = NbOfFrames-1
117 reset_view(view=aView)
120 while ind < NbOfLoops:
124 print "Stop Animation"
129 def XYPlot(self, myView, txtFile, theTableName, theDelay, theColor):
130 table = TableReader(FileName=txtFile)
133 myView = CreateXYPlotView()
134 myCurve = Show(table, view = myView)
137 aView=pvsimple.GetRenderView()
141 theEntity = EntityType.CELL
142 theMedFile = "TETRA_domaine_fluide.med"
143 theMedFile = os.path.join(medPath,theMedFile)
144 theMeshName = "Domaine_fluide"
145 theFieldName = "TempC"
148 #thePath = os.getenv("TMP_DIR")
149 thePrefix = "TestPngFromAnim"
150 thePath = os.path.join("/tmp", thePrefix)
153 displayMng = DisplayManager()
154 displayMng.loadData(theMedFile,theMeshName,theEntity)
155 ScalarMapOnField(displayMng.getData(), theEntity, theFieldName, 1)
157 myView = createView()
158 displayMng.Animation(myView, displayMng.getData(), theDuration, NbOfLoops, "", thePath)