1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # T 2.23, 28: Displaying fields (scalar and vectorial) on nodes, change presentation options.
25 # Uses MED files ResOK_0000.med and Fields_group3D.med
26 # This script is equivalent to non-regression test script 003/A1
34 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
36 #%====================Stage1: Creating a new study====================%
38 print "**** Stage1: Creating a new study"
40 print "Creating a new study..................",
41 myVisu = visu_gui.myVisu
42 myVisu.SetCurrentStudy(salome.myStudy)
43 myViewManager = myVisu.GetViewManager()
44 if myViewManager is None : print "Error"
47 #%====================Stage2: Importing MED file====================%
49 print "**** Stage2: Importing MED file"
51 print 'Import "ResOK_0000.med"...............',
52 medFile = datadir + "ResOK_0000.med"
53 myResult = myVisu.ImportFile(medFile)
54 if myResult is None : print "Error"
57 print 'Creating new View3D...................',
58 myView = myViewManager.Create3DView()
59 if myView is None : print "Error"
63 myCellEntity = VISU.CELL
64 myNodeEntity = VISU.NODE
66 #%====================Stage3: Displaying vector field====================%
68 print "**** Stage3: Displaying vector field"
70 print "Creating Scalar Map.......",
71 scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
72 if scalarmap is None : print "Error"
74 scalarmap.SetSize(0.15, 0.8)
75 myView.DisplayOnly(scalarmap)
78 print "Creating Stream Lines.....",
79 streamlines = myVisu.StreamLinesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
80 if streamlines is None : print "Error"
82 myView.DisplayOnly(streamlines)
84 print "Creating Vectors..........",
85 vectors = myVisu.VectorsOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
86 if vectors is None : print "Error"
88 myView.DisplayOnly(vectors)
91 print "Creating Iso Surfaces.....",
92 isosurfaces = myVisu.IsoSurfacesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
93 if isosurfaces is None : print "Error"
95 myView.DisplayOnly(isosurfaces)
97 print "Creating Cut Planes.......",
98 cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
99 if cutplanes is None : print "Error"
101 cutplanes.SetNbPlanes(30)
102 cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
103 myView.DisplayOnly(cutplanes)
105 print "Creating Scalar Map On Deformed Shape.......",
106 scalarmapondefshape = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
107 if scalarmapondefshape is None : print "Error"
109 scalarmapondefshape.SetScalarField(myCellEntity,'pression',2);
110 myView.DisplayOnly(scalarmapondefshape)
112 #%====================Stage4: Opening a new study and Med file import====================%
114 # Opening a new study tempoparily commented due to a problem
115 # with python initialization. To be restored after bug 10000 fixing.
117 #print "**** Stage4: Opening a new study and Med file import"
118 print "**** Stage4: Med file import"
120 #print "Creating a new study..................",
121 #newStudy = salome.myStudyManager.NewStudy('newStudy')
122 newStudy = salome.myStudy # temporarily
123 #myVisu.SetCurrentStudy(newStudy)
124 myViewManager = myVisu.GetViewManager()
125 myView = myViewManager.Create3DView()
126 if myView is None : print "Error"
129 print 'Importing "Fields_group3D.med"........',
130 medFile = datadir + "Fields_group3D.med"
131 myResult1 = myVisu.ImportFile(medFile)
132 if myResult1 is None : print "Error"
133 myView1 = myViewManager.Create3DView()
134 if myView1 is None : print "Error"
137 #%====================Stage5: Displaying scalar field====================%
139 print "**** Stage5: Displaying scalar field"
141 myMeshName1 = 'mailles_MED'
143 print "Creating Scalar Map.......",
144 scalarmap1 = myVisu.ScalarMapOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
145 if scalarmap1 is None : print "Error"
147 myView1.DisplayOnly(scalarmap1)
150 print "Creating Iso Surfaces.....",
151 isosurfaces1 = myVisu.IsoSurfacesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
152 if isosurfaces1 is None : print "Error"
154 myView1.DisplayOnly(isosurfaces1)
156 print "Creating Cut Planes.......",
157 cutplanes1 = myVisu.CutPlanesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
158 if cutplanes1 is None : print "Error"
160 cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
161 myView1.DisplayOnly(cutplanes1)
163 print "Creating Scalar Map On Deformed Shape.......",
164 scalarmapondefshape1 = myVisu.DeformedShapeAndScalarMapOnField(myResult1,myMeshName1,myCellEntity,'vectoriel field',1);
165 if scalarmapondefshape1 is None : print "Error"
167 myView1.DisplayOnly(scalarmapondefshape1)
168 #%====================Stage6: Object browser popup====================%
170 print "**** Stage6: Object browser popup"
172 print "Creating mesh.............",
173 mesh = myVisu.MeshOnEntity(myResult1,myMeshName1,myCellEntity);
174 if mesh is None : print "Error"
176 myView1.DisplayOnly(mesh)
179 print "Changing type of presentation of mesh:"
180 mesh.SetPresentationType(VISU.WIREFRAME)
181 PrsType = mesh.GetPresentationType()
182 print "Presentation type..", PrsType
183 myView1.DisplayOnly(mesh)
185 mesh.SetPresentationType(VISU.SHADED)
186 PrsType = mesh.GetPresentationType()
187 print "Presentation type.....", PrsType
188 myView1.DisplayOnly(mesh)
190 mesh.SetPresentationType(VISU.POINT)
191 PrsType = mesh.GetPresentationType()
192 print "Presentation type......", PrsType
193 myView1.DisplayOnly(mesh)
196 mesh.SetPresentationType(VISU.SHRINK)
197 PrsType = mesh.GetPresentationType()
198 print "Presentation type.....", PrsType
199 myView1.DisplayOnly(mesh)
201 print "Changing color of mesh....",
202 aColor = SALOMEDS.Color(0,0,1)
203 mesh.SetCellColor(aColor)
204 myView1.DisplayOnly(mesh)
207 print "Renaming ScalarMap........",
208 SObj = newStudy.FindObjectIOR(scalarmap1.GetID())
209 newName = 'Renamed Object'
213 print "Deleting Cut Planes.......",
214 SObj = newStudy.FindObjectIOR(cutplanes1.GetID())
215 myBuilder = newStudy.NewBuilder()
216 myBuilder.RemoveObject(SObj)
219 print "Changing first IsoSurfaces",
220 myVisu.SetCurrentStudy(salome.myStudy)
221 myView.DisplayOnly(isosurfaces)
222 isosurfaces.SetNbSurfaces(25)
226 myView.DisplayOnly(isosurfaces)
228 print "Hide IsoSurfaces..........",
229 myView.Erase(isosurfaces)