Back to index

salome-paravis  6.5.0
B3.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/DeformedShape/B3 case
00021 
00022 from paravistest import datadir
00023 from presentations import DeformedShapeOnField, EntityType
00024 import paravis
00025 import pvsimple
00026 
00027 
00028 my_paravis = paravis.myParavis
00029 
00030 #====================Stage1: Import from MED file in ParaVis============
00031 print "**** Stage1: Import from MED file in ParaVis"
00032 
00033 print 'Import "Tria3.med"....................',
00034 
00035 file_path = datadir + "Tria3.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 #====================Stage2: Creating Deformed Shape====================
00045 print "**** Stage2: Creating Deformed Shape"
00046 
00047 print "Creating Deformed Shape...............",
00048 
00049 cell_entity = EntityType.CELL
00050 field_name = 'vectoriel_field'
00051 defshape = DeformedShapeOnField(med_reader, cell_entity, field_name, 1)
00052 pvsimple.ResetCamera()
00053 
00054 if defshape is None:
00055     print "FAILED"
00056 else:
00057     print "OK"
00058 
00059 #====================Stage3: Scale of Deformed Shape====================
00060 print "**** Stage3: Scale of Deformed Shape"
00061 
00062 warp_vector = pvsimple.GetActiveSource()
00063 print "Default scale: ", warp_vector.ScaleFactor
00064 
00065 print "Set positive scale of Deformed Shape"
00066 scale = 1
00067 warp_vector.ScaleFactor = scale
00068 
00069 pvsimple.Render()
00070 print "Scale: ", warp_vector.ScaleFactor
00071 
00072 print "Set negative scale of Deformed Shape"
00073 scale = -1
00074 warp_vector.ScaleFactor = scale
00075 
00076 pvsimple.Render()
00077 print "Scale: ", warp_vector.ScaleFactor
00078 
00079 print "Set zero scale of Deformed Shape"
00080 scale = 0
00081 warp_vector.ScaleFactor = scale
00082 
00083 pvsimple.Render()
00084 print "Scale: ", warp_vector.ScaleFactor
00085 
00086 #====================Stage4: Coloring method of Deformed Shape===========
00087 print "**** Stage4: Coloring of Deformed Shape"
00088 
00089 color_array = defshape.ColorArrayName
00090 if color_array:
00091     print "Default shape is colored by array: ", color_array
00092 else:
00093     print "Default shape is colored by solid color: ", defshape.AmbientColor
00094 
00095 print "Set colored by array mode    .... ",
00096 defshape.ColorArrayName = field_name
00097 pvsimple.Render()
00098 
00099 if defshape.ColorArrayName == field_name:
00100     print "OK"
00101 else:
00102     print "FAILED"
00103 
00104 print "Set colored by solid color mode .... ",
00105 defshape.ColorArrayName = ''
00106 pvsimple.Render()
00107 
00108 if defshape.ColorArrayName:
00109     print "FAILED"
00110 else:
00111     print "OK"