Back to index

salome-paravis  6.5.0
A3.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/3D_viewer/A3 case
00021 # Create 3D Viewer and test set view properties for Stream Lines presentation
00022 # Author: POLYANSKIKH VERA
00023 from paravistest import *
00024 from presentations import *
00025 from pvsimple import *
00026 import sys
00027 import paravis
00028 import time
00029 
00030 # Directory for saving snapshots
00031 picturedir = get_picture_dir(sys.argv[1], "3D_viewer/A3")
00032 
00033 # Add path separator to the end of picture path if necessery
00034 if not picturedir.endswith(os.sep):
00035     picturedir += os.sep
00036 
00037 #import file
00038 my_paravis = paravis.myParavis
00039 
00040 # Get view
00041 my_view = GetRenderView()
00042 reset_view(my_view)
00043 Render(my_view)
00044 
00045 file_name = datadir + "Penta6.med"
00046 print " --------------------------------- "
00047 print "file ", file_name
00048 print " --------------------------------- "
00049 
00050 my_paravis.ImportFile(file_name)
00051 proxy = GetActiveSource()
00052 if proxy is None:
00053     raise RuntimeError("Error: can't import file.")
00054 else:
00055     print "OK"
00056 
00057 represents = [RepresentationType.POINTS, RepresentationType.WIREFRAME,\
00058 RepresentationType.SURFACE, RepresentationType.VOLUME]
00059 shrinks = [0, 1]
00060 shadings = [0, 1]
00061 opacities = [1.0, 0.5, 0.0]
00062 linewidths = [1.0, 3.0, 10.0]
00063 compare_prec = 0.00001
00064 
00065 field_name = 'vectoriel_field'
00066 
00067 print "\nCreating stream_lines......."
00068 stream_lines = StreamLinesOnField(proxy, EntityType.CELL,
00069 field_name, 1, is_colored=True)
00070 stream_tracer = stream_lines.Input
00071 print "stream_tracer:", stream_tracer
00072 stream_tracer.Input = None
00073 stream_tracer.InitialStepLength = 0.00940275
00074 stream_tracer.MaximumStreamlineLength = 140.373
00075 stream_tracer.MaximumStepLength = 0.5319
00076 stream_tracer.MinimumStepLength = 0.5319
00077 stream_tracer.UpdatePipeline()
00078 
00079 if stream_lines is None:
00080     raise RuntimeError("Error!!! Presentation wasn't created...")
00081 
00082 display_only(stream_lines, my_view)
00083 reset_view(my_view)
00084 Render(my_view)
00085 
00086 print "\nChange Presentation Parameters..."
00087 
00088 for reprCode in represents:
00089     repr = RepresentationType.get_name(reprCode)
00090     if reprCode == RepresentationType.VOLUME:
00091         is_good = call_and_check(stream_lines, "Representation", repr, 0)
00092         if is_good:
00093             msg = "VOLUME representation must be not available for streamlines"
00094             raise RuntimeError(msg)
00095     else:
00096         call_and_check(stream_lines, "Representation", repr, 1)
00097 
00098         for sha in shadings:
00099             setShaded(my_view, sha)
00100             call_and_check(stream_lines, "Shading", sha, 1)
00101             Render(my_view)
00102             time.sleep(1)
00103 
00104             for lwi in linewidths:
00105                 call_and_check(stream_lines, "LineWidth", lwi, 1, compare_prec)
00106                 # save picture in file
00107                 # Construct image file name
00108                 pic_name = picturedir + "params_" + repr.replace(' ', '_') + "_any_" +  \
00109                     str(sha) + "_" + str(lwi) + "." + pictureext
00110                 # Show and record the presentation
00111                 process_prs_for_test(stream_lines, my_view, pic_name)
00112 
00113 for opa in opacities:
00114     call_and_check(stream_lines, "Opacity", opa, 1, compare_prec)