1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 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
23 # T 2.23, 28: Displaying fields (scalar and vectorial) on nodes, change presentation options.
24 # Uses MED files ResOK_0000.med and Fields_group3D.med
25 # This script is equivalent to non-regression test script 003/A1
33 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
35 #%====================Stage1: Creating a new study====================%
37 print "**** Stage1: Creating a new study"
39 print "Creating a new study..................",
40 myVisu = visu_gui.myVisu
41 myVisu.SetCurrentStudy(salome.myStudy)
42 myViewManager = myVisu.GetViewManager()
43 if myViewManager is None : print "Error"
46 #%====================Stage2: Importing MED file====================%
48 print "**** Stage2: Importing MED file"
50 print 'Import "ResOK_0000.med"...............',
51 medFile = datadir + "ResOK_0000.med"
52 myResult = myVisu.ImportFile(medFile)
53 if myResult is None : print "Error"
56 print 'Creating new View3D...................',
57 myView = myViewManager.Create3DView()
58 if myView is None : print "Error"
62 myCellEntity = VISU.CELL
63 myNodeEntity = VISU.NODE
65 #%====================Stage3: Displaying vector field====================%
67 print "**** Stage3: Displaying vector field"
69 print "Creating Scalar Map.......",
70 scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
71 if scalarmap is None : print "Error"
73 scalarmap.SetSize(0.15, 0.8)
74 myView.DisplayOnly(scalarmap)
77 print "Creating Stream Lines.....",
78 streamlines = myVisu.StreamLinesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
79 if streamlines is None : print "Error"
81 myView.DisplayOnly(streamlines)
83 print "Creating Vectors..........",
84 vectors = myVisu.VectorsOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
85 if vectors is None : print "Error"
87 myView.DisplayOnly(vectors)
90 print "Creating Iso Surfaces.....",
91 isosurfaces = myVisu.IsoSurfacesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
92 if isosurfaces is None : print "Error"
94 myView.DisplayOnly(isosurfaces)
96 print "Creating Cut Planes.......",
97 cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
98 if cutplanes is None : print "Error"
100 cutplanes.SetNbPlanes(30)
101 cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
102 myView.DisplayOnly(cutplanes)
104 print "Creating Scalar Map On Deformed Shape.......",
105 scalarmapondefshape = myVisu.DeformedShapeAndScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
106 if scalarmapondefshape is None : print "Error"
108 scalarmapondefshape.SetScalarField(myCellEntity,'pression',2);
109 myView.DisplayOnly(scalarmapondefshape)
111 #%====================Stage4: Opening a new study and Med file import====================%
113 # Opening a new study tempoparily commented due to a problem
114 # with python initialization. To be restored after bug 10000 fixing.
116 #print "**** Stage4: Opening a new study and Med file import"
117 print "**** Stage4: Med file import"
119 #print "Creating a new study..................",
120 #newStudy = salome.myStudyManager.NewStudy('newStudy')
121 newStudy = salome.myStudy # temporarily
122 #myVisu.SetCurrentStudy(newStudy)
123 myViewManager = myVisu.GetViewManager()
124 myView = myViewManager.Create3DView()
125 if myView is None : print "Error"
128 print 'Importing "Fields_group3D.med"........',
129 medFile = datadir + "Fields_group3D.med"
130 myResult1 = myVisu.ImportFile(medFile)
131 if myResult1 is None : print "Error"
132 myView1 = myViewManager.Create3DView()
133 if myView1 is None : print "Error"
136 #%====================Stage5: Displaying scalar field====================%
138 print "**** Stage5: Displaying scalar field"
140 myMeshName1 = 'mailles_MED'
142 print "Creating Scalar Map.......",
143 scalarmap1 = myVisu.ScalarMapOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
144 if scalarmap1 is None : print "Error"
146 myView1.DisplayOnly(scalarmap1)
149 print "Creating Iso Surfaces.....",
150 isosurfaces1 = myVisu.IsoSurfacesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
151 if isosurfaces1 is None : print "Error"
153 myView1.DisplayOnly(isosurfaces1)
155 print "Creating Cut Planes.......",
156 cutplanes1 = myVisu.CutPlanesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
157 if cutplanes1 is None : print "Error"
159 cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
160 myView1.DisplayOnly(cutplanes1)
162 print "Creating Scalar Map On Deformed Shape.......",
163 scalarmapondefshape1 = myVisu.DeformedShapeAndScalarMapOnField(myResult1,myMeshName1,myCellEntity,'vectoriel field',1);
164 if scalarmapondefshape1 is None : print "Error"
166 myView1.DisplayOnly(scalarmapondefshape1)
167 #%====================Stage6: Object browser popup====================%
169 print "**** Stage6: Object browser popup"
171 print "Creating mesh.............",
172 mesh = myVisu.MeshOnEntity(myResult1,myMeshName1,myCellEntity);
173 if mesh is None : print "Error"
175 myView1.DisplayOnly(mesh)
178 print "Changing type of presentation of mesh:"
179 mesh.SetPresentationType(VISU.WIREFRAME)
180 PrsType = mesh.GetPresentationType()
181 print "Presentation type..", PrsType
182 myView1.DisplayOnly(mesh)
184 mesh.SetPresentationType(VISU.SHADED)
185 PrsType = mesh.GetPresentationType()
186 print "Presentation type.....", PrsType
187 myView1.DisplayOnly(mesh)
189 mesh.SetPresentationType(VISU.POINT)
190 PrsType = mesh.GetPresentationType()
191 print "Presentation type......", PrsType
192 myView1.DisplayOnly(mesh)
195 mesh.SetPresentationType(VISU.SHRINK)
196 PrsType = mesh.GetPresentationType()
197 print "Presentation type.....", PrsType
198 myView1.DisplayOnly(mesh)
200 print "Changing color of mesh....",
201 aColor = SALOMEDS.Color(0,0,1)
202 mesh.SetCellColor(aColor)
203 myView1.DisplayOnly(mesh)
206 print "Renaming ScalarMap........",
207 SObj = newStudy.FindObjectIOR(scalarmap1.GetID())
208 newName = 'Renamed Object'
212 print "Deleting Cut Planes.......",
213 SObj = newStudy.FindObjectIOR(cutplanes1.GetID())
214 myBuilder = newStudy.NewBuilder()
215 myBuilder.RemoveObject(SObj)
218 print "Changing first IsoSurfaces",
219 myVisu.SetCurrentStudy(salome.myStudy)
220 myView.DisplayOnly(isosurfaces)
221 isosurfaces.SetNbSurfaces(25)
225 myView.DisplayOnly(isosurfaces)
227 print "Hide IsoSurfaces..........",
228 myView.Erase(isosurfaces)