Back to index

salome-paravis  6.5.0
A1.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 # This case corresponds to: /visu/SWIG_scripts/A1 case
00021 
00022 from paravistest import datadir
00023 from presentations import *
00024 import paravis
00025 import pvsimple
00026 
00027 
00028 my_paravis = paravis.myParavis
00029 
00030 #====================Stage1: Importing MED file====================
00031 
00032 print "**** Stage1: Importing MED file"
00033 
00034 print 'Import "ResOK_0000.med"...............',
00035 file_path = datadir + "ResOK_0000.med"
00036 my_paravis.ImportFile(file_path)
00037 med_reader = pvsimple.GetActiveSource()
00038 
00039 if med_reader is None:
00040     print "FAILED"
00041 else:
00042     print "OK"
00043 
00044 cell_entity = EntityType.CELL
00045 node_entity = EntityType.NODE
00046 
00047 #====================Stage2: Displaying vector field===============
00048 
00049 print "**** Stage3: Displaying vector field"
00050 
00051 print 'Get view...................',
00052 view = pvsimple.GetRenderView()
00053 if view is None:
00054     print "FAILED"
00055 else:
00056     reset_view(view)
00057     print "OK"
00058 
00059 print "Creating Scalar Map.......",
00060 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
00061 if scalarmap is None:
00062     print "FAILED"
00063 else:
00064     bar = get_bar()
00065     bar.Orientation = 'Horizontal'
00066     bar.Position = [0.1, 0.1]
00067     bar.Position2 = [0.1, 0.25]
00068     bar.AspectRatio = 3
00069 
00070     display_only(scalarmap, view)
00071     print "OK"
00072 
00073 view.ResetCamera()
00074 
00075 print "Creating Stream Lines.....",
00076 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
00077 if streamlines is None:
00078     print "FAILED"
00079 else:
00080     display_only(streamlines, view)
00081     print "OK"
00082 
00083 print "Creating Vectors..........",
00084 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
00085 if vectors is None:
00086     print "FAILED"
00087 else:
00088     display_only(vectors, view)
00089     print "OK"
00090 
00091 print "Creating Iso Surfaces.....",
00092 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
00093 if isosurfaces is None:
00094     print "FAILED"
00095 else:
00096     display_only(isosurfaces, view)
00097     print "OK"
00098 
00099 print "Creating Cut Planes.......",
00100 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
00101                              nb_planes=30, orientation=Orientation.YZ)
00102 if cutplanes is None:
00103     print "FAILED"
00104 else:
00105     display_only(cutplanes, view)
00106     print "OK"
00107 
00108 print "Creating Scalar Map On Deformed Shape.......",
00109 scalarmapondefshape = DeformedShapeAndScalarMapOnField(med_reader,
00110                                                        node_entity,
00111                                                        'vitesse', 2,
00112                                                        None,
00113                                                        cell_entity,
00114                                                        'pression')
00115 if scalarmapondefshape is None:
00116     print "FAILED"
00117 else:
00118     display_only(scalarmapondefshape, view)
00119     print "OK"
00120 
00121 #====================Stage3: Another Med file import====================
00122 
00123 print 'Import "Fields_group3D.med"...............',
00124 file_path = datadir + "Fields_group3D.med"
00125 my_paravis.ImportFile(file_path)
00126 med_reader1 = pvsimple.GetActiveSource()
00127 
00128 if med_reader1 is None:
00129     print "FAILED"
00130 else:
00131     print "OK"
00132 
00133 #====================Stage4: Displaying scalar field====================
00134 
00135 print "**** Stage4: Displaying scalar field"
00136 
00137 print "Creating Scalar Map.......",
00138 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar_field', 1)
00139 if scalarmap1 is None:
00140     print "FAILED"
00141 else:
00142     display_only(scalarmap1, view)
00143     print "OK"
00144 
00145 view.ResetCamera()
00146 
00147 print "Creating Iso Surfaces.....",
00148 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar_field', 1)
00149 if isosurfaces1 is None:
00150     print "FAILED"
00151 else:
00152     display_only(isosurfaces1, view)
00153     print "OK"
00154 
00155 print "Creating Cut Planes.......",
00156 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar_field', 1,
00157                               orientation=Orientation.YZ)
00158 if cutplanes1 is None:
00159     print "FAILED"
00160 else:
00161     print "OK"
00162 
00163 slice_filter = pvsimple.GetActiveSource()
00164 slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
00165 display_only(cutplanes1, view)
00166 
00167 print "Creating Scalar Map On Deformed Shape.......",
00168 scalarmapondefshape1 = DeformedShapeAndScalarMapOnField(med_reader1,
00169                                                         cell_entity,
00170                                                         'vectoriel_field', 1)
00171 if scalarmapondefshape1 is None:
00172     print "FAILED"
00173 else:
00174     display_only(scalarmapondefshape1, view)
00175     print "OK"
00176 
00177 #====================Stage5: Object browser popup====================
00178 
00179 print "**** Stage5: Object browser popup"
00180 
00181 print "Creating mesh.............",
00182 
00183 mesh_name = 'mailles_MED'
00184 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
00185 if mesh is None:
00186     print "FAILED"
00187 else:
00188     display_only(mesh, view)
00189     print "OK"
00190 
00191 print "Changing type of presentation of mesh:"
00192 mesh.Representation = 'Wireframe'
00193 pvsimple.Render()
00194 prs_type = mesh.Representation
00195 print "Presentation type..", prs_type
00196 
00197 mesh.Representation = 'Points'
00198 pvsimple.Render()
00199 prs_type = mesh.Representation
00200 print "Presentation type..", prs_type
00201 
00202 mesh.Representation = 'Surface'
00203 pvsimple.Render()
00204 prs_type = mesh.Representation
00205 print "Presentation type..", prs_type
00206 
00207 shrink = pvsimple.Shrink(med_reader1)
00208 mesh_shrinked = pvsimple.GetRepresentation(shrink)
00209 display_only(mesh_shrinked, view)
00210 
00211 print "Changing color of mesh....",
00212 color = [0, 0, 1]
00213 mesh.DiffuseColor = color
00214 display_only(mesh, view)
00215 print "OK"