from math import sqrt, sin, cos, radians
from string import upper
-import pvsimple as pv
+# 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 pvsimple as pv
+import pvsimple as pvs
#try:
# # TODO(MZN): to be removed (issue with Point Sprite texture)
# #import paravisSM as sm
#except:
-# import paraview.simple as pv
+# import paraview.simple as pvs
# import paraview.servermanager as sm
os.makedirs(pic_dir)
# Save picture
- pv.WriteImage(file_name, view=view, Magnification=1)
+ pvs.WriteImage(file_name, view=view, Magnification=1)
def reset_view(view=None):
"""
if not view:
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
# Camera preferences
view.CameraFocalPoint = [0.0, 0.0, 0.0]
view.CameraParallelProjection = 1
view.ResetCamera()
- pv.Render(view=view)
+ pvs.Render(view=view)
def hide_all(view, to_remove=False):
"""Hide all representations in the view."""
if not view:
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
rep_list = view.Representations
for rep in rep_list:
rep.Visibility = 0
if to_remove:
view.Representations.remove(rep)
- pv.Render(view=view)
+ pvs.Render(view=view)
def display_only(prs, view=None):
hide_all(view)
if (hasattr(prs, 'Visibility') and prs.Visibility != 1):
prs.Visibility = 1
- pv.Render(view=view)
+ pvs.Render(view=view)
def set_visible_lines(xy_prs, lines):
# Transform vector array to scalar array if possible
nb_components = get_nb_components(proxy, array_entity, array_name)
if (nb_components > 1):
- calculator = pv.Calculator(proxy)
+ calculator = pvs.Calculator(proxy)
attribute_mode = "Point Data"
if array_entity != EntityType.NODE:
attribute_mode = "Cell Data"
nb_components = get_nb_components(proxy, array_entity, array_name)
if nb_components == 2:
- calculator = pv.Calculator(proxy)
+ calculator = pvs.Calculator(proxy)
attribute_mode = "Point Data"
if array_entity != EntityType.NODE:
attribute_mode = "Cell Data"
Used in creation of mesh/submesh presentation.
"""
- extractCT = pv.ExtractCellType()
+ extractCT = pvs.ExtractCellType()
extractCT.AllGeoTypes = extractCT.GetProperty("GeoTypesInfo")[::2]
title = "\n".join([title, vector_mode])
# Create scalar bar
- scalar_bar = pv.CreateScalarBar(Enabled=1)
+ scalar_bar = pvs.CreateScalarBar(Enabled=1)
scalar_bar.Orientation = 'Vertical'
scalar_bar.Title = title
scalar_bar.LookupTable = lookup_table
scalar_bar.LabelShadow = 1
# Add the scalar bar to the view
- pv.GetRenderView().Representations.append(scalar_bar)
+ pvs.GetRenderView().Representations.append(scalar_bar)
# Reassign the current bar
_current_bar = scalar_bar
def get_lookup_table(field_name, nb_components, vector_mode='Magnitude'):
"""Get lookup table for the given field."""
- lookup_table = pv.GetLookupTableForArray(field_name, nb_components)
+ lookup_table = pvs.GetLookupTableForArray(field_name, nb_components)
if vector_mode == 'Magnitude':
lookup_table.VectorMode = vector_mode
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Get Scalar Map representation object
- scalarmap = pv.GetRepresentation(proxy)
+ scalarmap = pvs.GetRepresentation(proxy)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create slice filter
- slice_filter = pv.Slice(proxy)
+ slice_filter = pvs.Slice(proxy)
slice_filter.SliceType = "Plane"
# Set cut planes normal
slice_filter.SliceOffsetValues = positions
# Get Cut Planes representation object
- cut_planes = pv.GetRepresentation(slice_filter)
+ cut_planes = pvs.GetRepresentation(slice_filter)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create base plane
- base_plane = pv.Slice(proxy)
+ base_plane = pvs.Slice(proxy)
base_plane.SliceType = "Plane"
# Set base plane normal
base_plane = proxy
# Create cutting planes
- cut_planes = pv.Slice(base_plane)
+ cut_planes = pvs.Slice(base_plane)
cut_planes.SliceType = "Plane"
# Set cutting planes normal and get positions
point2 = [bounds[1], bounds[3], bounds[5]]
# Create plot over line filter
- pol = pv.PlotOverLine(cut_planes,
+ pol = pvs.PlotOverLine(cut_planes,
Source="High Resolution Line Source")
- pv.RenameSource('Y' + str(index), pol)
+ pvs.RenameSource('Y' + str(index), pol)
pol.Source.Point1 = point1
pol.Source.Point2 = point2
pol.UpdatePipeline()
cut_planes.UpdatePipeline()
# Get Cut Lines representation object
- cut_lines = pv.GetRepresentation(cut_planes)
+ cut_lines = pvs.GetRepresentation(cut_planes)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create plot over line filter
- pol = pv.PlotOverLine(proxy, Source="High Resolution Line Source")
+ pol = pvs.PlotOverLine(proxy, Source="High Resolution Line Source")
pol.Source.Point1 = point1
pol.Source.Point2 = point2
pol.UpdatePipeline()
# Get Cut Segment representation object
- cut_segment = pv.GetRepresentation(pol)
+ cut_segment = pvs.GetRepresentation(pol)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
source = proxy
# Cell centers
if is_data_on_cells(proxy, field_name):
- cell_centers = pv.CellCenters(source)
+ cell_centers = pvs.CellCenters(source)
cell_centers.VertexCells = 1
source = cell_centers
source = calc
# Glyph
- glyph = pv.Glyph(source)
+ glyph = pvs.Glyph(source)
glyph.Vectors = vector_array
glyph.ScaleMode = 'vector'
glyph.MaskPoints = 0
glyph.UpdatePipeline()
# Get Vectors representation object
- vectors = pv.GetRepresentation(glyph)
+ vectors = pvs.GetRepresentation(glyph)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Do merge
- source = pv.MergeBlocks(proxy)
+ source = pvs.MergeBlocks(proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData()
+ cell_to_point = pvs.CellDatatoPointData()
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
warp_vector.ScaleFactor = def_scale
# Get Deformed Shape representation object
- defshape = pv.GetRepresentation(warp_vector)
+ defshape = pvs.GetRepresentation(warp_vector)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Set scalar field by default
scalar_field_entity = scalar_entity
scalar_field = field_name
# Do merge
- source = pv.MergeBlocks(proxy)
+ source = pvs.MergeBlocks(proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
warp_vector.ScaleFactor = def_scale
# Get Defromed Shape And Scalar Map representation object
- defshapemap = pv.GetRepresentation(warp_vector)
+ defshapemap = pvs.GetRepresentation(warp_vector)
# Get lookup table
lookup_table = get_lookup_table(scalar_field, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Do merge
- merge_blocks = pv.MergeBlocks(proxy)
+ merge_blocks = pvs.MergeBlocks(proxy)
merge_blocks.UpdatePipeline()
poly_data = None
radians(angle1), radians(angle2))
# Create slice filter
- slice_filter = pv.Slice(merge_blocks)
+ slice_filter = pvs.Slice(merge_blocks)
slice_filter.SliceType = "Plane"
# Set cutting plane normal
use_normal = 0
# Geometry filter
if not poly_data or poly_data.GetDataInformation().GetNumberOfCells() == 0:
- geometry_filter = pv.GeometryFilter(merge_blocks)
+ geometry_filter = pvs.GeometryFilter(merge_blocks)
poly_data = geometry_filter
use_normal = 1 # TODO(MZN): workaround
if is_data_on_cells(poly_data, field_name):
# Cell data to point data
- cell_to_point = pv.CellDatatoPointData(poly_data)
+ cell_to_point = pvs.CellDatatoPointData(poly_data)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by scalar
- warp_scalar = pv.WarpByScalar(source)
+ warp_scalar = pvs.WarpByScalar(source)
warp_scalar.Scalars = scalars
warp_scalar.Normal = normal
warp_scalar.UseNormal = use_normal
if (is_contour):
# Contours
- contour = pv.Contour(warp_scalar)
+ contour = pvs.Contour(warp_scalar)
contour.PointMergeMethod = "Uniform Binning"
contour.ContourBy = ['POINTS', field_name]
scalar_range = get_data_range(proxy, entity,
source = contour
# Get Plot 3D representation object
- plot3d = pv.GetRepresentation(source)
+ plot3d = pvs.GetRepresentation(source)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Do merge
- source = pv.MergeBlocks(proxy)
+ source = pvs.MergeBlocks(proxy)
# Transform cell data into point data if necessary
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Contour filter settings
- contour = pv.Contour(source)
+ contour = pvs.Contour(source)
contour.ComputeScalars = 1
contour.ContourBy = contour_by
contour.Isosurfaces = surfaces
# Get Iso Surfaces representation object
- isosurfaces = pv.GetRepresentation(contour)
+ isosurfaces = pvs.GetRepresentation(contour)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
+ pvs.GetRenderView().ViewTime = time_value
proxy.UpdatePipeline(time=time_value)
source = proxy
# If no quadrature point array is passed, use cell centers
if field_name in qp_arrays:
- generate_qp = pv.GenerateQuadraturePoints(source)
+ generate_qp = pvs.GenerateQuadraturePoints(source)
generate_qp.SelectSourceArray = ['CELLS', 'ELGA_Offset']
source = generate_qp
else:
# Cell centers
- cell_centers = pv.CellCenters(source)
+ cell_centers = pvs.CellCenters(source)
cell_centers.VertexCells = 1
source = cell_centers
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
source = warp_vector
# Get Gauss Points representation object
- gausspnt = pv.GetRepresentation(source)
+ gausspnt = pvs.GetRepresentation(source)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
+ pvs.GetRenderView().ViewTime = time_value
proxy.UpdatePipeline(time=time_value)
# Create Gauss Points object
- source = pv.GaussPoints(proxy)
+ source = pvs.GaussPoints(proxy)
source.UpdatePipeline()
# Get Gauss Points representation object
- gausspnt = pv.GetRepresentation(source)
+ gausspnt = pvs.GetRepresentation(source)
# Get lookup table
entity_data_info = None
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Do merge
- source = pv.MergeBlocks(proxy)
+ source = pvs.MergeBlocks(proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
cell_to_point.UpdatePipeline()
source = cell_to_point
source = calc
# Stream Tracer
- stream = pv.StreamTracer(source)
+ stream = pvs.StreamTracer(source)
stream.SeedType = "Point Source"
stream.Vectors = ['POINTS', vector_array]
stream.SeedType = "Point Source"
# Get Stream Lines representation object
if is_empty(stream):
return None
- streamlines = pv.GetRepresentation(stream)
+ streamlines = pvs.GetRepresentation(stream)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
prs = None
if (proxy.GetDataInformation().GetNumberOfPoints() or
proxy.GetDataInformation().GetNumberOfCells()):
- prs = pv.GetRepresentation(proxy)
+ prs = pvs.GetRepresentation(proxy)
prs.ColorArrayName = ''
return prs
nb_items = proxy.GetDataInformation().GetNumberOfCells()
if nb_items:
- prs = pv.GetRepresentation(proxy)
+ prs = pvs.GetRepresentation(proxy)
prs.ColorArrayName = ''
return prs
print "Import " + file_name.split(os.sep)[-1] + "..."
try:
- proxy = pv.MEDReader(FileName=file_name)
+ proxy = pvs.MEDReader(FileName=file_name)
if proxy is None:
print "FAILED"
else:
print "FAILED"
else:
# Get view
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
# Create required presentations for the proxy
CreatePrsForProxy(proxy, view, prs_types,
if PrsTypeEnum.MESH in prs_types:
# Create Mesh presentation. Build all possible submeshes.
- extGrp=pv.ExtractGroup()
+ extGrp=pvs.ExtractGroup()
# Remember the current state
groups = filter(lambda x:x[:4]=="GRP_",list(extGrp.GetProperty("GroupsFlagsInfo")[::2]))
from math import sqrt, sin, cos, radians
from string import upper
-import pvsimple as pv
+# 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 pvsimple as pv
+import pvsimple as pvs
#try:
# # TODO(MZN): to be removed (issue with Point Sprite texture)
# #import paravisSM as sm
#except:
-# import paraview.simple as pv
+# import paraview.simple as pvs
# import paraview.servermanager as sm
os.makedirs(pic_dir)
# Save picture
- pv.WriteImage(file_name, view=view, Magnification=1)
+ pvs.WriteImage(file_name, view=view, Magnification=1)
def reset_view(view=None):
"""
if not view:
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
# Camera preferences
view.CameraFocalPoint = [0.0, 0.0, 0.0]
view.CameraParallelProjection = 1
view.ResetCamera()
- pv.Render(view=view)
+ pvs.Render(view=view)
def hide_all(view, to_remove=False):
"""Hide all representations in the view."""
if not view:
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
rep_list = view.Representations
for rep in rep_list:
rep.Visibility = 0
if to_remove:
view.Representations.remove(rep)
- pv.Render(view=view)
+ pvs.Render(view=view)
def display_only(prs, view=None):
hide_all(view)
if (hasattr(prs, 'Visibility') and prs.Visibility != 1):
prs.Visibility = 1
- pv.Render(view=view)
+ pvs.Render(view=view)
def set_visible_lines(xy_prs, lines):
# Transform vector array to scalar array if possible
nb_components = get_nb_components(proxy, array_entity, array_name)
if (nb_components > 1):
- calculator = pv.Calculator(proxy)
+ calculator = pvs.Calculator(proxy)
attribute_mode = "Point Data"
if array_entity != EntityType.NODE:
attribute_mode = "Cell Data"
nb_components = get_nb_components(proxy, array_entity, array_name)
if nb_components == 2:
- calculator = pv.Calculator(proxy)
+ calculator = pvs.Calculator(proxy)
attribute_mode = "Point Data"
if array_entity != EntityType.NODE:
attribute_mode = "Cell Data"
# Extract groups if necessary
if force or (len(groups_to_extract) < len(initial_groups)):
- extract_group = pv.ExtractGroup(proxy)
+ extract_group = pvs.ExtractGroup(proxy)
extract_group.Groups = groups_to_extract
extract_group.UpdatePipeline()
source = extract_group
title = "\n".join([title, vector_mode])
# Create scalar bar
- scalar_bar = pv.CreateScalarBar(Enabled=1)
+ scalar_bar = pvs.CreateScalarBar(Enabled=1)
scalar_bar.Orientation = 'Vertical'
scalar_bar.Title = title
scalar_bar.LookupTable = lookup_table
scalar_bar.LabelShadow = 1
# Add the scalar bar to the view
- pv.GetRenderView().Representations.append(scalar_bar)
+ pvs.GetRenderView().Representations.append(scalar_bar)
# Reassign the current bar
_current_bar = scalar_bar
def get_lookup_table(field_name, nb_components, vector_mode='Magnitude'):
"""Get lookup table for the given field."""
- lookup_table = pv.GetLookupTableForArray(field_name, nb_components)
+ lookup_table = pvs.GetLookupTableForArray(field_name, nb_components)
if vector_mode == 'Magnitude':
lookup_table.VectorMode = vector_mode
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity,
force=True)
# Get Scalar Map representation object
- scalarmap = pv.GetRepresentation(new_proxy)
+ scalarmap = pvs.GetRepresentation(new_proxy)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create slice filter
- slice_filter = pv.Slice(proxy)
+ slice_filter = pvs.Slice(proxy)
slice_filter.SliceType = "Plane"
# Set cut planes normal
slice_filter.SliceOffsetValues = positions
# Get Cut Planes representation object
- cut_planes = pv.GetRepresentation(slice_filter)
+ cut_planes = pvs.GetRepresentation(slice_filter)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create base plane
- base_plane = pv.Slice(proxy)
+ base_plane = pvs.Slice(proxy)
base_plane.SliceType = "Plane"
# Set base plane normal
base_plane = proxy
# Create cutting planes
- cut_planes = pv.Slice(base_plane)
+ cut_planes = pvs.Slice(base_plane)
cut_planes.SliceType = "Plane"
# Set cutting planes normal and get positions
point2 = [bounds[1], bounds[3], bounds[5]]
# Create plot over line filter
- pol = pv.PlotOverLine(cut_planes,
+ pol = pvs.PlotOverLine(cut_planes,
Source="High Resolution Line Source")
- pv.RenameSource('Y' + str(index), pol)
+ pvs.RenameSource('Y' + str(index), pol)
pol.Source.Point1 = point1
pol.Source.Point2 = point2
pol.UpdatePipeline()
cut_planes.UpdatePipeline()
# Get Cut Lines representation object
- cut_lines = pv.GetRepresentation(cut_planes)
+ cut_lines = pvs.GetRepresentation(cut_planes)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Create plot over line filter
- pol = pv.PlotOverLine(proxy, Source="High Resolution Line Source")
+ pol = pvs.PlotOverLine(proxy, Source="High Resolution Line Source")
pol.Source.Point1 = point1
pol.Source.Point2 = point2
pol.UpdatePipeline()
# Get Cut Segment representation object
- cut_segment = pv.GetRepresentation(pol)
+ cut_segment = pvs.GetRepresentation(pol)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Cell centers
if is_data_on_cells(proxy, field_name):
- cell_centers = pv.CellCenters(source)
+ cell_centers = pvs.CellCenters(source)
cell_centers.VertexCells = 1
source = cell_centers
source = calc
# Glyph
- glyph = pv.Glyph(source)
+ glyph = pvs.Glyph(source)
glyph.Vectors = vector_array
glyph.ScaleMode = 'vector'
glyph.MaskPoints = 0
glyph.UpdatePipeline()
# Get Vectors representation object
- vectors = pv.GetRepresentation(glyph)
+ vectors = pvs.GetRepresentation(glyph)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Do merge
- source = pv.MergeBlocks(new_proxy)
+ source = pvs.MergeBlocks(new_proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData()
+ cell_to_point = pvs.CellDatatoPointData()
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
warp_vector.ScaleFactor = def_scale
# Get Deformed Shape representation object
- defshape = pv.GetRepresentation(warp_vector)
+ defshape = pvs.GetRepresentation(warp_vector)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Set scalar field by default
scalar_field_entity = scalar_entity
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Do merge
- source = pv.MergeBlocks(new_proxy)
+ source = pvs.MergeBlocks(new_proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
warp_vector.ScaleFactor = def_scale
# Get Defromed Shape And Scalar Map representation object
- defshapemap = pv.GetRepresentation(warp_vector)
+ defshapemap = pvs.GetRepresentation(warp_vector)
# Get lookup table
lookup_table = get_lookup_table(scalar_field, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Do merge
- merge_blocks = pv.MergeBlocks(new_proxy)
+ merge_blocks = pvs.MergeBlocks(new_proxy)
merge_blocks.UpdatePipeline()
poly_data = None
radians(angle1), radians(angle2))
# Create slice filter
- slice_filter = pv.Slice(merge_blocks)
+ slice_filter = pvs.Slice(merge_blocks)
slice_filter.SliceType = "Plane"
# Set cutting plane normal
use_normal = 0
# Geometry filter
if not poly_data or poly_data.GetDataInformation().GetNumberOfCells() == 0:
- geometry_filter = pv.GeometryFilter(merge_blocks)
+ geometry_filter = pvs.GeometryFilter(merge_blocks)
poly_data = geometry_filter
use_normal = 1 # TODO(MZN): workaround
if is_data_on_cells(poly_data, field_name):
# Cell data to point data
- cell_to_point = pv.CellDatatoPointData(poly_data)
+ cell_to_point = pvs.CellDatatoPointData(poly_data)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Warp by scalar
- warp_scalar = pv.WarpByScalar(source)
+ warp_scalar = pvs.WarpByScalar(source)
warp_scalar.Scalars = scalars
warp_scalar.Normal = normal
warp_scalar.UseNormal = use_normal
if (is_contour):
# Contours
- contour = pv.Contour(warp_scalar)
+ contour = pvs.Contour(warp_scalar)
contour.PointMergeMethod = "Uniform Binning"
contour.ContourBy = ['POINTS', field_name]
scalar_range = get_data_range(proxy, entity,
source = contour
# Get Plot 3D representation object
- plot3d = pv.GetRepresentation(source)
+ plot3d = pvs.GetRepresentation(source)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Do merge
- source = pv.MergeBlocks(new_proxy)
+ source = pvs.MergeBlocks(new_proxy)
# Transform cell data into point data if necessary
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
source = cell_to_point
source = calc
# Contour filter settings
- contour = pv.Contour(source)
+ contour = pvs.Contour(source)
contour.ComputeScalars = 1
contour.ContourBy = contour_by
contour.Isosurfaces = surfaces
# Get Iso Surfaces representation object
- isosurfaces = pv.GetRepresentation(contour)
+ isosurfaces = pvs.GetRepresentation(contour)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
+ pvs.GetRenderView().ViewTime = time_value
proxy.UpdatePipeline(time=time_value)
# Extract only groups with data for the field
# If no quadrature point array is passed, use cell centers
if field_name in qp_arrays:
- generate_qp = pv.GenerateQuadraturePoints(source)
+ generate_qp = pvs.GenerateQuadraturePoints(source)
generate_qp.SelectSourceArray = ['CELLS', 'ELGA_Offset']
source = generate_qp
else:
# Cell centers
- cell_centers = pv.CellCenters(source)
+ cell_centers = pvs.CellCenters(source)
cell_centers.VertexCells = 1
source = cell_centers
source = calc
# Warp by vector
- warp_vector = pv.WarpByVector(source)
+ warp_vector = pvs.WarpByVector(source)
warp_vector.Vectors = [vector_array]
if scale_factor is not None:
warp_vector.ScaleFactor = scale_factor
source = warp_vector
# Get Gauss Points representation object
- gausspnt = pv.GetRepresentation(source)
+ gausspnt = pvs.GetRepresentation(source)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
+ pvs.GetRenderView().ViewTime = time_value
proxy.UpdatePipeline(time=time_value)
# Create Gauss Points object
- source = pv.GaussPoints(proxy)
+ source = pvs.GaussPoints(proxy)
source.UpdatePipeline()
# Get Gauss Points representation object
- gausspnt = pv.GetRepresentation(source)
+ gausspnt = pvs.GetRepresentation(source)
# Get lookup table
entity_data_info = None
time_value = get_time(proxy, timestamp_nb)
# Set timestamp
- pv.GetRenderView().ViewTime = time_value
- pv.UpdatePipeline(time_value, proxy)
+ pvs.GetRenderView().ViewTime = time_value
+ pvs.UpdatePipeline(time_value, proxy)
# Extract only groups with data for the field
new_proxy = extract_groups_for_field(proxy, field_name, entity)
# Do merge
- source = pv.MergeBlocks(new_proxy)
+ source = pvs.MergeBlocks(new_proxy)
# Cell data to point data
if is_data_on_cells(proxy, field_name):
- cell_to_point = pv.CellDatatoPointData(source)
+ cell_to_point = pvs.CellDatatoPointData(source)
cell_to_point.PassCellData = 1
cell_to_point.UpdatePipeline()
source = cell_to_point
source = calc
# Stream Tracer
- stream = pv.StreamTracer(source)
+ stream = pvs.StreamTracer(source)
stream.SeedType = "Point Source"
stream.Vectors = ['POINTS', vector_array]
stream.SeedType = "Point Source"
# Get Stream Lines representation object
if is_empty(stream):
return None
- streamlines = pv.GetRepresentation(stream)
+ streamlines = pvs.GetRepresentation(stream)
# Get lookup table
lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
prs = None
if (proxy.GetDataInformation().GetNumberOfPoints() or
proxy.GetDataInformation().GetNumberOfCells()):
- prs = pv.GetRepresentation(proxy)
+ prs = pvs.GetRepresentation(proxy)
prs.ColorArrayName = ''
return prs
nb_items = proxy.GetDataInformation().GetNumberOfCells()
if nb_items:
- prs = pv.GetRepresentation(proxy)
+ prs = pvs.GetRepresentation(proxy)
prs.ColorArrayName = ''
return prs
try:
paravis_instance.ImportFile(file_name)
- proxy = pv.GetActiveSource()
+ proxy = pvs.GetActiveSource()
if proxy is None:
print "FAILED"
else:
print "FAILED"
else:
# Get view
- view = pv.GetRenderView()
+ view = pvs.GetRenderView()
# Create required presentations for the proxy
CreatePrsForProxy(proxy, view, prs_types,
# This case corresponds to: /visu/SWIG_scripts/A8 case
# Create table
-import paraview.simple as pv
+# 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
"""
# Creating programmable source (table)
-ps = pv.ProgrammableSource()
+ps = pvs.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pv.RenameSource("Very useful data", ps)
+pvs.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
tablesdir = samples_dir + "/Tables/"
# Get view
-view = pv.GetRenderView()
+view = pvs.GetRenderView()
sleep(DELAY)
# Destroy the view
-pv.Delete(view)
+pvs.Delete(view)
# Create view and set background
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
color = [0, 0.3, 1]
view.Background = color
-pv.Render()
+pvs.Render()
# Load MED reader plugin
pv_root_dir = os.getenv("PARAVIS_ROOT_DIR")
-pv.LoadPlugin(pv_root_dir + "/lib/paraview/libMedReaderPlugin.so")
+pvs.LoadPlugin(pv_root_dir + "/lib/paraview/libMedReaderPlugin.so")
# Import MED file
med_file = datadir + "pointe.med"
entity = EntityType.NODE
timestamp = 1
-med_reader = pv.MEDReader(FileName=med_file)
+med_reader = pvs.MEDReader(FileName=med_file)
med_reader.UpdatePipeline()
# Create scalar map
scalarmap = ScalarMapOnField(med_reader, entity, field_name, timestamp)
-pv.Show(scalarmap.Input)
+pvs.Show(scalarmap.Input)
# Set view properties
print "view.CameraFocalPoint = [0, 0, 0]"
view.CameraFocalPoint = [0, 0, 0]
print "view.CameraParallelScale = 2"
view.CameraParallelScale = 2
-print "pv.ResetCamera(view)"
-pv.ResetCamera(view)
+print "pvs.ResetCamera(view)"
+pvs.ResetCamera(view)
# Play with scalar bar
bar = get_bar()
y = range_max - delta * i / nb_colors
lt.RGBPoints[0] = x
lt.RGBPoints[4] = y
- pv.Render(view)
+ pvs.Render(view)
sleep(DELAY / 4.0)
lt.RGBPoints[0] = range_min
lt.RGBPoints[4] = range_max
-print "pv.ResetCamera(view)"
-pv.ResetCamera(view)
+print "pvs.ResetCamera(view)"
+pvs.ResetCamera(view)
# Create another view for cut planes
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
color = [0, 0.7, 0]
view.Background = color
-pv.Render(view)
+pvs.Render(view)
displacement = 0.5
orient = Orientation.YZ
print "Set view.CameraPosition"
cutplanes.Scale[0] = 3
cutplanes.Scale[1] = 10
-pv.Render(view)
+pvs.Render(view)
sleep(DELAY)
-pv.ResetCamera(view)
+pvs.ResetCamera(view)
slice_filter = cutplanes.Input
offset_vals = slice_filter.SliceOffsetValues
slice_filter.SliceType.Normal = normal
pos = get_positions(i, normal, bounds, displacement)
slice_filter.SliceOffsetValues = pos
- pv.Render(view)
+ pvs.Render(view)
sleep(DELAY)
nb_planes = 10
for i in xrange(1, nb_planes):
pos = get_positions(i, normal, bounds, displacement)
slice_filter.SliceOffsetValues = pos
- pv.Render(view)
+ pvs.Render(view)
sleep(DELAY)
slice_filter.SliceType.Normal = [0, 0, 1]
slice_filter.UpdatePipeline()
-print "pv.ResetCamera(view)"
-pv.ResetCamera(view)
+print "pvs.ResetCamera(view)"
+pvs.ResetCamera(view)
# Create one more view for iso surfaces
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
color = [1, 0.7, 0]
view.Background = color
-pv.Render(view)
+pvs.Render(view)
sleep(DELAY)
isosurf = IsoSurfacesOnField(med_reader, entity, field_name, timestamp)
display_only(isosurf, view)
-pv.ResetCamera(view)
+pvs.ResetCamera(view)
print "display_only(isosurf, view)"
sleep(DELAY)
for i in xrange(2, nb_surfaces):
contours = get_contours(scalar_range, i)
contour.Isosurfaces = contours
- pv.Render(view)
+ pvs.Render(view)
sleep(DELAY)
contour.Isosurfaces = get_contours(scalar_range, 10)
contour.UpdatePipeline()
-print "pv.ResetCamera(view)"
-pv.ResetCamera(view)
+print "pvs.ResetCamera(view)"
+pvs.ResetCamera(view)
# Create one more view for cut lines
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
color = [0.7, 0.7, 0.7]
view.Background = color
-pv.Render(view)
+pvs.Render(view)
sleep(DELAY)
cutlines, curves = CutLinesOnField(med_reader, entity, field_name, timestamp,
generate_curves=True)
print "CutLinesOnField(...)"
display_only(cutlines, view)
-pv.ResetCamera(view)
+pvs.ResetCamera(view)
print "display_only(cutlines, view)"
sleep(DELAY)
-xy_view = pv.CreateXYPlotView()
-print "pv.CreateXYPlotView()"
+xy_view = pvs.CreateXYPlotView()
+print "pvs.CreateXYPlotView()"
index = 0
for curve in curves:
- xyrep = pv.Show(curve, xy_view)
+ xyrep = pvs.Show(curve, xy_view)
xyrep.AttributeType = 'Point Data'
xyrep.UseIndexForXAxis = 0
xyrep.XArrayName = 'arc_length'
- pv.Render(xy_view)
+ pvs.Render(xy_view)
set_visible_lines(xyrep, [field_name])
xyrep.SeriesLabel = [field_name, 'Y' + str(index)]
r = str(random.random())
xyrep.SeriesColor = [field_name, r, g, b]
index += 1
-pv.Render(xy_view)
+pvs.Render(xy_view)
sleep(DELAY)
# Create one more view for cut segment
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
color = [0.0, 0.7, 0.3]
view.Background = color
-pv.Render(view)
+pvs.Render(view)
sleep(DELAY)
point1 = [0.0, -1.0, 2.5]
point1, point2)
print "CutSegmentOnField(...)"
display_only(cutsegment, view)
-pv.ResetCamera(view)
+pvs.ResetCamera(view)
print "display_only(cutsegment, view)"
sleep(DELAY)
-xy_view = pv.CreateXYPlotView()
-curve = pv.Show(cutsegment.Input, xy_view)
+xy_view = pvs.CreateXYPlotView()
+curve = pvs.Show(cutsegment.Input, xy_view)
curve.AttributeType = 'Point Data'
curve.UseIndexForXAxis = 0
curve.XArrayName = 'arc_length'
set_visible_lines(xyrep, [field_name])
-pv.Render(xy_view)
+pvs.Render(xy_view)
sleep(DELAY)
# Create one more view for animation
-view = pv.CreateRenderView()
+view = pvs.CreateRenderView()
reset_view(view)
med_file = datadir + "TimeStamps.med"
entity = EntityType.NODE
timestamp = 2
-med_reader = pv.MEDReader(FileName=med_file)
+med_reader = pvs.MEDReader(FileName=med_file)
isosurf = IsoSurfacesOnField(med_reader, entity, field_name, timestamp)
-pv.ResetCamera(view)
+pvs.ResetCamera(view)
print "Start Animation"
-pv.AnimateReader(med_reader, view)
+pvs.AnimateReader(med_reader, view)
# This case corresponds to: /visu/SWIG_scripts/C3 case
# Create table and display curves
-import paraview.simple as pv
+# 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
"""
# Creating programmable source (table)
-ps = pv.ProgrammableSource()
+ps = pvs.ProgrammableSource()
ps.OutputDataSetType = 'vtkTable'
ps.Script = script
-pv.RenameSource("Very useful data", ps)
+pvs.RenameSource("Very useful data", ps)
ps.UpdatePipeline()
# Display table
# TODO: no possibility to create spreadsheet view
# Display curves
-xy_view = pv.CreateXYPlotView()
+xy_view = pvs.CreateXYPlotView()
xy_view.ChartTitle = 'Very useful data'
xy_view.AxisTitle = ['[ Wt ]', 'Frequency [ Hz ]']
-xy_rep = pv.Show(ps)
+xy_rep = pvs.Show(ps)
xy_rep.AttributeType = 'Row Data'
xy_rep.UseIndexForXAxis = 0
xy_rep.XArrayName = 'Frequency'
xy_rep.SeriesVisibility = ['Frequency', '0']
-pv.Render(xy_view)
+pvs.Render(xy_view)
# Hide legend
xy_view.ShowLegend = 0
-pv.Render(xy_view)
+pvs.Render(xy_view)
# Set logarithmic scaling for X axis
xy_view.AxisLogScale[1] = 1
-pv.Render(xy_view)
+pvs.Render(xy_view)
# Set linear scaling for X axis
xy_view.AxisLogScale[1] = 0
-pv.Render(xy_view)
+pvs.Render(xy_view)
# Set logarithmic scaling for X axis
xy_view.AxisLogScale[0] = 1
-pv.Render(xy_view)
+pvs.Render(xy_view)
# Show legend
xy_view.ShowLegend = 1
-pv.Render(xy_view)
+pvs.Render(xy_view)
# import MED file
paravis.ImportFile(file)
- proxy = presentations.pv.GetActiveSource()
+ proxy = presentations.pvs.GetActiveSource()
if proxy is None:
raise RuntimeError, "ERROR!!! Can't import file!!!"
pvsimple.Render(view)
print "Picure file name is " + pic_path
-pv.WriteImage(pic_path, view=view, Magnification=1)
+pvs.WriteImage(pic_path, view=view, Magnification=1)
time.sleep(1)
pvsimple.Render(view)
print "Picure file name is " + pic_path
-pv.WriteImage(pic_path, view=view, Magnification=1)
+pvs.WriteImage(pic_path, view=view, Magnification=1)
time.sleep(1)
# (spreadsheet view in terms of ParaViS) from in Python script
# 5. Creation of curve based on Table
-xy_view = pv.CreateXYPlotView()
+xy_view = pvs.CreateXYPlotView()
-curve1 = pv.Show(cut_segment1.Input, xy_view)
+curve1 = pvs.Show(cut_segment1.Input, xy_view)
if curve1 == None:
raise RuntimeError, " ERROR!!! Curve based on the first CutSegment is not built!"
-curve2 = pv.Show(cut_segment2.Input, xy_view)
+curve2 = pvs.Show(cut_segment2.Input, xy_view)
if curve2 == None:
raise RuntimeError, " ERROR!!! Curve based on the second CutSegment is not built!"
vector_array = calc.ResultArrayName
calc.UpdatePipeline()
source = calc
-stream = pv.StreamTracer(source)
+stream = pvs.StreamTracer(source)
# 3. Apply settings
RenameSource(settings['name'], stream)