Back to index

salome-paravis  6.5.0
F9.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/Vectors/F9 case
00021 # Create Vectors for field of the the given MED file for 10 timestamps%
00022 
00023 import sys
00024 from paravistest import datadir, pictureext, get_picture_dir
00025 import paravis
00026 from pvsimple import GetActiveSource, GetRenderView, Render
00027 from presentations import VectorsOnField, hide_all,EntityType,PrsTypeEnum,reset_view,process_prs_for_test
00028 
00029 # Create presentations
00030 myParavis = paravis.myParavis
00031 
00032 picturedir = get_picture_dir(sys.argv[1], "Vectors/F9")
00033 
00034 theFileName = datadir +  "Bug829_resu_mode.med"
00035 print " --------------------------------- "
00036 print "file ", theFileName
00037 print " --------------------------------- "
00038 
00039 """Build presentations of the given types for all fields of the given file."""
00040 #print "Import %s..." % theFileName.split('/')[-1],
00041 result = myParavis.ImportFile(theFileName)
00042 aProxy = GetActiveSource()
00043 if aProxy is None:
00044        raise RuntimeError, "Error: can't import file."
00045 else: print "OK"
00046 # Get view
00047 aView = GetRenderView()
00048 
00049 # Create required presentations for the proxy
00050 # CreatePrsForProxy(aProxy, aView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete)
00051 aFieldNames = aProxy.PointArrays.GetData()
00052 aNbOnNodes = len(aFieldNames)
00053 aFieldNames.extend(aProxy.CellArrays.GetData())
00054 aTimeStamps = aProxy.TimestepValues.GetData()
00055 aFieldEntity = EntityType.NODE
00056 aFieldName = "MODES_DEPL"
00057 
00058 #Creation of a set of non-colored and then colored Vectors presentations, based on time stamps of MODES_DEP field
00059 for colored in [False,True]:
00060     colored_str = "_non-colored"
00061     if colored:
00062         colored_str = "_colored"
00063     for i in range(1,11):
00064         hide_all(aView, True)
00065         aPrs = VectorsOnField(aProxy, aFieldEntity, aFieldName, i, is_colored=colored)     
00066         if aPrs is None:
00067             raise RuntimeError, "Presentation is None!!!"
00068         # display only current deformed shape
00069         #display_only(aView,aPrs)
00070         aPrs.Visibility =1  
00071         reset_view(aView)
00072         Render(aView)
00073         # Add path separator to the end of picture path if necessery
00074         if not picturedir.endswith(os.sep):
00075                 picturedir += os.sep
00076         prs_type = PrsTypeEnum.VECTORS
00077                 
00078         # Get name of presentation type
00079         prs_name = PrsTypeEnum.get_name(prs_type)    
00080         f_prs_type = prs_name.replace(' ', '').upper()
00081         # Construct image file name
00082         pic_name = picturedir + aFieldName+colored_str + "_" + str(i) + "_" + f_prs_type + "." + pictureext
00083         # Show and record the presentation
00084         process_prs_for_test(aPrs, aView, pic_name)
00085