]> SALOME platform Git repositories - modules/paravis.git/commitdiff
Salome HOME
Porting to ParaView-4.1.0
authorvtn <vtn@opencascade.com>
Mon, 17 Mar 2014 14:46:56 +0000 (18:46 +0400)
committervtn <vtn@opencascade.com>
Mon, 17 Mar 2014 14:46:56 +0000 (18:46 +0400)
src/PV_SWIG/VTKWrapping/presentations.py
src/PV_SWIG/presentations.py
test/VisuPrs/SWIG_scripts/A8.py
test/VisuPrs/SWIG_scripts/A9.py
test/VisuPrs/SWIG_scripts/C3.py
test/VisuPrs/Util/paravistest.py
test/VisuPrs/bugs/A1.py
test/VisuPrs/bugs/A2.py
test/VisuPrs/bugs/D6.py
test/VisuPrs/dump_study/A7.py

index 5fb0117d791cc7fd13b27865a6886c77f1c700c0..338957a366d4a3939e30f9863b99c696b710fa2f 100644 (file)
@@ -32,12 +32,15 @@ import warnings
 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
 
 
@@ -195,7 +198,7 @@ def process_prs_for_test(prs, view, picture_name, show_bar=True):
         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):
@@ -206,7 +209,7 @@ def reset_view(view=None):
 
     """
     if not view:
-        view = pv.GetRenderView()
+        view = pvs.GetRenderView()
 
     # Camera preferences
     view.CameraFocalPoint = [0.0, 0.0, 0.0]
@@ -221,13 +224,13 @@ def reset_view(view=None):
     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:
@@ -235,7 +238,7 @@ def hide_all(view, to_remove=False):
             rep.Visibility = 0
         if to_remove:
             view.Representations.remove(rep)
-    pv.Render(view=view)
+    pvs.Render(view=view)
 
 
 def display_only(prs, view=None):
@@ -243,7 +246,7 @@ 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):
@@ -672,7 +675,7 @@ def get_calc_magnitude(proxy, array_entity, array_name):
     # 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"
@@ -705,7 +708,7 @@ def get_add_component_calc(proxy, array_entity, array_name):
 
     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"
@@ -724,7 +727,7 @@ def select_all_cells(proxy):
     Used in creation of mesh/submesh presentation.
 
     """
-    extractCT = pv.ExtractCellType()
+    extractCT = pvs.ExtractCellType()
     extractCT.AllGeoTypes = extractCT.GetProperty("GeoTypesInfo")[::2]
 
 
@@ -809,7 +812,7 @@ def add_scalar_bar(field_name, nb_components,
         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
@@ -832,7 +835,7 @@ def add_scalar_bar(field_name, nb_components,
     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
@@ -849,7 +852,7 @@ def get_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
@@ -1013,11 +1016,11 @@ def ScalarMapOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1077,11 +1080,11 @@ def CutPlanesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1095,7 +1098,7 @@ def CutPlanesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1167,11 +1170,11 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1191,7 +1194,7 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
         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
@@ -1217,9 +1220,9 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
             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()
@@ -1231,7 +1234,7 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1289,17 +1292,17 @@ def CutSegmentOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1357,15 +1360,15 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
     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
 
@@ -1377,7 +1380,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
         source = calc
 
     # Glyph
-    glyph = pv.Glyph(source)
+    glyph = pvs.Glyph(source)
     glyph.Vectors = vector_array
     glyph.ScaleMode = 'vector'
     glyph.MaskPoints = 0
@@ -1410,7 +1413,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1476,15 +1479,15 @@ def DeformedShapeOnField(proxy, entity, field_name,
     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
 
@@ -1496,7 +1499,7 @@ def DeformedShapeOnField(proxy, entity, field_name,
         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
@@ -1506,7 +1509,7 @@ def DeformedShapeOnField(proxy, entity, field_name,
         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)
@@ -1584,8 +1587,8 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
     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
@@ -1595,11 +1598,11 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
         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
 
@@ -1611,7 +1614,7 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
         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
@@ -1621,7 +1624,7 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
         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)
@@ -1695,11 +1698,11 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1719,7 +1722,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
                                            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
@@ -1741,7 +1744,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
     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
 
@@ -1751,7 +1754,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
 
     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
 
@@ -1764,7 +1767,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
         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
@@ -1780,7 +1783,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
 
     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,
@@ -1790,7 +1793,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
         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)
@@ -1852,15 +1855,15 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
     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
 
@@ -1873,7 +1876,7 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
         source = calc
 
     # Contour filter settings
-    contour = pv.Contour(source)
+    contour = pvs.Contour(source)
     contour.ComputeScalars = 1
     contour.ContourBy = contour_by
 
@@ -1890,7 +1893,7 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1971,7 +1974,7 @@ def GaussPointsOnField(proxy, entity, field_name,
     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
@@ -1981,12 +1984,12 @@ def GaussPointsOnField(proxy, entity, field_name,
 
     # 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
 
@@ -2003,7 +2006,7 @@ def GaussPointsOnField(proxy, entity, field_name,
             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
@@ -2015,7 +2018,7 @@ def GaussPointsOnField(proxy, entity, field_name,
         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)
@@ -2134,15 +2137,15 @@ def GaussPointsOnField1(proxy, entity, field_name,
     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
@@ -2269,15 +2272,15 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -2291,7 +2294,7 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
         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"
@@ -2302,7 +2305,7 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
     # 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)
@@ -2357,7 +2360,7 @@ def MeshOnEntity(proxy, mesh_name, entity):
     prs = None
     if (proxy.GetDataInformation().GetNumberOfPoints() or
         proxy.GetDataInformation().GetNumberOfCells()):
-        prs = pv.GetRepresentation(proxy)
+        prs = pvs.GetRepresentation(proxy)
         prs.ColorArrayName = ''
 
     return prs
@@ -2397,7 +2400,7 @@ def MeshOnGroup(proxy, group_name):
             nb_items = proxy.GetDataInformation().GetNumberOfCells()
 
         if nb_items:
-            prs = pv.GetRepresentation(proxy)
+            prs = pvs.GetRepresentation(proxy)
             prs.ColorArrayName = ''
 
     return prs
@@ -2421,7 +2424,7 @@ def CreatePrsForFile(paravis_instance, file_name, prs_types,
     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:
@@ -2431,7 +2434,7 @@ def CreatePrsForFile(paravis_instance, file_name, prs_types,
         print "FAILED"
     else:
         # Get view
-        view = pv.GetRenderView()
+        view = pvs.GetRenderView()
 
         # Create required presentations for the proxy
         CreatePrsForProxy(proxy, view, prs_types,
@@ -2491,7 +2494,7 @@ def CreatePrsForProxy(proxy, view, prs_types, picture_dir, picture_ext):
     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]))
index 05b78de4aa5e7f4f6b8ef6384a387bb7467a9c0f..5b408786c45a1f79883852f54d47b7b29553616b 100644 (file)
@@ -32,12 +32,15 @@ import warnings
 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
 
 
@@ -195,7 +198,7 @@ def process_prs_for_test(prs, view, picture_name, show_bar=True):
         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):
@@ -206,7 +209,7 @@ def reset_view(view=None):
 
     """
     if not view:
-        view = pv.GetRenderView()
+        view = pvs.GetRenderView()
 
     # Camera preferences
     view.CameraFocalPoint = [0.0, 0.0, 0.0]
@@ -221,13 +224,13 @@ def reset_view(view=None):
     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:
@@ -235,7 +238,7 @@ def hide_all(view, to_remove=False):
             rep.Visibility = 0
         if to_remove:
             view.Representations.remove(rep)
-    pv.Render(view=view)
+    pvs.Render(view=view)
 
 
 def display_only(prs, view=None):
@@ -243,7 +246,7 @@ 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):
@@ -672,7 +675,7 @@ def get_calc_magnitude(proxy, array_entity, array_name):
     # 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"
@@ -705,7 +708,7 @@ def get_add_component_calc(proxy, array_entity, array_name):
 
     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"
@@ -830,7 +833,7 @@ def extract_groups_for_field(proxy, field_name, field_entity, force=False):
 
     # 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
@@ -867,7 +870,7 @@ def add_scalar_bar(field_name, nb_components,
         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
@@ -890,7 +893,7 @@ def add_scalar_bar(field_name, nb_components,
     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
@@ -907,7 +910,7 @@ def get_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
@@ -1071,15 +1074,15 @@ def ScalarMapOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1139,11 +1142,11 @@ def CutPlanesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1157,7 +1160,7 @@ def CutPlanesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1229,11 +1232,11 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1253,7 +1256,7 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
         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
@@ -1279,9 +1282,9 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
             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()
@@ -1293,7 +1296,7 @@ def CutLinesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1351,17 +1354,17 @@ def CutSegmentOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1419,8 +1422,8 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1428,7 +1431,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
 
     # 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
 
@@ -1440,7 +1443,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
         source = calc
 
     # Glyph
-    glyph = pv.Glyph(source)
+    glyph = pvs.Glyph(source)
     glyph.Vectors = vector_array
     glyph.ScaleMode = 'vector'
     glyph.MaskPoints = 0
@@ -1473,7 +1476,7 @@ def VectorsOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -1539,18 +1542,18 @@ def DeformedShapeOnField(proxy, entity, field_name,
     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
 
@@ -1562,7 +1565,7 @@ def DeformedShapeOnField(proxy, entity, field_name,
         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
@@ -1572,7 +1575,7 @@ def DeformedShapeOnField(proxy, entity, field_name,
         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)
@@ -1650,8 +1653,8 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
     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
@@ -1664,11 +1667,11 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
     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
 
@@ -1680,7 +1683,7 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
         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
@@ -1690,7 +1693,7 @@ def DeformedShapeAndScalarMapOnField(proxy, entity, field_name,
         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)
@@ -1764,14 +1767,14 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -1791,7 +1794,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
                                            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
@@ -1813,7 +1816,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
     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
 
@@ -1823,7 +1826,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
 
     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
 
@@ -1836,7 +1839,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
         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
@@ -1852,7 +1855,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
 
     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,
@@ -1862,7 +1865,7 @@ def Plot3DOnField(proxy, entity, field_name, timestamp_nb,
         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)
@@ -1924,18 +1927,18 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
     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
 
@@ -1948,7 +1951,7 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
         source = calc
 
     # Contour filter settings
-    contour = pv.Contour(source)
+    contour = pvs.Contour(source)
     contour.ComputeScalars = 1
     contour.ContourBy = contour_by
 
@@ -1965,7 +1968,7 @@ def IsoSurfacesOnField(proxy, entity, field_name, timestamp_nb,
     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)
@@ -2046,7 +2049,7 @@ def GaussPointsOnField(proxy, entity, field_name,
     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
@@ -2057,12 +2060,12 @@ def GaussPointsOnField(proxy, entity, field_name,
 
     # 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
 
@@ -2079,7 +2082,7 @@ def GaussPointsOnField(proxy, entity, field_name,
             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
@@ -2091,7 +2094,7 @@ def GaussPointsOnField(proxy, entity, field_name,
         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)
@@ -2210,15 +2213,15 @@ def GaussPointsOnField1(proxy, entity, field_name,
     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
@@ -2345,18 +2348,18 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
     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
@@ -2370,7 +2373,7 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
         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"
@@ -2381,7 +2384,7 @@ def StreamLinesOnField(proxy, entity, field_name, timestamp_nb,
     # 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)
@@ -2436,7 +2439,7 @@ def MeshOnEntity(proxy, mesh_name, entity):
     prs = None
     if (proxy.GetDataInformation().GetNumberOfPoints() or
         proxy.GetDataInformation().GetNumberOfCells()):
-        prs = pv.GetRepresentation(proxy)
+        prs = pvs.GetRepresentation(proxy)
         prs.ColorArrayName = ''
 
     return prs
@@ -2476,7 +2479,7 @@ def MeshOnGroup(proxy, group_name):
             nb_items = proxy.GetDataInformation().GetNumberOfCells()
 
         if nb_items:
-            prs = pv.GetRepresentation(proxy)
+            prs = pvs.GetRepresentation(proxy)
             prs.ColorArrayName = ''
 
     return prs
@@ -2501,7 +2504,7 @@ def CreatePrsForFile(paravis_instance, file_name, prs_types,
 
     try:
         paravis_instance.ImportFile(file_name)
-        proxy = pv.GetActiveSource()
+        proxy = pvs.GetActiveSource()
         if proxy is None:
             print "FAILED"
         else:
@@ -2511,7 +2514,7 @@ def CreatePrsForFile(paravis_instance, file_name, prs_types,
         print "FAILED"
     else:
         # Get view
-        view = pv.GetRenderView()
+        view = pvs.GetRenderView()
 
         # Create required presentations for the proxy
         CreatePrsForProxy(proxy, view, prs_types,
index bfbd73ebd404ce0baa6bb346c00d71445aaee013..5bce5b2f9d0f9ff58f94fb59b9af779157a4c2fa 100644 (file)
 # 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
 
 
@@ -58,8 +61,8 @@ for i in xrange(1, nb_cols + 1):
 """
 
 # 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()
index 37b57b536127913e4934d20ea9853399dc862270..85cc06efc57f214d4b8a41239a90744358b9fb6d 100644 (file)
@@ -41,24 +41,24 @@ if samples_dir is not None:
     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"
@@ -66,20 +66,20 @@ field_name = "fieldnodedouble"
 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()
@@ -97,22 +97,22 @@ for i in xrange(2, nb_colors):
     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
@@ -129,10 +129,10 @@ cam_pos[0] = cam_pos[0] + 10
 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
@@ -146,7 +146,7 @@ for i in xrange(nb_planes, 1, -1):
     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
@@ -155,26 +155,26 @@ slice_filter.SliceType.Normal = normal
 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)
 
@@ -185,21 +185,21 @@ scalar_range = get_data_range(med_reader, entity, field_name, cut_off=True)
 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,
@@ -208,19 +208,19 @@ 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())
@@ -229,16 +229,16 @@ for curve in curves:
     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]
@@ -247,23 +247,23 @@ cutsegment = CutSegmentOnField(med_reader, entity, field_name, timestamp,
                                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"
@@ -271,10 +271,10 @@ field_name = "vitesse"
 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)
index 6b49e1a718dd403ee5b52e25e4f1281484a47492..41060746c18e67f9be6ff6c3b182a6d07e76c437 100644 (file)
 # 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
 
 
@@ -58,43 +61,43 @@ for i in xrange(1, nb_cols + 1):
 """
 
 # 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)
index eff246a5484b6ec04d452c6348dc00ce10f0de1c..8083283ac7c7e1d48b0d938742e3188ae1d44800 100755 (executable)
@@ -291,7 +291,7 @@ def Import_Med_Field(paravis, file, field_names, check_errors=0, prs=[]):
 
     # 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!!!"  
     
index a245df79249878a945281168b20a55fa15900484..90ff0f7217e709c8e9573b564c2fde1ca75b39b8 100644 (file)
@@ -58,5 +58,5 @@ view.ResetCamera()
 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)
index 5d8cbee332f1382ae6753e5d32282b1bf12eeabd..f4f1a6e429a0feb3afd70297adee19ff758cec30 100644 (file)
@@ -71,5 +71,5 @@ view.CameraParallelScale = 0.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)
index 1bf2eec4e69cbf217030384b393ee19ca2d41f9b..26cd2dec5c4b6ea6f09a32334ca1e7aeaa80c955 100644 (file)
@@ -55,13 +55,13 @@ if cut_segment2 == None:
 #       (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!"
 
index 6eb2f2510f329594fe533ec7a8f4be284f71d03d..d3ba872d077d49c4f48f4aa417223999659574d0 100644 (file)
@@ -59,7 +59,7 @@ calc = get_add_component_calc(source, EntityType.NODE, field_name)
 vector_array = calc.ResultArrayName
 calc.UpdatePipeline()
 source = calc
-stream = pv.StreamTracer(source)
+stream = pvs.StreamTracer(source)
 
 # 3. Apply settings
 RenameSource(settings['name'], stream)