if is_proportional:
mult = multiplier
- if mult is None:
+ if mult is None and data_range[1] != 0:
mult = abs(0.1 / data_range[1])
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusTransferFunctionMode = 'Table'
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusUseScalarRange = 1
- gausspnt.RadiusIsProportional = 1
- gausspnt.RadiusProportionalFactor = mult
+ if mult is not None:
+ gausspnt.RadiusIsProportional = 1
+ gausspnt.RadiusProportionalFactor = mult
else:
gausspnt.RadiusTransferFunctionEnabled = 0
gausspnt.RadiusMode = 'Constant'
if is_proportional:
mult = multiplier
- if mult is None:
+ if mult is None and data_range[1] != 0:
mult = abs(0.1 / data_range[1])
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusTransferFunctionMode = 'Table'
gausspnt.RadiusScalarRange = data_range
gausspnt.RadiusUseScalarRange = 1
- gausspnt.RadiusIsProportional = 1
- gausspnt.RadiusProportionalFactor = mult
+ if mult is not None:
+ gausspnt.RadiusIsProportional = 1
+ gausspnt.RadiusProportionalFactor = mult
else:
gausspnt.RadiusTransferFunctionEnabled = 0
gausspnt.RadiusMode = 'Constant'
proxy.UpdatePipeline()
# Get timestamps
- entity_data_info = proxy.GetCellDataInformation()
timestamps = proxy.TimestepValues.GetData()
for prs_type in prs_types:
if (scalar_range[0] == scalar_range[1]):
continue
print "Creating " + prs_name + " on " + field_name + ", time = " + str(time) + "... "
- prs = create_prs(prs_type, proxy,
- field_entity, field_name, timestamp_nb)
+ try:
+ prs = create_prs(prs_type, proxy,
+ field_entity, field_name, timestamp_nb)
+ except ValueError:
+ """ This exception comes from get_nb_components(...) function.
+ The reason of exception is an implementation of MEDReader
+ activating the first leaf when reading MED file (refer to
+ MEDFileFieldRepresentationTree::activateTheFirst() and
+ MEDFileFieldRepresentationTree::getTheSingleActivated(...) methods).
+ """
+ print "ValueError exception is catched"
+ continue
if prs is None:
print "FAILED"
continue
# Stream Lines creation
prs= StreamLinesOnField(aProxy,EntityType.NODE,'vitesse' , 1)
-prs.Visibility=1
+if prs is None:
+ # TODO: check why stream lines prs is empty
+ print "WARNING! StreamLines presentation wasn't created or is empty..."
+else:
+ prs.Visibility=1
aView.ResetCamera()
print "Creating an Animation.....................",
my_format = "jpeg"
from paravistest import datadir, Import_Med_Field
med_file = datadir + "ResOK_0000.med"
-field_names = ["temperature", "vitesse", "pression"]
-prs_list = [ [1,2,3,4,8], range(1,10), [0,1,2,3,4,8] ]
+field_names1 = ["temperature", "vitesse", "pression"]
+prs_list1 = [ [1,2,3,4,8], [1,2,3,4,5,6,8,9], [0,1,2,3,4,8] ]
-Import_Med_Field(med_file, field_names, 1, prs_list)
+Import_Med_Field(med_file, field_names1, 1, prs_list1)
+
+# Stream Lines presentation on "vitesse" field is created
+# by ParaView as an empty presentation: no any cells or points.
+# TODO: check why presentation is empty.
+field_names2 = ["vitesse"]
+prs_list2 = [ [7] ]
+
+Import_Med_Field(med_file, field_names2, 0, prs_list2)
# This case corresponds to: /visu/SWIG_scripts/A8 case
# Create table
-# Do not use pv as a short name.
-# It is a name of function from numpy and may be redefined implicitly by 'from numpy import *' call.
-# import paraview.simple as pv
-import paraview.simple as pvs
-import paraview.servermanager as sm
-
+import pvsimple
# Define script for table creation
script = """
"""
# Creating programmable source (table)
-ps = pvs.ProgrammableSource()
+ps = pvsimple.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pvs.RenameSource("Very useful data", ps)
+pvsimple.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
# This case corresponds to: /visu/SWIG_scripts/C3 case
# Create table and display curves
-# Do not use pv as a short name.
-# It is a name of function from numpy and may be redefined implicitly by 'from numpy import *' call.
-# import paraview.simple as pv
-import paraview.simple as pvs
-import paraview.servermanager as sm
-
+import pvsimple
# Define script for table creation
script = """
"""
# Creating programmable source (table)
-ps = pvs.ProgrammableSource()
+ps = pvsimple.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pvs.RenameSource("Very useful data", ps)
+pvsimple.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
# Display table
# TODO: no possibility to create spreadsheet view
# Display curves
-xy_view = pvs.CreateXYPlotView()
+xy_view = pvsimple.CreateXYPlotView()
xy_view.ChartTitle = 'Very useful data'
-xy_view.AxisTitle = ['[ Wt ]', 'Frequency [ Hz ]']
+xy_view.BottomAxisTitle = '[ Wt ]'
+xy_view.LeftAxisTitle = 'Frequency [ Hz ]'
-xy_rep = pvs.Show(ps)
+xy_rep = pvsimple.Show(ps)
xy_rep.AttributeType = 'Row Data'
xy_rep.UseIndexForXAxis = 0
xy_rep.XArrayName = 'Frequency'
xy_rep.SeriesVisibility = ['Frequency', '0']
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
# Hide legend
xy_view.ShowLegend = 0
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
-# Set logarithmic scaling for X axis
-xy_view.AxisLogScale[1] = 1
-pvs.Render(xy_view)
+# Set logarithmic scaling for Y axis
+xy_view.LeftAxisLogScale = 1
+pvsimple.Render(xy_view)
-# Set linear scaling for X axis
-xy_view.AxisLogScale[1] = 0
-pvs.Render(xy_view)
+# Set linear scaling for Y axis
+xy_view.LeftAxisLogScale = 0
+pvsimple.Render(xy_view)
# Set logarithmic scaling for X axis
-xy_view.AxisLogScale[0] = 1
-pvs.Render(xy_view)
+xy_view.BottomAxisLogScale = 1
+pvsimple.Render(xy_view)
# Show legend
xy_view.ShowLegend = 1
-pvs.Render(xy_view)
+pvsimple.Render(xy_view)
samples_dir = os.getenv("DATA_DIR")
datadir = None
tablesdir = None
+texturesdir = None
if samples_dir is not None:
samples_dir = os.path.normpath(samples_dir)
datadir = samples_dir + "/MedFiles/"
tablesdir = samples_dir + "/Tables/"
+ texturesdir = samples_dir + "/Textures/"
# Graphics files extension
pictureext = os.getenv("PIC_EXT")
err = nb_errors
for type in prs[i]:
- if type==0:
- if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
- if type==1:
- if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
- if type==2:
- if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
- if type==3:
- if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
- if type==4:
- if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
- if type==5:
- if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
- if type==6:
- if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
- if type==7:
- if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
- if type==8:
- if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
- if type==9:
- if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
- print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
+ try:
+ if type==0:
+ if presentations.GaussPointsOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created GaussPoints presentation is None!!!"; nb_errors+=1
+ if type==1:
+ if presentations.ScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created ScalarMap presentation is None!!!"; nb_errors+=1
+ if type==2:
+ if presentations.IsoSurfacesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created IsoSurfaces presentation is None!!!"; nb_errors+=1
+ if type==3:
+ if presentations.CutPlanesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created CutPlanes presentation is None!!!"; nb_errors+=1
+ if type==4:
+ if presentations.CutLinesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created CutLines presentation is None!!!"; nb_errors+=1
+ if type==5:
+ if presentations.DeformedShapeOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created DeformedShape presentation is None!!!"; nb_errors+=1
+ if type==6:
+ if presentations.VectorsOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created Vectors presentation is None!!!"; nb_errors+=1
+ if type==7:
+ if presentations.StreamLinesOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created StreamLines presentation is None!!!"; nb_errors+=1
+ if type==8:
+ if presentations.Plot3DOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created Plot3D presentation is None!!!"; nb_errors+=1
+ if type==9:
+ if presentations.DeformedShapeAndScalarMapOnField(proxy, entity, field_names[i], iteration) is None:
+ print "ERROR!!! Created ScalarMapOnDeformedShape presentation is None!!!"; nb_errors+=1
+ except ValueError:
+ """ This exception comes from get_nb_components(...) function.
+ The reason of exception is an implementation of MEDReader
+ activating the first leaf when reading MED file (refer to
+ MEDFileFieldRepresentationTree::activateTheFirst() and
+ MEDFileFieldRepresentationTree::getTheSingleActivated(...) methods).
+ """
+ print "ValueError exception is catched"
+ continue
# check if number of errors has increased
if err == nb_errors:
return result_name
+#
+# NB! An 'Unknown exception' is raised, when a user try to open
+# "Bug619-result_calcul_OCC.med" file in MED module via 'Add Data Source' functionality.
+# Refer to LastTest.log file for more information.
+# TODO: check MedReader pb.
+#
# 1. Import of the "Bug619-result_calcul_OCC.med" file
med_file_path = datadir + "Bug619-result_calcul_OCC.med"
prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
if prs is None:
print "ERROR!!! ", name," presentation wasn't created..."
- errors += 1
+ # StreamLines presentation is empty for "vitesse" field defined in the loaded MED file.
+ # TODO: check why stream lines prs is empty
+ if name == "StreamLines":
+ print "WARNING: Stream lines presentation is empty!"
+ else:
+ errors += 1
else:
RenameSource(name, prs.Input)
prs_list.append(prs)
# This case corresponds to: /visu/imps/B1 case
-from paravistest import datadir
+from paravistest import datadir, texturesdir
from presentations import *
import pvsimple
# Set texture
scalarmap.RenderMode = 'Texture'
-scalarmap.Texture = [os.path.join(datadir, "Textures", "texture1.dat")]
+# COMMENTED OUT! Currently this does not work as Point Sprite ParaView plugin is not correctly wrapped to Python.
+# As soon as problem is fixed, below code probably need to be modified, but it should be something similar.
+#import vtk
+#texture = vtk.vtkTexture()
+#pngReader = vtk.vtkPNGReader()
+#pngReader.SetFileName(os.path.join(texturesdir, "texture1.png"))
+#texture.SetInputConnection(pngReader.GetOutputPort())
+#texture.InterpolateOn()
+#scalarmap.Texture = texture
pvsimple.Render()