1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # T 2.23, 28: Displaying fields (scalar and vectorial) on nodes, change presentation options.
21 # Uses MED files ResOK_0000.med and Fields_group3D.med
23 # This script is equivalent to non-regression test script 003/A1
31 datadir = os.getenv("DATA_DIR") + "/MedFiles/"
33 #%====================Stage1: Creating a new study====================%
35 print "**** Stage1: Creating a new study"
37 print "Creating a new study..................",
38 myVisu = visu_gui.myVisu
39 myVisu.SetCurrentStudy(salome.myStudy)
40 myViewManager = myVisu.GetViewManager()
41 if myViewManager is None : print "Error"
44 #%====================Stage2: Importing MED file====================%
46 print "**** Stage2: Importing MED file"
48 print 'Import "ResOK_0000.med"...............',
49 medFile = datadir + "ResOK_0000.med"
50 myResult = myVisu.ImportFile(medFile)
51 if myResult is None : print "Error"
54 print 'Creating new View3D...................',
55 myView = myViewManager.Create3DView()
56 if myView is None : print "Error"
60 myCellEntity = VISU.CELL
61 myNodeEntity = VISU.NODE
63 #%====================Stage3: Displaying vector field====================%
65 print "**** Stage3: Displaying vector field"
67 print "Creating Scalar Map.......",
68 scalarmap = myVisu.ScalarMapOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
69 if scalarmap is None : print "Error"
71 scalarmap.SetSize(0.15, 0.8)
72 myView.DisplayOnly(scalarmap)
75 print "Creating Stream Lines.....",
76 streamlines = myVisu.StreamLinesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
77 if streamlines is None : print "Error"
79 myView.DisplayOnly(streamlines)
81 print "Creating Vectors..........",
82 vectors = myVisu.VectorsOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
83 if vectors is None : print "Error"
85 myView.DisplayOnly(vectors)
88 print "Creating Iso Surfaces.....",
89 isosurfaces = myVisu.IsoSurfacesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
90 if isosurfaces is None : print "Error"
92 myView.DisplayOnly(isosurfaces)
94 print "Creating Cut Planes.......",
95 cutplanes = myVisu.CutPlanesOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
96 if cutplanes is None : print "Error"
98 cutplanes.SetNbPlanes(30)
99 cutplanes.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
100 myView.DisplayOnly(cutplanes)
102 print "Creating Scalar Map On Deformed Shape.......",
103 scalarmapondefshape = myVisu.ScalarMapOnDeformedShapeOnField(myResult,myMeshName,myNodeEntity,'vitesse',1);
104 if scalarmapondefshape is None : print "Error"
106 scalarmapondefshape.SetScalarField(myMeshName,'pression',2,myCellEntity);
107 myView.DisplayOnly(scalarmapondefshape)
109 #%====================Stage4: Opening a new study and Med file import====================%
111 # Opening a new study tempoparily commented due to a problem
112 # with python initialization. To be restored after bug 10000 fixing.
114 #print "**** Stage4: Opening a new study and Med file import"
115 print "**** Stage4: Med file import"
117 #print "Creating a new study..................",
118 #newStudy = salome.myStudyManager.NewStudy('newStudy')
119 newStudy = salome.myStudy # temporarily
120 #myVisu.SetCurrentStudy(newStudy)
121 myViewManager = myVisu.GetViewManager()
122 myView = myViewManager.Create3DView()
123 if myView is None : print "Error"
126 print 'Importing "Fields_group3D.med"........',
127 medFile = datadir + "Fields_group3D.med"
128 myResult1 = myVisu.ImportFile(medFile)
129 if myResult1 is None : print "Error"
130 myView1 = myViewManager.Create3DView()
131 if myView1 is None : print "Error"
134 #%====================Stage5: Displaying scalar field====================%
136 print "**** Stage5: Displaying scalar field"
138 myMeshName1 = 'mailles_MED'
140 print "Creating Scalar Map.......",
141 scalarmap1 = myVisu.ScalarMapOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
142 if scalarmap1 is None : print "Error"
144 myView1.DisplayOnly(scalarmap1)
147 print "Creating Iso Surfaces.....",
148 isosurfaces1 = myVisu.IsoSurfacesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
149 if isosurfaces1 is None : print "Error"
151 myView1.DisplayOnly(isosurfaces1)
153 print "Creating Cut Planes.......",
154 cutplanes1 = myVisu.CutPlanesOnField(myResult1,myMeshName1,myCellEntity,'scalar field',1);
155 if cutplanes1 is None : print "Error"
157 cutplanes1.SetOrientation(VISU.CutPlanes.YZ, 0, 0)
158 myView1.DisplayOnly(cutplanes1)
160 print "Creating Scalar Map On Deformed Shape.......",
161 scalarmapondefshape1 = myVisu.ScalarMapOnDeformedShapeOnField(myResult1,myMeshName1,myCellEntity,'vectoriel field',1);
162 if scalarmapondefshape1 is None : print "Error"
164 myView1.DisplayOnly(scalarmapondefshape1)
165 #%====================Stage6: Object browser popup====================%
167 print "**** Stage6: Object browser popup"
169 print "Creating mesh.............",
170 mesh = myVisu.MeshOnEntity(myResult1,myMeshName1,myCellEntity);
171 if mesh is None : print "Error"
173 myView1.DisplayOnly(mesh)
176 print "Changing type of presentation of mesh:"
177 mesh.SetPresentationType(VISU.WIREFRAME)
178 PrsType = mesh.GetPresentationType()
179 print "Presentation type..", PrsType
180 myView1.DisplayOnly(mesh)
182 mesh.SetPresentationType(VISU.SHADED)
183 PrsType = mesh.GetPresentationType()
184 print "Presentation type.....", PrsType
185 myView1.DisplayOnly(mesh)
187 mesh.SetPresentationType(VISU.POINT)
188 PrsType = mesh.GetPresentationType()
189 print "Presentation type......", PrsType
190 myView1.DisplayOnly(mesh)
193 mesh.SetPresentationType(VISU.SHRINK)
194 PrsType = mesh.GetPresentationType()
195 print "Presentation type.....", PrsType
196 myView1.DisplayOnly(mesh)
198 print "Changing color of mesh....",
199 aColor = SALOMEDS.Color(0,0,1)
200 mesh.SetCellColor(aColor)
201 myView1.DisplayOnly(mesh)
204 print "Renaming ScalarMap........",
205 SObj = newStudy.FindObjectIOR(scalarmap1.GetID())
206 newName = 'Renamed Object'
210 print "Deleting Cut Planes.......",
211 SObj = newStudy.FindObjectIOR(cutplanes1.GetID())
212 myBuilder = newStudy.NewBuilder()
213 myBuilder.RemoveObject(SObj)
216 print "Changing first IsoSurfaces",
217 myVisu.SetCurrentStudy(salome.myStudy)
218 myView.DisplayOnly(isosurfaces)
219 isosurfaces.SetNbSurfaces(25)
223 myView.DisplayOnly(isosurfaces)
225 print "Hide IsoSurfaces..........",
226 myView.Erase(isosurfaces)