Back to index

salome-paravis  6.5.0
B4.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/B4 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 "Hexa8.med"....................',
00034 
00035 file_path = datadir + "Hexa8.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: Color of Deformed Shape====================
00060 print "**** Stage3: Color of Deformed Shape"
00061 
00062 # Step1
00063 print "Getting the current color of Deformed Shape in RGB ... ",
00064 color = defshape.AmbientColor
00065 print color
00066 
00067 # Step2
00068 print "Set the positive color in RGB"
00069 color = [0.3, 0.3, 0.3]
00070 defshape.AmbientColor = color
00071 pvsimple.Render()
00072 
00073 color = defshape.AmbientColor
00074 print "Color: ", color
00075 
00076 # Step3
00077 print "Set the negative R and positive GB"
00078 color = [-0.3, 0.3, 0.3]
00079 defshape.AmbientColor = color
00080 pvsimple.Render()
00081 
00082 color = defshape.AmbientColor
00083 print "Color: ", color
00084 
00085 # Step4
00086 print "Set the negative R and positive GB"
00087 color = [0.3, -0.3, 0.3]
00088 defshape.AmbientColor = color
00089 pvsimple.Render()
00090 
00091 color = defshape.AmbientColor
00092 print "Color: ", color
00093 
00094 # Step5
00095 print "Set the negative B and positive RG"
00096 print "Set the negative R and positive GB"
00097 color = [0.3, 0.3, -0.3]
00098 defshape.AmbientColor = color
00099 pvsimple.Render()
00100 
00101 color = defshape.AmbientColor
00102 print "Color: ", color