Back to index

salome-paravis  6.5.0
Classes | Functions | Variables
presentations Namespace Reference

Classes

class  PrsTypeEnum
class  EntityType
class  Orientation
class  GlyphPos
class  GaussType

Functions

def process_prs_for_test
def reset_view
def hide_all
def display_only
def set_visible_lines
def check_vector_mode
def get_vector_component
def get_data_range
def get_bounds
def get_x_range
def get_y_range
def get_z_range
def is_planar_input
def is_data_on_cells
def is_empty
def get_orientation
def dot_product
def multiply3x3
def get_rx
def get_ry
def get_rz
def get_normal_by_orientation
def get_bound_project
def get_positions
def get_contours
def get_nb_components
def get_scale_factor
def get_default_scale
def get_calc_magnitude
def get_add_component_calc
def select_all_cells
def select_cells_with_data
def extract_groups_for_field
def if_possible
def add_scalar_bar
def get_bar
def get_lookup_table
def get_group_mesh_name
def get_group_entity
def get_group_short_name
def get_mesh_names
def get_group_names
def get_time
def create_prs
def ScalarMapOnField
def CutPlanesOnField
def CutLinesOnField
def CutSegmentOnField
def VectorsOnField
def DeformedShapeOnField
def DeformedShapeAndScalarMapOnField
def Plot3DOnField
def IsoSurfacesOnField
def GaussPointsOnField
def StreamLinesOnField
def MeshOnEntity
def MeshOnGroup
def CreatePrsForFile
def CreatePrsForProxy

Variables

int EPS = 1
int FLT_MIN = 1
int VTK_LARGE_FLOAT = 1
float GAP_COEFFICIENT = 0.0001
 _current_bar = None

Function Documentation

def presentations.add_scalar_bar (   field_name,
  nb_components,
  vector_mode,
  lookup_table,
  time_value 
)
Add scalar bar with predefined properties.

Definition at line 857 of file presentations.py.

00857 
00858                    vector_mode, lookup_table, time_value):
00859     """Add scalar bar with predefined properties."""
00860     global _current_bar
00861 
00862     # Construct bar title
00863     title = "\n".join([field_name, str(time_value)])
00864     if nb_components > 1:
00865         title = "\n".join([title, vector_mode])
00866 
00867     # Create scalar bar
00868     scalar_bar = pv.CreateScalarBar(Enabled=1)
00869     scalar_bar.Orientation = 'Vertical'
00870     scalar_bar.Title = title
00871     scalar_bar.LookupTable = lookup_table
00872 
00873     # Set default properties same as in Post-Pro
00874     scalar_bar.NumberOfLabels = 5
00875     scalar_bar.AutomaticLabelFormat = 0
00876     scalar_bar.LabelFormat = '%-#6.6g'
00877     # Title
00878     scalar_bar.TitleFontFamily = 'Arial'
00879     scalar_bar.TitleFontSize = 8
00880     scalar_bar.TitleBold = 1
00881     scalar_bar.TitleItalic = 1
00882     scalar_bar.TitleShadow = 1
00883     # Labels
00884     scalar_bar.LabelFontFamily = 'Arial'
00885     scalar_bar.LabelFontSize = 8
00886     scalar_bar.LabelBold = 1
00887     scalar_bar.LabelItalic = 1
00888     scalar_bar.LabelShadow = 1
00889 
00890     # Add the scalar bar to the view
00891     pv.GetRenderView().Representations.append(scalar_bar)
00892 
00893     # Reassign the current bar
00894     _current_bar = scalar_bar
00895 
00896     return scalar_bar
00897 

Here is the caller graph for this function:

def presentations.check_vector_mode (   vector_mode,
  nb_components 
)
Check vector mode.

Check if vector mode is correct for the data array with the
given number of components.

Arguments:
  vector_mode: 'Magnitude', 'X', 'Y' or 'Z'
  nb_components: number of component in the data array

Raises:
  ValueError: in case of the vector mode is unexistent
  or nonapplicable.

Definition at line 267 of file presentations.py.

00267 
00268 def check_vector_mode(vector_mode, nb_components):
00269     """Check vector mode.
00270 
00271     Check if vector mode is correct for the data array with the
00272     given number of components.
00273 
00274     Arguments:
00275       vector_mode: 'Magnitude', 'X', 'Y' or 'Z'
00276       nb_components: number of component in the data array
00277 
00278     Raises:
00279       ValueError: in case of the vector mode is unexistent
00280       or nonapplicable.
00281 
00282     """
00283     if vector_mode not in ('Magnitude', 'X', 'Y', 'Z'):
00284         raise ValueError("Unexistent vector mode: " + vector_mode)
00285 
00286     if ((nb_components == 1 and (vector_mode == 'Y' or vector_mode == 'Z')) or
00287         (nb_components == 2 and  vector_mode == 'Z')):
00288         raise ValueError("Incorrect vector mode " + vector_mode + " for " +
00289                          nb_components + "-component field")
00290 

Here is the caller graph for this function:

def presentations.create_prs (   prs_type,
  proxy,
  field_entity,
  field_name,
  timestamp_nb 
)
Auxiliary function.

Build presentation of the given type on the given field and
timestamp number.
Set the presentation properties like visu.CreatePrsForResult() do.

Definition at line 992 of file presentations.py.

00992 
00993 def create_prs(prs_type, proxy, field_entity, field_name, timestamp_nb):
00994     """Auxiliary function.
00995 
00996     Build presentation of the given type on the given field and
00997     timestamp number.
00998     Set the presentation properties like visu.CreatePrsForResult() do.
00999 
01000     """
01001     prs = None
01002 
01003     if prs_type == PrsTypeEnum.SCALARMAP:
01004         prs = ScalarMapOnField(proxy, field_entity, field_name, timestamp_nb)
01005     elif prs_type == PrsTypeEnum.CUTPLANES:
01006         prs = CutPlanesOnField(proxy, field_entity, field_name, timestamp_nb,
01007                                orientation=Orientation.ZX)
01008     elif prs_type == PrsTypeEnum.CUTLINES:
01009         prs = CutLinesOnField(proxy, field_entity, field_name, timestamp_nb,
01010                               orientation1=Orientation.XY,
01011                               orientation2=Orientation.ZX)
01012     elif prs_type == PrsTypeEnum.DEFORMEDSHAPE:
01013         prs = DeformedShapeOnField(proxy, field_entity,
01014                                    field_name, timestamp_nb)
01015     elif prs_type == PrsTypeEnum.DEFORMEDSHAPESCALARMAP:
01016         prs = DeformedShapeAndScalarMapOnField(proxy, field_entity,
01017                                                field_name, timestamp_nb)
01018     elif prs_type == PrsTypeEnum.VECTORS:
01019         prs = VectorsOnField(proxy, field_entity, field_name, timestamp_nb)
01020     elif prs_type == PrsTypeEnum.PLOT3D:
01021         prs = Plot3DOnField(proxy, field_entity, field_name, timestamp_nb)
01022     elif prs_type == PrsTypeEnum.ISOSURFACES:
01023         prs = IsoSurfacesOnField(proxy, field_entity, field_name, timestamp_nb)
01024     elif prs_type == PrsTypeEnum.GAUSSPOINTS:
01025         prs = GaussPointsOnField(proxy, field_entity, field_name, timestamp_nb)
01026     elif prs_type == PrsTypeEnum.STREAMLINES:
01027         prs = StreamLinesOnField(proxy, field_entity, field_name, timestamp_nb)
01028     else:
01029         raise ValueError("Unexistent presentation type.")
01030 
01031     return prs
01032 
01033 
# Functions for building Post-Pro presentations

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.CreatePrsForFile (   paravis_instance,
  file_name,
  prs_types,
  picture_dir,
  picture_ext 
)
Build presentations of the given types for the file.

Build presentations for all fields on all timestamps.

Arguments:
  paravis_instance: ParaVis module instance object
  file_name: full path to the MED file
  prs_types: the list of presentation types to build
  picture_dir: the directory path for saving snapshots
  picture_ext: graphics files extension (determines file type)

Definition at line 2343 of file presentations.py.

02343 
02344                      picture_dir, picture_ext):
02345     """Build presentations of the given types for the file.
02346 
02347     Build presentations for all fields on all timestamps.
02348 
02349     Arguments:
02350       paravis_instance: ParaVis module instance object
02351       file_name: full path to the MED file
02352       prs_types: the list of presentation types to build
02353       picture_dir: the directory path for saving snapshots
02354       picture_ext: graphics files extension (determines file type)
02355 
02356     """
02357     # Import MED file
02358     print "Import " + file_name.split(os.sep)[-1] + "..."
02359 
02360     try:
02361         paravis_instance.ImportFile(file_name)
02362         proxy = pv.GetActiveSource()
02363         if proxy is None:
02364             print "FAILED"
02365         else:
02366             proxy.UpdatePipeline()
02367             print "OK"
02368     except:
02369         print "FAILED"
02370     else:
02371         # Get view
02372         view = pv.GetRenderView()
02373 
02374         # Create required presentations for the proxy
02375         CreatePrsForProxy(proxy, view, prs_types,
02376                           picture_dir, picture_ext)
02377 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.CreatePrsForProxy (   proxy,
  view,
  prs_types,
  picture_dir,
  picture_ext 
)
Build presentations of the given types for all fields of the proxy.

Save snapshots in graphics files (type depends on the given extension).
Stores the files in the given directory.

Arguments:
  proxy: the pipeline object, containig data
  view: the render view
  prs_types: the list of presentation types to build
  picture_dir: the directory path for saving snapshots
  picture_ext: graphics files extension (determines file type)

Definition at line 2378 of file presentations.py.

02378 
02379 def CreatePrsForProxy(proxy, view, prs_types, picture_dir, picture_ext):
02380     """Build presentations of the given types for all fields of the proxy.
02381 
02382     Save snapshots in graphics files (type depends on the given extension).
02383     Stores the files in the given directory.
02384 
02385     Arguments:
02386       proxy: the pipeline object, containig data
02387       view: the render view
02388       prs_types: the list of presentation types to build
02389       picture_dir: the directory path for saving snapshots
02390       picture_ext: graphics files extension (determines file type)
02391 
02392     """
02393     # List of the field names
02394     field_names = list(proxy.PointArrays.GetData())
02395     nb_on_nodes = len(field_names)
02396     field_names.extend(proxy.CellArrays.GetData())
02397 
02398     # Add path separator to the end of picture path if necessery
02399     if not picture_dir.endswith(os.sep):
02400         picture_dir += os.sep
02401 
02402     # Mesh Presentation
02403     if PrsTypeEnum.MESH in prs_types:
02404         # Create Mesh presentation. Build all possible submeshes.
02405 
02406         # Remember the current state
02407         groups = list(proxy.Groups)
02408 
02409         # Iterate on meshes
02410         mesh_names = get_mesh_names(proxy)
02411         for mesh_name in mesh_names:
02412             # Build mesh on nodes and cells
02413             for entity in (EntityType.NODE, EntityType.CELL):
02414                 entity_name = EntityType.get_name(entity)
02415                 if if_possible(proxy, mesh_name, entity, PrsTypeEnum.MESH):
02416                     print "Creating submesh on " + entity_name + " for '" + mesh_name + "' mesh... "
02417                     prs = MeshOnEntity(proxy, mesh_name, entity)
02418                     if prs is None:
02419                         print "FAILED"
02420                         continue
02421                     else:
02422                         print "OK"
02423                     # Construct image file name
02424                     pic_name = picture_dir + mesh_name + "_" + entity_name + "." + picture_ext
02425 
02426                     # Show and dump the presentation into a graphics file
02427                     process_prs_for_test(prs, view, pic_name, False)
02428 
02429                 # Build submesh on all groups of the mesh
02430                 mesh_groups = get_group_names(proxy, mesh_name,
02431                                               entity, wo_nogroups=True)
02432                 for group in mesh_groups:
02433                     print "Creating submesh on group " + group + "... "
02434                     prs = MeshOnGroup(proxy, group)
02435                     if prs is None:
02436                         print "FAILED"
02437                         continue
02438                     else:
02439                         print "OK"
02440                     # Construct image file name
02441                     pic_name = picture_dir + group.replace('/', '_') + "." + picture_ext
02442 
02443                     # Show and dump the presentation into a graphics file
02444                     process_prs_for_test(prs, view, pic_name, False)
02445 
02446         # Restore the state
02447         proxy.Groups = groups
02448         proxy.UpdatePipeline()
02449 
02450     # Presentations on fields
02451     for (i, field_name) in enumerate(field_names):
02452         # Select only the current field:
02453         # necessary for getting the right timestamps
02454         cell_arrays = proxy.CellArrays.GetData()
02455         point_arrays = proxy.PointArrays.GetData()
02456         field_entity = None
02457         if (i >= nb_on_nodes):
02458             field_entity = EntityType.CELL
02459             proxy.PointArrays.DeselectAll()
02460             proxy.CellArrays = [field_name]
02461         else:
02462             field_entity = EntityType.NODE
02463             proxy.CellArrays.DeselectAll()
02464             proxy.PointArrays = [field_name]
02465 
02466         # Get timestamps
02467         proxy.UpdatePipelineInformation()
02468         timestamps = proxy.TimestepValues.GetData()
02469 
02470         # Restore fields selection state
02471         proxy.CellArrays = cell_arrays
02472         proxy.PointArrays = point_arrays
02473         proxy.UpdatePipelineInformation()
02474 
02475         for prs_type in prs_types:
02476             # Ignore mesh presentation
02477             if prs_type == PrsTypeEnum.MESH:
02478                 continue
02479 
02480             # Get name of presentation type
02481             prs_name = PrsTypeEnum.get_name(prs_type)
02482 
02483             # Build the presentation if possible
02484             possible = if_possible(proxy, field_name,
02485                                    field_entity, prs_type)
02486             if possible:
02487                 # Presentation type for graphics file name
02488                 f_prs_type = prs_name.replace(' ', '').upper()
02489 
02490                 for timestamp_nb in xrange(1, len(timestamps) + 1):
02491                     time = timestamps[timestamp_nb - 1]
02492                     print "Creating " + prs_name + " on " + field_name + ", time = " + str(time) + "... "
02493                     prs = create_prs(prs_type, proxy,
02494                                      field_entity, field_name, timestamp_nb)
02495                     if prs is None:
02496                         print "FAILED"
02497                         continue
02498                     else:
02499                         print "OK"
02500 
02501                     # Construct image file name
02502                     pic_name = picture_dir + field_name + "_" + str(time) + "_" + f_prs_type + "." + picture_ext
02503 
02504                     # Show and dump the presentation into a graphics file
02505                     process_prs_for_test(prs, view, pic_name)

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.CutLinesOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  nb_lines = 10,
  orientation1 = Orientation.XY,
  base_angle1 = 0,
  base_angle2 = 0,
  orientation2 = Orientation.YZ,
  cut_angle1 = 0,
  cut_angle2 = 0,
  displacement1 = 0.5,
  displacement2 = 0.5,
  generate_curves = False,
  vector_mode = 'Magnitude' 
)
Creates Cut Lines presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  nb_lines: number of lines
  orientation1: base plane orientation in 3D space
  base_angle1: rotation of the base plane in 3d space around the first
  axis of the orientation1 (X axis for XY, Y axis for YZ, Z axis for ZX).
  The angle of rotation is set in degrees. Acceptable range: [-45, 45].
  base_angle2: rotation of the base plane in 3d space around the second
  axis of the orientation1. Acceptable range: [-45, 45].
  orientation2: cutting planes orientation in 3D space
  cut_angle1: rotation of the cut planes in 3d space around the first
  axis of the orientation2. Acceptable range: [-45, 45].
  cut_angle2: rotation of the cuting planes in 3d space around the second
  axis of the orientation2. Acceptable range: [-45, 45].
  displacement1: base plane displacement
  displacement2: cutting planes displacement
  generate_curves: if true, 'PlotOverLine' filter will be created
  for each cut line
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Cut Lines as representation object if generate_curves == False,
  (Cut Lines as representation object, list of 'PlotOverLine') otherwise

Definition at line 1182 of file presentations.py.

01182 
01183                     vector_mode='Magnitude'):
01184     """Creates Cut Lines presentation on the given field.
01185 
01186     Arguments:
01187       proxy: the pipeline object, containig data
01188       entity: the entity type from PrsTypeEnum
01189       field_name: the field name
01190       timestamp_nb: the number of time step (1, 2, ...)
01191       nb_lines: number of lines
01192       orientation1: base plane orientation in 3D space
01193       base_angle1: rotation of the base plane in 3d space around the first
01194       axis of the orientation1 (X axis for XY, Y axis for YZ, Z axis for ZX).
01195       The angle of rotation is set in degrees. Acceptable range: [-45, 45].
01196       base_angle2: rotation of the base plane in 3d space around the second
01197       axis of the orientation1. Acceptable range: [-45, 45].
01198       orientation2: cutting planes orientation in 3D space
01199       cut_angle1: rotation of the cut planes in 3d space around the first
01200       axis of the orientation2. Acceptable range: [-45, 45].
01201       cut_angle2: rotation of the cuting planes in 3d space around the second
01202       axis of the orientation2. Acceptable range: [-45, 45].
01203       displacement1: base plane displacement
01204       displacement2: cutting planes displacement
01205       generate_curves: if true, 'PlotOverLine' filter will be created
01206       for each cut line
01207       vector_mode: the mode of transformation of vector values
01208       into scalar values, applicable only if the field contains vector values.
01209       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01210 
01211     Returns:
01212       Cut Lines as representation object if generate_curves == False,
01213       (Cut Lines as representation object, list of 'PlotOverLine') otherwise
01214 
01215     """
01216     # Check vector mode
01217     nb_components = get_nb_components(proxy, entity, field_name)
01218     check_vector_mode(vector_mode, nb_components)
01219 
01220     # Get time value
01221     time_value = get_time(proxy, timestamp_nb)
01222 
01223     # Set timestamp
01224     pv.GetRenderView().ViewTime = time_value
01225     pv.UpdatePipeline(time_value, proxy)
01226 
01227     # Create base plane
01228     base_plane = pv.Slice(proxy)
01229     base_plane.SliceType = "Plane"
01230 
01231     # Set base plane normal
01232     base_normal = get_normal_by_orientation(orientation1,
01233                                             radians(base_angle1),
01234                                             radians(base_angle2))
01235     base_plane.SliceType.Normal = base_normal
01236 
01237     # Set base plane position
01238     base_position = get_positions(1, base_normal,
01239                                   get_bounds(proxy), displacement1)
01240     base_plane.SliceOffsetValues = base_position
01241 
01242     # Check base plane
01243     base_plane.UpdatePipeline()
01244     if (base_plane.GetDataInformation().GetNumberOfCells() == 0):
01245         base_plane = proxy
01246 
01247     # Create cutting planes
01248     cut_planes = pv.Slice(base_plane)
01249     cut_planes.SliceType = "Plane"
01250 
01251     # Set cutting planes normal and get positions
01252     cut_normal = get_normal_by_orientation(orientation2,
01253                                            radians(cut_angle1),
01254                                            radians(cut_angle2))
01255     cut_planes.SliceType.Normal = cut_normal
01256 
01257     # Set cutting planes position
01258     cut_positions = get_positions(nb_lines, cut_normal,
01259                                   get_bounds(base_plane), displacement2)
01260 
01261     # Generate curves
01262     curves = []
01263     if generate_curves:
01264         index = 0
01265         for pos in cut_positions:
01266             # Get points for plot over line objects
01267             cut_planes.SliceOffsetValues = pos
01268             cut_planes.UpdatePipeline()
01269             bounds = get_bounds(cut_planes)
01270             point1 = [bounds[0], bounds[2], bounds[4]]
01271             point2 = [bounds[1], bounds[3], bounds[5]]
01272 
01273             # Create plot over line filter
01274             pol = pv.PlotOverLine(cut_planes,
01275                                   Source="High Resolution Line Source")
01276             pv.RenameSource('Y' + str(index), pol)
01277             pol.Source.Point1 = point1
01278             pol.Source.Point2 = point2
01279             pol.UpdatePipeline()
01280             curves.append(pol)
01281 
01282             index += 1
01283 
01284     cut_planes.SliceOffsetValues = cut_positions
01285     cut_planes.UpdatePipeline()
01286 
01287     # Get Cut Lines representation object
01288     cut_lines = pv.GetRepresentation(cut_planes)
01289 
01290     # Get lookup table
01291     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01292 
01293     # Set field range if necessary
01294     data_range = get_data_range(proxy, entity,
01295                                 field_name, vector_mode)
01296     lookup_table.LockScalarRange = 1
01297     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01298 
01299     # Set properties
01300     cut_lines.ColorAttributeType = EntityType.get_pvtype(entity)
01301     cut_lines.ColorArrayName = field_name
01302     cut_lines.LookupTable = lookup_table
01303 
01304     # Set wireframe represenatation mode
01305     cut_lines.Representation = 'Wireframe'
01306 
01307     # Add scalar bar
01308     add_scalar_bar(field_name, nb_components,
01309                    vector_mode, lookup_table, time_value)
01310 
01311     result = cut_lines
01312     # If curves were generated return tuple (cut lines, list of curves)
01313     if curves:
01314         result = cut_lines, curves
01315 
01316     return result
01317 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.CutPlanesOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  nb_planes = 10,
  orientation = Orientation.YZ,
  angle1 = 0,
  angle2 = 0,
  displacement = 0.5,
  vector_mode = 'Magnitude' 
)
Creates Cut Planes presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  nb_planes: number of cutting planes
  orientation: cutting planes orientation in 3D space
  angle1: rotation of the planes in 3d space around the first axis of the
  selected orientation (X axis for XY, Y axis for YZ, Z axis for ZX).
  The angle of rotation is set in degrees. Acceptable range: [-45, 45].
  angle2: rotation of the planes in 3d space around the second axis of the
  selected orientation. Acceptable range: [-45, 45].
  displacement: the displacement of the planes into one or another side
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Cut Planes as representation object.

Definition at line 1101 of file presentations.py.

01101 
01102                      displacement=0.5, vector_mode='Magnitude'):
01103     """Creates Cut Planes presentation on the given field.
01104 
01105     Arguments:
01106       proxy: the pipeline object, containig data
01107       entity: the entity type from PrsTypeEnum
01108       field_name: the field name
01109       timestamp_nb: the number of time step (1, 2, ...)
01110       nb_planes: number of cutting planes
01111       orientation: cutting planes orientation in 3D space
01112       angle1: rotation of the planes in 3d space around the first axis of the
01113       selected orientation (X axis for XY, Y axis for YZ, Z axis for ZX).
01114       The angle of rotation is set in degrees. Acceptable range: [-45, 45].
01115       angle2: rotation of the planes in 3d space around the second axis of the
01116       selected orientation. Acceptable range: [-45, 45].
01117       displacement: the displacement of the planes into one or another side
01118       vector_mode: the mode of transformation of vector values
01119       into scalar values, applicable only if the field contains vector values.
01120       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01121 
01122     Returns:
01123       Cut Planes as representation object.
01124 
01125     """
01126     # Check vector mode
01127     nb_components = get_nb_components(proxy, entity, field_name)
01128     check_vector_mode(vector_mode, nb_components)
01129 
01130     # Get time value
01131     time_value = get_time(proxy, timestamp_nb)
01132 
01133     # Set timestamp
01134     pv.GetRenderView().ViewTime = time_value
01135     pv.UpdatePipeline(time_value, proxy)
01136 
01137     # Create slice filter
01138     slice_filter = pv.Slice(proxy)
01139     slice_filter.SliceType = "Plane"
01140 
01141     # Set cut planes normal
01142     normal = get_normal_by_orientation(orientation,
01143                                        radians(angle1), radians(angle2))
01144     slice_filter.SliceType.Normal = normal
01145 
01146     # Set cut planes positions
01147     positions = get_positions(nb_planes, normal,
01148                               get_bounds(proxy), displacement)
01149     slice_filter.SliceOffsetValues = positions
01150 
01151     # Get Cut Planes representation object
01152     cut_planes = pv.GetRepresentation(slice_filter)
01153 
01154     # Get lookup table
01155     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01156 
01157     # Set field range if necessary
01158     data_range = get_data_range(proxy, entity,
01159                                 field_name, vector_mode)
01160     lookup_table.LockScalarRange = 1
01161     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01162 
01163     # Set properties
01164     cut_planes.ColorAttributeType = EntityType.get_pvtype(entity)
01165     cut_planes.ColorArrayName = field_name
01166     cut_planes.LookupTable = lookup_table
01167 
01168     # Add scalar bar
01169     add_scalar_bar(field_name, nb_components,
01170                    vector_mode, lookup_table, time_value)
01171 
01172     return cut_planes
01173 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.CutSegmentOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  point1,
  point2,
  vector_mode = 'Magnitude' 
)
Creates Cut Segment presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  point1: set the first point of the segment (as [x, y, z])
  point1: set the second point of the segment (as [x, y, z])
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Cut Segment as 3D representation object.

Definition at line 1319 of file presentations.py.

01319 
01320                       point1, point2, vector_mode='Magnitude'):
01321     """Creates Cut Segment presentation on the given field.
01322 
01323     Arguments:
01324       proxy: the pipeline object, containig data
01325       entity: the entity type from PrsTypeEnum
01326       field_name: the field name
01327       timestamp_nb: the number of time step (1, 2, ...)
01328       point1: set the first point of the segment (as [x, y, z])
01329       point1: set the second point of the segment (as [x, y, z])
01330       vector_mode: the mode of transformation of vector values
01331       into scalar values, applicable only if the field contains vector values.
01332       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01333 
01334     Returns:
01335       Cut Segment as 3D representation object.
01336 
01337     """
01338     # Check vector mode
01339     nb_components = get_nb_components(proxy, entity, field_name)
01340     check_vector_mode(vector_mode, nb_components)
01341 
01342     # Get time value
01343     time_value = get_time(proxy, timestamp_nb)
01344 
01345     # Set timestamp
01346     pv.GetRenderView().ViewTime = time_value
01347     pv.UpdatePipeline(time_value, proxy)
01348 
01349     # Create plot over line filter
01350     pol = pv.PlotOverLine(proxy, Source="High Resolution Line Source")
01351     pol.Source.Point1 = point1
01352     pol.Source.Point2 = point2
01353     pol.UpdatePipeline()
01354 
01355     # Get Cut Segment representation object
01356     cut_segment = pv.GetRepresentation(pol)
01357 
01358     # Get lookup table
01359     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01360 
01361     # Set field range if necessary
01362     data_range = get_data_range(proxy, entity,
01363                                 field_name, vector_mode)
01364     lookup_table.LockScalarRange = 1
01365     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01366 
01367     # Set properties
01368     cut_segment.ColorAttributeType = EntityType.get_pvtype(entity)
01369     cut_segment.ColorArrayName = field_name
01370     cut_segment.LookupTable = lookup_table
01371 
01372     # Set wireframe represenatation mode
01373     cut_segment.Representation = 'Wireframe'
01374 
01375     # Add scalar bar
01376     add_scalar_bar(field_name, nb_components,
01377                    vector_mode, lookup_table, time_value)
01378 
01379     return cut_segment
01380 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.DeformedShapeAndScalarMapOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  scale_factor = None,
  scalar_entity = None,
  scalar_field_name = None,
  vector_mode = 'Magnitude' 
)
Creates Defromed Shape And Scalar Map presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  scale_factor: scale factor of the deformation
  scalar_entity: scalar field entity
  scalar_field_name: scalar field, i.e. the field for coloring
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Defromed Shape And Scalar Map as representation object.

Definition at line 1600 of file presentations.py.

01600 
01601                                      vector_mode='Magnitude'):
01602     """Creates Defromed Shape And Scalar Map presentation on the given field.
01603 
01604     Arguments:
01605       proxy: the pipeline object, containig data
01606       entity: the entity type from PrsTypeEnum
01607       field_name: the field name
01608       timestamp_nb: the number of time step (1, 2, ...)
01609       scale_factor: scale factor of the deformation
01610       scalar_entity: scalar field entity
01611       scalar_field_name: scalar field, i.e. the field for coloring
01612       vector_mode: the mode of transformation of vector values
01613       into scalar values, applicable only if the field contains vector values.
01614       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01615 
01616     Returns:
01617       Defromed Shape And Scalar Map as representation object.
01618 
01619     """
01620     # We don't need mesh parts with no data on them
01621     on_points = []
01622     on_cells = []
01623 
01624     if entity == EntityType.NODE:
01625         on_points.append(field_name)
01626     else:
01627         on_cells.append(field_name)
01628 
01629     if scalar_entity and scalar_field_name:
01630         if scalar_entity == EntityType.NODE:
01631             on_points.append(scalar_field_name)
01632         else:
01633             on_cells.append(scalar_field_name)
01634 
01635     select_cells_with_data(proxy, on_points, on_cells)
01636 
01637     # Check vector mode
01638     nb_components = get_nb_components(proxy, entity, field_name)
01639     check_vector_mode(vector_mode, nb_components)
01640 
01641     # Get time value
01642     time_value = get_time(proxy, timestamp_nb)
01643 
01644     # Set timestamp
01645     pv.GetRenderView().ViewTime = time_value
01646     pv.UpdatePipeline(time_value, proxy)
01647 
01648     # Set scalar field by default
01649     scalar_field_entity = scalar_entity
01650     scalar_field = scalar_field_name
01651     if (scalar_field_entity is None) or (scalar_field is None):
01652         scalar_field_entity = entity
01653         scalar_field = field_name
01654 
01655     # Extract only groups with data for the field
01656     new_proxy = extract_groups_for_field(proxy, field_name, entity)
01657 
01658     # Do merge
01659     source = pv.MergeBlocks(new_proxy)
01660 
01661     # Cell data to point data
01662     if is_data_on_cells(proxy, field_name):
01663         cell_to_point = pv.CellDatatoPointData(source)
01664         cell_to_point.PassCellData = 1
01665         source = cell_to_point
01666 
01667     vector_array = field_name
01668     # If the given vector array has only 2 components, add the third one
01669     if nb_components == 2:
01670         calc = get_add_component_calc(source, EntityType.NODE, field_name)
01671         vector_array = calc.ResultArrayName
01672         source = calc
01673 
01674     # Warp by vector
01675     warp_vector = pv.WarpByVector(source)
01676     warp_vector.Vectors = [vector_array]
01677     if scale_factor is not None:
01678         warp_vector.ScaleFactor = scale_factor
01679     else:
01680         def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE,
01681                                       new_proxy, entity, field_name)
01682         warp_vector.ScaleFactor = def_scale
01683 
01684     # Get Defromed Shape And Scalar Map representation object
01685     defshapemap = pv.GetRepresentation(warp_vector)
01686 
01687     # Get lookup table
01688     lookup_table = get_lookup_table(scalar_field, nb_components, vector_mode)
01689 
01690     # Set field range if necessary
01691     data_range = get_data_range(proxy, scalar_field_entity,
01692                                 scalar_field, vector_mode)
01693     lookup_table.LockScalarRange = 1
01694     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01695 
01696     # Set properties
01697     defshapemap.ColorArrayName = scalar_field
01698     defshapemap.LookupTable = lookup_table
01699     defshapemap.ColorAttributeType = EntityType.get_pvtype(scalar_field_entity)
01700 
01701     # Add scalar bar
01702     add_scalar_bar(field_name, nb_components,
01703                    vector_mode, lookup_table, time_value)
01704 
01705     return defshapemap
01706 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.DeformedShapeOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  scale_factor = None,
  is_colored = False,
  vector_mode = 'Magnitude' 
)
Creates Defromed Shape presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  scale_factor: scale factor of the deformation
  is_colored: this option allows to color the presentation according to
  the corresponding data array values
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Defromed Shape as representation object.

Definition at line 1500 of file presentations.py.

01500 
01501                          vector_mode='Magnitude'):
01502     """Creates Defromed Shape presentation on the given field.
01503 
01504     Arguments:
01505       proxy: the pipeline object, containig data
01506       entity: the entity type from PrsTypeEnum
01507       field_name: the field name
01508       timestamp_nb: the number of time step (1, 2, ...)
01509       scale_factor: scale factor of the deformation
01510       is_colored: this option allows to color the presentation according to
01511       the corresponding data array values
01512       vector_mode: the mode of transformation of vector values
01513       into scalar values, applicable only if the field contains vector values.
01514       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01515 
01516     Returns:
01517       Defromed Shape as representation object.
01518 
01519     """
01520     # We don't need mesh parts with no data on them
01521     if entity == EntityType.NODE:
01522         select_cells_with_data(proxy, on_points=[field_name])
01523     else:
01524         select_cells_with_data(proxy, on_cells=[field_name])
01525 
01526     # Check vector mode
01527     nb_components = get_nb_components(proxy, entity, field_name)
01528     check_vector_mode(vector_mode, nb_components)
01529 
01530     # Get time value
01531     time_value = get_time(proxy, timestamp_nb)
01532 
01533     # Set timestamp
01534     pv.GetRenderView().ViewTime = time_value
01535     pv.UpdatePipeline(time_value, proxy)
01536 
01537     # Extract only groups with data for the field
01538     new_proxy = extract_groups_for_field(proxy, field_name, entity)
01539 
01540     # Do merge
01541     source = pv.MergeBlocks(new_proxy)
01542 
01543     # Cell data to point data
01544     if is_data_on_cells(proxy, field_name):
01545         cell_to_point = pv.CellDatatoPointData()
01546         cell_to_point.PassCellData = 1
01547         source = cell_to_point
01548 
01549     vector_array = field_name
01550     # If the given vector array has only 2 components, add the third one
01551     if nb_components == 2:
01552         calc = get_add_component_calc(source, EntityType.NODE, field_name)
01553         vector_array = calc.ResultArrayName
01554         source = calc
01555 
01556     # Warp by vector
01557     warp_vector = pv.WarpByVector(source)
01558     warp_vector.Vectors = [vector_array]
01559     if scale_factor is not None:
01560         warp_vector.ScaleFactor = scale_factor
01561     else:
01562         def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE,
01563                                       proxy, entity, field_name)
01564         warp_vector.ScaleFactor = def_scale
01565 
01566     # Get Deformed Shape representation object
01567     defshape = pv.GetRepresentation(warp_vector)
01568 
01569     # Get lookup table
01570     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01571 
01572     # Set field range if necessary
01573     data_range = get_data_range(proxy, entity,
01574                                 field_name, vector_mode)
01575     lookup_table.LockScalarRange = 1
01576     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01577 
01578     # Set properties
01579     if is_colored:
01580         defshape.ColorAttributeType = EntityType.get_pvtype(entity)
01581         defshape.ColorArrayName = field_name
01582     else:
01583         defshape.ColorArrayName = ''
01584     defshape.LookupTable = lookup_table
01585 
01586     # Set wireframe represenatation mode
01587     defshape.Representation = 'Wireframe'
01588 
01589     # Add scalar bar
01590     add_scalar_bar(field_name, nb_components,
01591                    vector_mode, lookup_table, time_value)
01592 
01593     return defshape
01594 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.display_only (   prs,
  view = None 
)
Display only the given presentation in the view.

Definition at line 241 of file presentations.py.

00241 
00242 def display_only(prs, view=None):
00243     """Display only the given presentation in the view."""
00244     hide_all(view)
00245     if (hasattr(prs, 'Visibility') and prs.Visibility != 1):
00246         prs.Visibility = 1
00247     pv.Render(view=view)
00248 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.dot_product (   a,
  b 
)
Dot product of two 3-vectors.

Definition at line 445 of file presentations.py.

00445 
00446 def dot_product(a, b):
00447     """Dot product of two 3-vectors."""
00448     dot = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
00449     return dot
00450 

Here is the caller graph for this function:

def presentations.extract_groups_for_field (   proxy,
  field_name,
  field_entity,
  force = False 
)
Exctract only groups which have the field.

Arguments:
  proxy: the pipeline object, containig data
  field_name: the field name
  field_entity: the field entity
  force: if True - ExtractGroup object will be created in any case

Returns:
  ExtractGroup object: if not all groups have the field or
  the force argument is true
  The initial proxy: if no groups had been filtered.

Definition at line 784 of file presentations.py.

00784 
00785 def extract_groups_for_field(proxy, field_name, field_entity, force=False):
00786     """Exctract only groups which have the field.
00787 
00788     Arguments:
00789       proxy: the pipeline object, containig data
00790       field_name: the field name
00791       field_entity: the field entity
00792       force: if True - ExtractGroup object will be created in any case
00793 
00794     Returns:
00795       ExtractGroup object: if not all groups have the field or
00796       the force argument is true
00797       The initial proxy: if no groups had been filtered.
00798 
00799     """
00800     source = proxy
00801 
00802     # Remember the state
00803     initial_groups = list(proxy.Groups)
00804 
00805     # Get data information for the field entity
00806     entity_data_info = None
00807     field_data = proxy.GetFieldDataInformation()
00808 
00809     if field_name in field_data.keys():
00810         entity_data_info = field_data
00811     elif field_entity == EntityType.CELL:
00812         entity_data_info = proxy.GetCellDataInformation()
00813     elif field_entity == EntityType.NODE:
00814         entity_data_info = proxy.GetPointDataInformation()
00815 
00816     # Collect groups for extraction
00817     groups_to_extract = []
00818 
00819     for group in initial_groups:
00820         proxy.Groups = [group]
00821         proxy.UpdatePipeline()
00822         if field_name in entity_data_info.keys():
00823             groups_to_extract.append(group)
00824 
00825     # Restore state
00826     proxy.Groups = initial_groups
00827     proxy.UpdatePipeline()
00828 
00829     # Extract groups if necessary
00830     if force or (len(groups_to_extract) < len(initial_groups)):
00831         extract_group = pv.ExtractGroup(proxy)
00832         extract_group.Groups = groups_to_extract
00833         extract_group.UpdatePipeline()
00834         source = extract_group
00835 
00836     return source
00837 

Here is the caller graph for this function:

def presentations.GaussPointsOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  is_deformed = True,
  scale_factor = None,
  is_colored = True,
  color = None,
  primitive = GaussType.SPRITE,
  is_proportional = True,
  max_pixel_size = 256,
  multiplier = None,
  vector_mode = 'Magnitude' 
)
Creates Gauss Points on the given field.

Arguments:

proxy: the pipeline object, containig data
entity: the field entity type from PrsTypeEnum
field_name: the field name
timestamp_nb: the number of time step (1, 2, ...)
is_deformed: defines whether the Gauss Points will be deformed or not
scale_factor -- the scale factor for deformation. Will be taken into
account only if is_deformed is True.
If not passed by user, default scale will be computed.
is_colored -- defines whether the Gauss Points will be multicolored,
using the corresponding data values
color: defines the presentation color as [R, G, B] triple. Taken into
account only if is_colored is False.
primitive: primitive type from GaussType
is_proportional: if True, the size of primitives will depends on
the gauss point value
max_pixel_size: the maximum sizr of the Gauss Points primitive in pixels
multiplier: coefficient between data values and the size of primitives
If not passed by user, default scale will be computed.
vector_mode: the mode of transformation of vector values into
scalar values, applicable only if the field contains vector values.
Possible modes: 'Magnitude' - vector module;
'X', 'Y', 'Z' - vector components.

Returns:
  Gauss Points as representation object.

Definition at line 1994 of file presentations.py.

01994 
01995                        multiplier=None, vector_mode='Magnitude'):
01996     """Creates Gauss Points on the given field.
01997 
01998     Arguments:
01999 
02000     proxy: the pipeline object, containig data
02001     entity: the field entity type from PrsTypeEnum
02002     field_name: the field name
02003     timestamp_nb: the number of time step (1, 2, ...)
02004     is_deformed: defines whether the Gauss Points will be deformed or not
02005     scale_factor -- the scale factor for deformation. Will be taken into
02006     account only if is_deformed is True.
02007     If not passed by user, default scale will be computed.
02008     is_colored -- defines whether the Gauss Points will be multicolored,
02009     using the corresponding data values
02010     color: defines the presentation color as [R, G, B] triple. Taken into
02011     account only if is_colored is False.
02012     primitive: primitive type from GaussType
02013     is_proportional: if True, the size of primitives will depends on
02014     the gauss point value
02015     max_pixel_size: the maximum sizr of the Gauss Points primitive in pixels
02016     multiplier: coefficient between data values and the size of primitives
02017     If not passed by user, default scale will be computed.
02018     vector_mode: the mode of transformation of vector values into
02019     scalar values, applicable only if the field contains vector values.
02020     Possible modes: 'Magnitude' - vector module;
02021     'X', 'Y', 'Z' - vector components.
02022 
02023     Returns:
02024       Gauss Points as representation object.
02025 
02026     """
02027     # We don't need mesh parts with no data on them
02028     if entity == EntityType.NODE:
02029         select_cells_with_data(proxy, on_points=[field_name])
02030     else:
02031         select_cells_with_data(proxy, on_cells=[field_name])
02032 
02033     # Check vector mode
02034     nb_components = get_nb_components(proxy, entity, field_name)
02035     check_vector_mode(vector_mode, nb_components)
02036 
02037     # Get time value
02038     time_value = get_time(proxy, timestamp_nb)
02039 
02040     # Set timestamp
02041     pv.GetRenderView().ViewTime = time_value
02042     proxy.UpdatePipeline(time=time_value)
02043 
02044     # Extract only groups with data for the field
02045     source = extract_groups_for_field(proxy, field_name, entity)
02046 
02047     # Quadrature point arrays
02048     qp_arrays = proxy.QuadraturePointArrays.Available
02049 
02050     # If no quadrature point array is passed, use cell centers
02051     if field_name in qp_arrays:
02052         generate_qp = pv.GenerateQuadraturePoints(source)
02053         generate_qp.SelectSourceArray = ['CELLS', 'ELGA_Offset']
02054         source = generate_qp
02055     else:
02056         # Cell centers
02057         cell_centers = pv.CellCenters(source)
02058         cell_centers.VertexCells = 1
02059         source = cell_centers
02060 
02061     source.UpdatePipeline()
02062 
02063     # Check if deformation enabled
02064     if is_deformed and nb_components > 1:
02065         vector_array = field_name
02066         # If the given vector array has only 2 components, add the third one
02067         if nb_components == 2:
02068             calc = get_add_component_calc(source,
02069                                           EntityType.NODE, field_name)
02070             vector_array = calc.ResultArrayName
02071             source = calc
02072 
02073         # Warp by vector
02074         warp_vector = pv.WarpByVector(source)
02075         warp_vector.Vectors = [vector_array]
02076         if scale_factor is not None:
02077             warp_vector.ScaleFactor = scale_factor
02078         else:
02079             def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE, proxy,
02080                                           entity, field_name)
02081             warp_vector.ScaleFactor = def_scale
02082         warp_vector.UpdatePipeline()
02083         source = warp_vector
02084 
02085     # Get Gauss Points representation object
02086     gausspnt = pv.GetRepresentation(source)
02087 
02088     # Get lookup table
02089     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
02090 
02091     # Set field range if necessary
02092     data_range = get_data_range(proxy, entity,
02093                                 field_name, vector_mode)
02094     lookup_table.LockScalarRange = 1
02095     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
02096 
02097     # Set display properties
02098     if is_colored:
02099         gausspnt.ColorAttributeType = EntityType.get_pvtype(entity)
02100         gausspnt.ColorArrayName = field_name
02101     else:
02102         gausspnt.ColorArrayName = ''
02103         if color:
02104             gausspnt.DiffuseColor = color
02105 
02106     gausspnt.LookupTable = lookup_table
02107 
02108     # Add scalar bar
02109     add_scalar_bar(field_name, nb_components,
02110                    vector_mode, lookup_table, time_value)
02111 
02112     # Set point sprite representation
02113     gausspnt.Representation = 'Point Sprite'
02114 
02115     # Point sprite settings
02116     gausspnt.InterpolateScalarsBeforeMapping = 0
02117     gausspnt.MaxPixelSize = max_pixel_size
02118 
02119     # Render mode
02120     gausspnt.RenderMode = GaussType.get_mode(primitive)
02121 
02122     #if primitive == GaussType.SPRITE:
02123         # Set texture
02124         # TODO(MZN): replace with pvsimple high-level interface
02125     #    texture = sm.CreateProxy("textures", "SpriteTexture")
02126     #    alphamprop = texture.GetProperty("AlphaMethod")
02127     #    alphamprop.SetElement(0, 2)  # Clamp
02128     #    alphatprop = texture.GetProperty("AlphaThreshold")
02129     #    alphatprop.SetElement(0, 63)
02130     #    maxprop = texture.GetProperty("Maximum")
02131     #    maxprop.SetElement(0, 255)
02132     #    texture.UpdateVTKObjects()
02133 
02134     #    gausspnt.Texture = texture
02135         #gausspnt.Texture.AlphaMethod = 'Clamp'
02136         #gausspnt.Texture.AlphaThreshold = 63
02137         #gausspnt.Texture.Maximum= 255
02138 
02139     # Proportional radius
02140     gausspnt.RadiusUseScalarRange = 0
02141     gausspnt.RadiusIsProportional = 0
02142 
02143     if is_proportional:
02144         mult = multiplier
02145         if mult is None:
02146             mult = abs(0.1 / data_range[1])
02147 
02148         gausspnt.RadiusScalarRange = data_range
02149         gausspnt.RadiusTransferFunctionEnabled = 1
02150         gausspnt.RadiusMode = 'Scalar'
02151         gausspnt.RadiusArray = ['POINTS', field_name]
02152         if nb_components > 1:
02153             v_comp = get_vector_component(vector_mode)
02154             gausspnt.RadiusVectorComponent = v_comp
02155         gausspnt.RadiusTransferFunctionMode = 'Table'
02156         gausspnt.RadiusScalarRange = data_range
02157         gausspnt.RadiusUseScalarRange = 1
02158         gausspnt.RadiusIsProportional = 1
02159         gausspnt.RadiusProportionalFactor = mult
02160     else:
02161         gausspnt.RadiusTransferFunctionEnabled = 0
02162         gausspnt.RadiusMode = 'Constant'
02163         gausspnt.RadiusArray = ['POINTS', 'Constant Radius']
02164 
02165     return gausspnt
02166 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_add_component_calc (   proxy,
  array_entity,
  array_name 
)
Creates 3-component array from 2-component.

The first two components is from the original array. The 3rd component
is zero.
If the number of components is not equal to 2 - return original array name.

Returns:
  the calculator object.

Definition at line 693 of file presentations.py.

00693 
00694 def get_add_component_calc(proxy, array_entity, array_name):
00695     """Creates 3-component array from 2-component.
00696 
00697     The first two components is from the original array. The 3rd component
00698     is zero.
00699     If the number of components is not equal to 2 - return original array name.
00700 
00701     Returns:
00702       the calculator object.
00703 
00704     """
00705     calculator = None
00706 
00707     nb_components = get_nb_components(proxy, array_entity, array_name)
00708     if nb_components == 2:
00709         calculator = pv.Calculator(proxy)
00710         attribute_mode = "point_data"
00711         if array_entity != EntityType.NODE:
00712             attribute_mode = "cell_data"
00713         calculator.AttributeMode = attribute_mode
00714         expression = "iHat * " + array_name + "_X + jHat * " + array_name + "_Y + kHat * 0"
00715         calculator.Function = expression
00716         calculator.ResultArrayName = array_name + "_3c"
00717         calculator.UpdatePipeline()
00718 
00719     return calculator
00720 

Here is the call graph for this function:

Here is the caller graph for this function:

Get current scalar bar.

Definition at line 898 of file presentations.py.

00898 
00899 def get_bar():
00900     """Get current scalar bar."""
00901     global _current_bar
00902 
00903     return _current_bar
00904 

def presentations.get_bound_project (   bound_box,
  dir 
)
Get bounds projection

Definition at line 529 of file presentations.py.

00529 
00530 def get_bound_project(bound_box, dir):
00531     """Get bounds projection"""
00532     bound_points = [[bound_box[0], bound_box[2], bound_box[4]],
00533                     [bound_box[1], bound_box[2], bound_box[4]],
00534                     [bound_box[0], bound_box[3], bound_box[4]],
00535                     [bound_box[1], bound_box[3], bound_box[4]],
00536                     [bound_box[0], bound_box[2], bound_box[5]],
00537                     [bound_box[1], bound_box[2], bound_box[5]],
00538                     [bound_box[0], bound_box[3], bound_box[5]],
00539                     [bound_box[1], bound_box[3], bound_box[5]]]
00540 
00541     bound_prj = [0, 0, 0]
00542     bound_prj[0] = dot_product(dir, bound_points[0])
00543     bound_prj[1] = bound_prj[0]
00544 
00545     for i in xrange(1, 8):
00546         tmp = dot_product(dir, bound_points[i])
00547         if bound_prj[1] < tmp:
00548             bound_prj[1] = tmp
00549         if bound_prj[0] > tmp:
00550             bound_prj[0] = tmp
00551 
00552     bound_prj[2] = bound_prj[1] - bound_prj[0]
00553     bound_prj[1] = bound_prj[0] + (1.0 - EPS) * bound_prj[2]
00554     bound_prj[0] = bound_prj[0] + EPS * bound_prj[2]
00555     bound_prj[2] = bound_prj[1] - bound_prj[0]
00556 
00557     return bound_prj
00558 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_bounds (   proxy)
Get bounds of the proxy in 3D.

Definition at line 358 of file presentations.py.

00358 
00359 def get_bounds(proxy):
00360     """Get bounds of the proxy in 3D."""
00361     dataInfo = proxy.GetDataInformation()
00362     bounds_info = dataInfo.GetBounds()
00363     return bounds_info
00364 

Here is the caller graph for this function:

def presentations.get_calc_magnitude (   proxy,
  array_entity,
  array_name 
)
Compute magnitude for the given vector array via Calculator.

Returns:
  the calculator object.

Definition at line 663 of file presentations.py.

00663 
00664 def get_calc_magnitude(proxy, array_entity, array_name):
00665     """Compute magnitude for the given vector array via Calculator.
00666 
00667     Returns:
00668       the calculator object.
00669 
00670     """
00671     calculator = None
00672 
00673     # Transform vector array to scalar array if possible
00674     nb_components = get_nb_components(proxy, array_entity, array_name)
00675     if (nb_components > 1):
00676         calculator = pv.Calculator(proxy)
00677         attribute_mode = "point_data"
00678         if array_entity != EntityType.NODE:
00679             attribute_mode = "cell_data"
00680         calculator.AttributeMode = attribute_mode
00681         if (nb_components == 2):
00682             # Workaroud: calculator unable to compute magnitude
00683             # if number of components equal to 2
00684             func = "sqrt(" + array_name + "_X^2+" + array_name + "_Y^2)"
00685             calculator.Function = func
00686         else:
00687             calculator.Function = "mag(" + array_name + ")"
00688         calculator.ResultArrayName = array_name + "_magnitude"
00689         calculator.UpdatePipeline()
00690 
00691     return calculator
00692 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_contours (   scalar_range,
  nb_contours 
)
Generate contour values.

Definition at line 577 of file presentations.py.

00577 
00578 def get_contours(scalar_range, nb_contours):
00579     """Generate contour values."""
00580     contours = []
00581     for i in xrange(nb_contours):
00582         pos = scalar_range[0] + i * (
00583             scalar_range[1] - scalar_range[0]) / (nb_contours - 1)
00584         contours.append(pos)
00585 
00586     return contours
00587 

Here is the caller graph for this function:

def presentations.get_data_range (   proxy,
  entity,
  field_name,
  vector_mode = 'Magnitude',
  cut_off = False 
)
Get data range for the field.

Arguments:
  proxy: the pipeline object, containig data array for the field
  entity: the field entity
  field_name: the field name
  vector_mode: the vector mode ('Magnitude', 'X', 'Y' or 'Z')

Returns:
  Data range as [min, max]

Definition at line 315 of file presentations.py.

00315 
00316                    cut_off=False):
00317     """Get data range for the field.
00318 
00319     Arguments:
00320       proxy: the pipeline object, containig data array for the field
00321       entity: the field entity
00322       field_name: the field name
00323       vector_mode: the vector mode ('Magnitude', 'X', 'Y' or 'Z')
00324 
00325     Returns:
00326       Data range as [min, max]
00327 
00328     """
00329     entity_data_info = None
00330     field_data = proxy.GetFieldDataInformation()
00331 
00332     if field_name in field_data.keys():
00333         entity_data_info = field_data
00334     elif entity == EntityType.CELL:
00335         entity_data_info = proxy.GetCellDataInformation()
00336     elif entity == EntityType.NODE:
00337         entity_data_info = proxy.GetPointDataInformation()
00338 
00339     data_range = []
00340 
00341     if field_name in entity_data_info.keys():
00342         vcomp = get_vector_component(vector_mode)
00343         data_range = entity_data_info[field_name].GetComponentRange(vcomp)
00344     else:
00345         pv_entity = EntityType.get_pvtype(entity)
00346         warnings.warn("Field " + field_name +
00347                       " is unknown for " + pv_entity + "!")
00348 
00349     # Cut off the range
00350     if cut_off and (data_range[0] <= data_range[1]):
00351         data_range = list(data_range)
00352         delta = abs(data_range[1] - data_range[0]) * GAP_COEFFICIENT
00353         data_range[0] += delta
00354         data_range[1] -= delta
00355 
00356     return data_range
00357 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_default_scale (   prs_type,
  proxy,
  entity,
  field_name 
)
Get default scale factor.

Definition at line 641 of file presentations.py.

00641 
00642 def get_default_scale(prs_type, proxy, entity, field_name):
00643     """Get default scale factor."""
00644     data_range = get_data_range(proxy, entity, field_name)
00645 
00646     if prs_type == PrsTypeEnum.DEFORMEDSHAPE:
00647         EPS = 1.0 / VTK_LARGE_FLOAT
00648         if abs(data_range[1]) > EPS:
00649             scale_factor = get_scale_factor(proxy)
00650             return scale_factor / data_range[1]
00651     elif prs_type == PrsTypeEnum.PLOT3D:
00652         bounds = get_bounds(proxy)
00653         length = sqrt((bounds[1] - bounds[0]) ** 2 +
00654                       (bounds[3] - bounds[2]) ** 2 +
00655                       (bounds[5] - bounds[4]) ** 2)
00656 
00657         EPS = 0.3
00658         if data_range[1] > 0:
00659             return length / data_range[1] * EPS
00660 
00661     return 0
00662 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_group_entity (   full_group_name)
Return entity type of the group by its full name.

Definition at line 938 of file presentations.py.

00938 
00939 def get_group_entity(full_group_name):
00940     """Return entity type of the group by its full name."""
00941     aList = full_group_name.split('/')
00942     if len(aList) >= 3 :
00943         entity_name = full_group_name.split('/')[2]
00944         entity = EntityType.get_type(entity_name)
00945         return entity
00946 

Here is the caller graph for this function:

def presentations.get_group_mesh_name (   full_group_name)
Return mesh name of the group by its full name.

Definition at line 930 of file presentations.py.

00930 
00931 def get_group_mesh_name(full_group_name):
00932     """Return mesh name of the group by its full name."""
00933     aList = full_group_name.split('/')
00934     if len(aList) >= 2 :
00935         group_name = full_group_name.split('/')[1]
00936         return group_name
00937 

Here is the caller graph for this function:

def presentations.get_group_names (   proxy,
  mesh_name,
  entity,
  wo_nogroups = False 
)
Return full names of all groups of the given entity type
from the mesh with the given name as a list.

Definition at line 963 of file presentations.py.

00963 
00964 def get_group_names(proxy, mesh_name, entity, wo_nogroups=False):
00965     """Return full names of all groups of the given entity type
00966     from the mesh with the given name as a list.
00967     """
00968     groups = proxy.Groups.Available
00969 
00970     condition = lambda item: (get_group_mesh_name(item) == mesh_name and
00971                               get_group_entity(item) == entity)
00972     group_names = [item for item in groups if condition(item)]
00973 
00974     if wo_nogroups:
00975         # Remove "No_Group" group
00976         not_no_group = lambda item: get_group_short_name(item) != "No_Group"
00977         group_names = filter(not_no_group, group_names)
00978 
00979     return group_names
00980 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_group_short_name (   full_group_name)
Return short name of the group by its full name.

Definition at line 947 of file presentations.py.

00947 
00948 def get_group_short_name(full_group_name):
00949     """Return short name of the group by its full name."""
00950     aList = full_group_name.split('/')
00951     if len(aList) >= 4 :
00952         short_name = full_group_name.split('/')[3]
00953         return short_name
00954 

Here is the caller graph for this function:

def presentations.get_lookup_table (   field_name,
  nb_components,
  vector_mode = 'Magnitude' 
)
Get lookup table for the given field.

Definition at line 905 of file presentations.py.

00905 
00906 def get_lookup_table(field_name, nb_components, vector_mode='Magnitude'):
00907     """Get lookup table for the given field."""
00908     lookup_table = pv.GetLookupTableForArray(field_name, nb_components)
00909 
00910     if vector_mode == 'Magnitude':
00911         lookup_table.VectorMode = vector_mode
00912     elif vector_mode == 'X':
00913         lookup_table.VectorMode = 'Component'
00914         lookup_table.VectorComponent = 0
00915     elif vector_mode == 'Y':
00916         lookup_table.VectorMode = 'Component'
00917         lookup_table.VectorComponent = 1
00918     elif vector_mode == 'Z':
00919         lookup_table.VectorMode = 'Component'
00920         lookup_table.VectorComponent = 2
00921     else:
00922         raise ValueError("Incorrect vector mode: " + vector_mode)
00923 
00924     lookup_table.Discretize = 0
00925     lookup_table.ColorSpace = 'HSV'
00926     lookup_table.LockScalarRange = 0
00927 
00928     return lookup_table
00929 

Here is the caller graph for this function:

Return all mesh names in the given proxy as a set.

Definition at line 955 of file presentations.py.

00955 
00956 def get_mesh_names(proxy):
00957     """Return all mesh names in the given proxy as a set."""
00958     groups = proxy.Groups.Available
00959     mesh_names = set([get_group_mesh_name(item) for item in groups])
00960 
00961     return mesh_names
00962 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_nb_components (   proxy,
  entity,
  field_name 
)
Return number of components for the field.

Definition at line 588 of file presentations.py.

00588 
00589 def get_nb_components(proxy, entity, field_name):
00590     """Return number of components for the field."""
00591     entity_data_info = None
00592     field_data = proxy.GetFieldDataInformation()
00593 
00594     if field_name in field_data.keys():
00595         entity_data_info = field_data
00596     elif entity == EntityType.CELL:
00597         entity_data_info = proxy.GetCellDataInformation()
00598     elif entity == EntityType.NODE:
00599         entity_data_info = proxy.GetPointDataInformation()
00600 
00601     nb_comp = None
00602     if field_name in entity_data_info.keys():
00603         nb_comp = entity_data_info[field_name].GetNumberOfComponents()
00604     else:
00605         pv_entity = EntityType.get_pvtype(entity)
00606         raise ValueError("Field " + field_name +
00607                          " is unknown for " + pv_entity + "!")
00608 
00609     return nb_comp
00610 

Here is the caller graph for this function:

def presentations.get_normal_by_orientation (   orientation,
  ang1 = 0,
  ang2 = 0 
)
Get normal for the plane by its orientation.

Definition at line 492 of file presentations.py.

00492 
00493 def get_normal_by_orientation(orientation, ang1=0, ang2=0):
00494     """Get normal for the plane by its orientation."""
00495     i_plane = 0
00496     rotation = [[], [], []]
00497     rx = ry = rz = [[1.0, 0.0, 0.0],
00498                     [0.0, 1.0, 0.0],
00499                     [0.0, 0.0, 1.0]]
00500 
00501     normal = [0.0, 0.0, 0.0]
00502     if orientation == Orientation.XY:
00503         if abs(ang1) > EPS:
00504             rx = get_rx(ang1)
00505         if abs(ang2) > EPS:
00506             ry = get_ry(ang2)
00507         rotation = multiply3x3(rx, ry)
00508         i_plane = 2
00509     elif orientation == Orientation.ZX:
00510         if abs(ang1) > EPS:
00511             rz = get_rz(ang1)
00512         if abs(ang2) > EPS:
00513             rx = get_rx(ang2)
00514         rotation = multiply3x3(rz, rx)
00515         i_plane = 1
00516     elif orientation == Orientation.YZ:
00517         if abs(ang1) > EPS:
00518             ry = get_ry(ang1)
00519         if abs(ang2) > EPS:
00520             rz = get_rz(ang2)
00521         rotation = multiply3x3(ry, rz)
00522         i_plane = 0
00523 
00524     for i in xrange(0, 3):
00525         normal[i] = rotation[i][i_plane]
00526 
00527     return normal
00528 

Here is the call graph for this function:

Here is the caller graph for this function:

Get the optimum cutting plane orientation for Plot 3D.

Definition at line 417 of file presentations.py.

00417 
00418 def get_orientation(proxy):
00419     """Get the optimum cutting plane orientation for Plot 3D."""
00420     orientation = Orientation.XY
00421 
00422     bounds = get_bounds(proxy)
00423     delta = [bounds[1] - bounds[0],
00424              bounds[3] - bounds[2],
00425              bounds[5] - bounds[4]]
00426 
00427     if (delta[0] >= delta[1] and delta[0] >= delta[2]):
00428         if (delta[1] >= delta[2]):
00429             orientation = Orientation.XY
00430         else:
00431             orientation = Orientation.ZX
00432     elif (delta[1] >= delta[0] and delta[1] >= delta[2]):
00433         if (delta[0] >= delta[2]):
00434             orientation = Orientation.XY
00435         else:
00436             orientation = Orientation.YZ
00437     elif (delta[2] >= delta[0] and delta[2] >= delta[1]):
00438         if (delta[0] >= delta[1]):
00439             orientation = Orientation.ZX
00440         else:
00441             orientation = Orientation.YZ
00442 
00443     return orientation
00444 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_positions (   nb_planes,
  dir,
  bounds,
  displacement 
)
Compute plane positions.

Definition at line 559 of file presentations.py.

00559 
00560 def get_positions(nb_planes, dir, bounds, displacement):
00561     """Compute plane positions."""
00562     positions = []
00563     bound_prj = get_bound_project(bounds, dir)
00564     if nb_planes > 1:
00565         step = bound_prj[2] / (nb_planes - 1)
00566         abs_displacement = step * displacement
00567         start_pos = bound_prj[0] - 0.5 * step + abs_displacement
00568         for i in xrange(nb_planes):
00569             pos = start_pos + i * step
00570             positions.append(pos)
00571     else:
00572         pos = bound_prj[0] + bound_prj[2] * displacement
00573         positions.append(pos)
00574 
00575     return positions
00576 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_rx (   ang)
Get X rotation matrix by angle.

Definition at line 465 of file presentations.py.

00465 
00466 def get_rx(ang):
00467     """Get X rotation matrix by angle."""
00468     rx = [[1.0, 0.0,      0.0],
00469           [0.0, cos(ang), -sin(ang)],
00470           [0.0, sin(ang), cos(ang)]]
00471 
00472     return rx
00473 

Here is the caller graph for this function:

def presentations.get_ry (   ang)
Get Y rotation matrix by angle.

Definition at line 474 of file presentations.py.

00474 
00475 def get_ry(ang):
00476     """Get Y rotation matrix by angle."""
00477     ry = [[cos(ang),  0.0, sin(ang)],
00478           [0.0,       1.0, 0.0],
00479           [-sin(ang), 0.0, cos(ang)]]
00480 
00481     return ry
00482 

Here is the caller graph for this function:

def presentations.get_rz (   ang)
Get Z rotation matrix by angle.

Definition at line 483 of file presentations.py.

00483 
00484 def get_rz(ang):
00485     """Get Z rotation matrix by angle."""
00486     rz = [[cos(ang), -sin(ang), 0.0],
00487           [sin(ang), cos(ang),  0.0],
00488           [0.0,      0.0,       1.0]]
00489 
00490     return rz
00491 

Here is the caller graph for this function:

Compute scale factor.

Definition at line 611 of file presentations.py.

00611 
00612 def get_scale_factor(proxy):
00613     """Compute scale factor."""
00614     if not proxy:
00615         return 0.0
00616 
00617     proxy.UpdatePipeline()
00618     data_info = proxy.GetDataInformation()
00619 
00620     nb_cells = data_info.GetNumberOfCells()
00621     nb_points = data_info.GetNumberOfPoints()
00622     nb_elements = nb_cells if nb_cells > 0  else nb_points
00623     bounds = get_bounds(proxy)
00624 
00625     volume = 1
00626     vol = dim = 0
00627 
00628     for i in xrange(0, 6, 2):
00629         vol = abs(bounds[i + 1] - bounds[i])
00630         if vol > 0:
00631             dim += 1
00632             volume *= vol
00633 
00634     if nb_elements == 0 or dim < 1 / VTK_LARGE_FLOAT:
00635         return 0
00636 
00637     volume /= nb_elements
00638 
00639     return pow(volume, 1 / dim)
00640 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_time (   proxy,
  timestamp_nb 
)
Get time value by timestamp number.

Definition at line 981 of file presentations.py.

00981 
00982 def get_time(proxy, timestamp_nb):
00983     """Get time value by timestamp number."""
00984     # Check timestamp number
00985     timestamps = proxy.TimestepValues.GetData()
00986     if ((timestamp_nb - 1) not in xrange(len(timestamps))):
00987         raise ValueError("Timestamp number is out of range: " + timestamp_nb)
00988 
00989     # Return time value
00990     return timestamps[timestamp_nb - 1]
00991 

Here is the caller graph for this function:

def presentations.get_vector_component (   vector_mode)
Get vector component as ineger.

Translate vector component notation from string
to integer:
  'Magnitude': -1
  'X': 0
  'Y': 1
  'Z': 2

Definition at line 291 of file presentations.py.

00291 
00292 def get_vector_component(vector_mode):
00293     """Get vector component as ineger.
00294 
00295     Translate vector component notation from string
00296     to integer:
00297       'Magnitude': -1
00298       'X': 0
00299       'Y': 1
00300       'Z': 2
00301 
00302     """
00303     vcomponent = -1
00304 
00305     if vector_mode == 'X':
00306         vcomponent = 0
00307     elif vector_mode == 'Y':
00308         vcomponent = 1
00309     elif vector_mode == 'Z':
00310         vcomponent = 2
00311 
00312     return vcomponent
00313 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.get_x_range (   proxy)
Get X range of the proxy bounds in 3D.

Definition at line 365 of file presentations.py.

00365 
00366 def get_x_range(proxy):
00367     """Get X range of the proxy bounds in 3D."""
00368     bounds_info = get_bounds(proxy)
00369     return bounds_info[0:2]
00370 

Here is the call graph for this function:

def presentations.get_y_range (   proxy)
Get Y range of the proxy bounds in 3D.

Definition at line 371 of file presentations.py.

00371 
00372 def get_y_range(proxy):
00373     """Get Y range of the proxy bounds in 3D."""
00374     bounds_info = get_bounds(proxy)
00375     return bounds_info[2:4]
00376 

Here is the call graph for this function:

def presentations.get_z_range (   proxy)
Get Z range of the proxy bounds in 3D.

Definition at line 377 of file presentations.py.

00377 
00378 def get_z_range(proxy):
00379     """Get Z range of the proxy bounds in 3D."""
00380     bounds_info = get_bounds(proxy)
00381     return bounds_info[4:6]
00382 

Here is the call graph for this function:

def presentations.hide_all (   view,
  to_remove = False 
)
Hide all representations in the view.

Definition at line 227 of file presentations.py.

00227 
00228 def hide_all(view, to_remove=False):
00229     """Hide all representations in the view."""
00230     if not view:
00231         view = pv.GetRenderView()
00232 
00233     rep_list = view.Representations
00234     for rep in rep_list:
00235         if hasattr(rep, 'Visibility') and rep.Visibility != 0:
00236             rep.Visibility = 0
00237         if to_remove:
00238             view.Representations.remove(rep)
00239     pv.Render(view=view)
00240 

Here is the caller graph for this function:

def presentations.if_possible (   proxy,
  field_name,
  entity,
  prs_type 
)
Check if the presentation creation is possible on the given field.

Definition at line 838 of file presentations.py.

00838 
00839 def if_possible(proxy, field_name, entity, prs_type):
00840     """Check if the presentation creation is possible on the given field."""
00841     result = True
00842     if (prs_type == PrsTypeEnum.DEFORMEDSHAPE or
00843         prs_type == PrsTypeEnum.DEFORMEDSHAPESCALARMAP or
00844         prs_type == PrsTypeEnum.VECTORS or
00845         prs_type == PrsTypeEnum.STREAMLINES):
00846         nb_comp = get_nb_components(proxy, entity, field_name)
00847         result = (nb_comp > 1)
00848     elif (prs_type == PrsTypeEnum.GAUSSPOINTS):
00849         result = (entity == EntityType.CELL or
00850                   field_name in proxy.QuadraturePointArrays.Available)
00851     elif (prs_type == PrsTypeEnum.MESH):
00852         result = len(get_group_names(proxy, field_name, entity)) > 0
00853 
00854     return result
00855 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.is_data_on_cells (   proxy,
  field_name 
)
Check the existence of a field on cells with the given name.

Definition at line 395 of file presentations.py.

00395 
00396 def is_data_on_cells(proxy, field_name):
00397     """Check the existence of a field on cells with the given name."""
00398     cell_data_info = proxy.GetCellDataInformation()
00399     return (field_name in cell_data_info.keys())
00400 

Here is the caller graph for this function:

def presentations.is_empty (   proxy)
Check if the object contains any points or cells.

Returns:
  True: if the given proxy doesn't contain any points or cells
  False: otherwise

Definition at line 401 of file presentations.py.

00401 
00402 def is_empty(proxy):
00403     """Check if the object contains any points or cells.
00404 
00405     Returns:
00406       True: if the given proxy doesn't contain any points or cells
00407       False: otherwise
00408 
00409     """
00410     data_info = proxy.GetDataInformation()
00411 
00412     nb_cells = data_info.GetNumberOfCells()
00413     nb_points = data_info.GetNumberOfPoints()
00414 
00415     return not(nb_cells + nb_points)
00416 

Here is the caller graph for this function:

Check if the given input is planar.

Definition at line 383 of file presentations.py.

00383 
00384 def is_planar_input(proxy):
00385     """Check if the given input is planar."""
00386     bounds_info = get_bounds(proxy)
00387 
00388     if (abs(bounds_info[0] - bounds_info[1]) <= FLT_MIN or
00389         abs(bounds_info[2] - bounds_info[3]) <= FLT_MIN or
00390         abs(bounds_info[4] - bounds_info[5]) <= FLT_MIN):
00391         return True
00392 
00393     return False
00394 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.IsoSurfacesOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  custom_range = None,
  nb_surfaces = 10,
  is_colored = True,
  color = None,
  vector_mode = 'Magnitude' 
)
Creates Iso Surfaces presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  custom_range: scalar range, if undefined the source range will be applied
  nb_surfaces: number of surfaces, which will be generated
  is_colored: this option allows to color the presentation according to
  the corresponding data array values. If False - the presentation will
  be one-coloured.
  color: defines the presentation color as [R, G, B] triple. Taken into
  account only if is_colored is False.
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Iso Surfaces as representation object.

Definition at line 1881 of file presentations.py.

01881 
01882                        is_colored=True, color=None, vector_mode='Magnitude'):
01883     """Creates Iso Surfaces presentation on the given field.
01884 
01885     Arguments:
01886       proxy: the pipeline object, containig data
01887       entity: the entity type from PrsTypeEnum
01888       field_name: the field name
01889       timestamp_nb: the number of time step (1, 2, ...)
01890       custom_range: scalar range, if undefined the source range will be applied
01891       nb_surfaces: number of surfaces, which will be generated
01892       is_colored: this option allows to color the presentation according to
01893       the corresponding data array values. If False - the presentation will
01894       be one-coloured.
01895       color: defines the presentation color as [R, G, B] triple. Taken into
01896       account only if is_colored is False.
01897       vector_mode: the mode of transformation of vector values
01898       into scalar values, applicable only if the field contains vector values.
01899       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01900 
01901     Returns:
01902       Iso Surfaces as representation object.
01903 
01904     """
01905     # We don't need mesh parts with no data on them
01906     if entity == EntityType.NODE:
01907         select_cells_with_data(proxy, on_points=[field_name])
01908     else:
01909         select_cells_with_data(proxy, on_cells=[field_name])
01910 
01911     # Check vector mode
01912     nb_components = get_nb_components(proxy, entity, field_name)
01913     check_vector_mode(vector_mode, nb_components)
01914 
01915     # Get time value
01916     time_value = get_time(proxy, timestamp_nb)
01917 
01918     # Set timestamp
01919     pv.GetRenderView().ViewTime = time_value
01920     pv.UpdatePipeline(time_value, proxy)
01921 
01922     # Extract only groups with data for the field
01923     new_proxy = extract_groups_for_field(proxy, field_name, entity)
01924 
01925     # Do merge
01926     source = pv.MergeBlocks(new_proxy)
01927 
01928     # Transform cell data into point data if necessary
01929     if is_data_on_cells(proxy, field_name):
01930         cell_to_point = pv.CellDatatoPointData(source)
01931         cell_to_point.PassCellData = 1
01932         source = cell_to_point
01933 
01934     contour_by = ['POINTS', field_name]
01935 
01936     # Transform vector array to scalar array if necessary
01937     if (nb_components > 1):
01938         calc = get_calc_magnitude(source, EntityType.NODE, field_name)
01939         contour_by = ['POINTS', calc.ResultArrayName]
01940         source = calc
01941 
01942     # Contour filter settings
01943     contour = pv.Contour(source)
01944     contour.ComputeScalars = 1
01945     contour.ContourBy = contour_by
01946 
01947     # Specify the range
01948     scalar_range = custom_range
01949     if (scalar_range is None):
01950         scalar_range = get_data_range(proxy, entity,
01951                                       field_name, cut_off=True)
01952 
01953     # Get contour values for the range
01954     surfaces = get_contours(scalar_range, nb_surfaces)
01955 
01956     # Set contour values
01957     contour.Isosurfaces = surfaces
01958 
01959     # Get Iso Surfaces representation object
01960     isosurfaces = pv.GetRepresentation(contour)
01961 
01962     # Get lookup table
01963     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01964 
01965     # Set field range if necessary
01966     data_range = get_data_range(proxy, entity,
01967                                 field_name, vector_mode)
01968     lookup_table.LockScalarRange = 1
01969     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01970 
01971     # Set display properties
01972     if (is_colored):
01973         isosurfaces.ColorAttributeType = EntityType.get_pvtype(entity)
01974         isosurfaces.ColorArrayName = field_name
01975     else:
01976         isosurfaces.ColorArrayName = ''
01977         if color:
01978             isosurfaces.DiffuseColor = color
01979     isosurfaces.LookupTable = lookup_table
01980 
01981     # Add scalar bar
01982     add_scalar_bar(field_name, nb_components,
01983                    vector_mode, lookup_table, time_value)
01984 
01985     return isosurfaces
01986 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.MeshOnEntity (   proxy,
  mesh_name,
  entity 
)
Creates submesh of the entity type for the mesh.

Arguments:
  proxy -- the pipeline object, containig data
  mesh_name -- the mesh name
  entity -- the entity type

Returns:
  Submesh as representation object of the given source.

Definition at line 2270 of file presentations.py.

02270 
02271 def MeshOnEntity(proxy, mesh_name, entity):
02272     """Creates submesh of the entity type for the mesh.
02273 
02274     Arguments:
02275       proxy -- the pipeline object, containig data
02276       mesh_name -- the mesh name
02277       entity -- the entity type
02278 
02279     Returns:
02280       Submesh as representation object of the given source.
02281 
02282     """
02283     # Select all cell types
02284     select_all_cells(proxy)
02285 
02286     # Get subset of groups on the given entity
02287     subset = get_group_names(proxy, mesh_name, entity)
02288 
02289     # Select only groups of the given entity type
02290     proxy.Groups = subset
02291     proxy.UpdatePipeline()
02292 
02293     # Get representation object if the submesh is not empty
02294     prs = None
02295     if (proxy.GetDataInformation().GetNumberOfPoints() or
02296         proxy.GetDataInformation().GetNumberOfCells()):
02297         prs = pv.GetRepresentation(proxy)
02298         prs.ColorArrayName = ''
02299 
02300     return prs
02301 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.MeshOnGroup (   proxy,
  group_name 
)
Creates submesh on the group.

Arguments:
  proxy -- the pipeline object, containig data
  group_name -- the full group name

Returns:
  Representation object of the given source with single group
  selected.

Definition at line 2302 of file presentations.py.

02302 
02303 def MeshOnGroup(proxy, group_name):
02304     """Creates submesh on the group.
02305 
02306     Arguments:
02307       proxy -- the pipeline object, containig data
02308       group_name -- the full group name
02309 
02310     Returns:
02311       Representation object of the given source with single group
02312       selected.
02313 
02314     """
02315     # Select all cell types
02316     select_all_cells(proxy)
02317 
02318     # Select only the group with the given name
02319     one_group = [group_name]
02320     proxy.Groups = one_group
02321     proxy.UpdatePipeline()
02322 
02323     # Get representation object if the submesh is not empty
02324     prs = None
02325 
02326     # Check if the group was set
02327     if proxy.Groups.GetData() == one_group:
02328         group_entity = get_group_entity(group_name)
02329         # Check if the submesh is not empty
02330         nb_items = 0
02331         if group_entity == EntityType.NODE:
02332             nb_items = proxy.GetDataInformation().GetNumberOfPoints()
02333         elif group_entity == EntityType.CELL:
02334             nb_items = proxy.GetDataInformation().GetNumberOfCells()
02335 
02336         if nb_items:
02337             prs = pv.GetRepresentation(proxy)
02338             prs.ColorArrayName = ''
02339 
02340     return prs
02341 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.multiply3x3 (   a,
  b 
)
Mutltiply one 3x3 matrix by another.

Definition at line 451 of file presentations.py.

00451 
00452 def multiply3x3(a, b):
00453     """Mutltiply one 3x3 matrix by another."""
00454     c = [[0, 0, 0],
00455          [0, 0, 0],
00456          [0, 0, 0]]
00457 
00458     for i in xrange(3):
00459         c[0][i] = a[0][0] * b[0][i] + a[0][1] * b[1][i] + a[0][2] * b[2][i]
00460         c[1][i] = a[1][0] * b[0][i] + a[1][1] * b[1][i] + a[1][2] * b[2][i]
00461         c[2][i] = a[2][0] * b[0][i] + a[2][1] * b[1][i] + a[2][2] * b[2][i]
00462 
00463     return c
00464 

Here is the caller graph for this function:

def presentations.Plot3DOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  orientation = Orientation.AUTO,
  angle1 = 0,
  angle2 = 0,
  position = 0.5,
  is_relative = True,
  scale_factor = None,
  is_contour = False,
  nb_contours = 32,
  vector_mode = 'Magnitude' 
)
Creates Plot 3D presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  orientation: the cut plane plane orientation in 3D space, if
  the input is planar - will not be taken into account
  angle1: rotation of the cut plane in 3d space around the first axis
  of the selected orientation (X axis for XY, Y axis for YZ,
  Z axis for ZX).
  The angle of rotation is set in degrees. Acceptable range: [-45, 45].
  angle2: rotation of the cut plane in 3d space around the second axis
  of the selected orientation. Acceptable range: [-45, 45].
  position: position of the cut plane in the object (ranging from 0 to 1).
  The value 0.5 corresponds to cutting by halves.
  is_relative: defines if the cut plane position is relative or absolute
  scale_factor: deformation scale factor
  is_contour: if True - Plot 3D will be represented with a set of contours,
  otherwise - Plot 3D will be represented with a smooth surface
  nb_contours: number of contours, applied if is_contour is True
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Plot 3D as representation object.

Definition at line 1713 of file presentations.py.

01713 
01714                   vector_mode='Magnitude'):
01715     """Creates Plot 3D presentation on the given field.
01716 
01717     Arguments:
01718       proxy: the pipeline object, containig data
01719       entity: the entity type from PrsTypeEnum
01720       field_name: the field name
01721       timestamp_nb: the number of time step (1, 2, ...)
01722       orientation: the cut plane plane orientation in 3D space, if
01723       the input is planar - will not be taken into account
01724       angle1: rotation of the cut plane in 3d space around the first axis
01725       of the selected orientation (X axis for XY, Y axis for YZ,
01726       Z axis for ZX).
01727       The angle of rotation is set in degrees. Acceptable range: [-45, 45].
01728       angle2: rotation of the cut plane in 3d space around the second axis
01729       of the selected orientation. Acceptable range: [-45, 45].
01730       position: position of the cut plane in the object (ranging from 0 to 1).
01731       The value 0.5 corresponds to cutting by halves.
01732       is_relative: defines if the cut plane position is relative or absolute
01733       scale_factor: deformation scale factor
01734       is_contour: if True - Plot 3D will be represented with a set of contours,
01735       otherwise - Plot 3D will be represented with a smooth surface
01736       nb_contours: number of contours, applied if is_contour is True
01737       vector_mode: the mode of transformation of vector values
01738       into scalar values, applicable only if the field contains vector values.
01739       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01740 
01741     Returns:
01742       Plot 3D as representation object.
01743 
01744     """
01745     # We don't need mesh parts with no data on them
01746     if entity == EntityType.NODE:
01747         select_cells_with_data(proxy, on_points=[field_name])
01748     else:
01749         select_cells_with_data(proxy, on_cells=[field_name])
01750 
01751     # Check vector mode
01752     nb_components = get_nb_components(proxy, entity, field_name)
01753     check_vector_mode(vector_mode, nb_components)
01754 
01755     # Get time value
01756     time_value = get_time(proxy, timestamp_nb)
01757 
01758     # Set timestamp
01759     pv.GetRenderView().ViewTime = time_value
01760     pv.UpdatePipeline(time_value, proxy)
01761 
01762     # Extract only groups with data for the field
01763     new_proxy = extract_groups_for_field(proxy, field_name, entity)
01764 
01765     # Do merge
01766     merge_blocks = pv.MergeBlocks(new_proxy)
01767     merge_blocks.UpdatePipeline()
01768 
01769     poly_data = None
01770 
01771     # Cutting plane
01772 
01773     # Define orientation if necessary (auto mode)
01774     plane_orientation = orientation
01775     if (orientation == Orientation.AUTO):
01776         plane_orientation = get_orientation(proxy)
01777 
01778     # Get cutting plane normal
01779     normal = None
01780 
01781     if (not is_planar_input(proxy)):
01782         normal = get_normal_by_orientation(plane_orientation,
01783                                            radians(angle1), radians(angle2))
01784 
01785         # Create slice filter
01786         slice_filter = pv.Slice(merge_blocks)
01787         slice_filter.SliceType = "Plane"
01788 
01789         # Set cutting plane normal
01790         slice_filter.SliceType.Normal = normal
01791 
01792         # Set cutting plane position
01793         if (is_relative):
01794             base_position = get_positions(1, normal,
01795                                           get_bounds(proxy), position)
01796             slice_filter.SliceOffsetValues = base_position
01797         else:
01798             slice_filter.SliceOffsetValues = position
01799 
01800         slice_filter.UpdatePipeline()
01801         poly_data = slice_filter
01802     else:
01803         normal = get_normal_by_orientation(plane_orientation, 0, 0)
01804 
01805     use_normal = 0
01806     # Geometry filter
01807     if not poly_data or poly_data.GetDataInformation().GetNumberOfCells() == 0:
01808         geometry_filter = pv.GeometryFilter(merge_blocks)
01809         poly_data = geometry_filter
01810         use_normal = 1  # TODO(MZN): workaround
01811 
01812     warp_scalar = None
01813     plot3d = None
01814     source = poly_data
01815 
01816     if is_data_on_cells(poly_data, field_name):
01817         # Cell data to point data
01818         cell_to_point = pv.CellDatatoPointData(poly_data)
01819         cell_to_point.PassCellData = 1
01820         source = cell_to_point
01821 
01822     scalars = ['POINTS', field_name]
01823 
01824     # Transform vector array to scalar array if necessary
01825     if (nb_components > 1):
01826         calc = get_calc_magnitude(source, EntityType.NODE, field_name)
01827         scalars = ['POINTS', calc.ResultArrayName]
01828         source = calc
01829 
01830     # Warp by scalar
01831     warp_scalar = pv.WarpByScalar(source)
01832     warp_scalar.Scalars = scalars
01833     warp_scalar.Normal = normal
01834     warp_scalar.UseNormal = use_normal
01835     if scale_factor is not None:
01836         warp_scalar.ScaleFactor = scale_factor
01837     else:
01838         def_scale = get_default_scale(PrsTypeEnum.PLOT3D,
01839                                       proxy, entity, field_name)
01840         warp_scalar.ScaleFactor = def_scale
01841 
01842     warp_scalar.UpdatePipeline()
01843     source = warp_scalar
01844 
01845     if (is_contour):
01846         # Contours
01847         contour = pv.Contour(warp_scalar)
01848         contour.PointMergeMethod = "Uniform Binning"
01849         contour.ContourBy = ['POINTS', field_name]
01850         scalar_range = get_data_range(proxy, entity,
01851                                       field_name, vector_mode)
01852         contour.Isosurfaces = get_contours(scalar_range, nb_contours)
01853         contour.UpdatePipeline()
01854         source = contour
01855 
01856     # Get Plot 3D representation object
01857     plot3d = pv.GetRepresentation(source)
01858 
01859     # Get lookup table
01860     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01861 
01862     # Set field range if necessary
01863     data_range = get_data_range(proxy, entity,
01864                                 field_name, vector_mode)
01865     lookup_table.LockScalarRange = 1
01866     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01867 
01868     # Set properties
01869     plot3d.ColorAttributeType = EntityType.get_pvtype(entity)
01870     plot3d.ColorArrayName = field_name
01871     plot3d.LookupTable = lookup_table
01872 
01873     # Add scalar bar
01874     add_scalar_bar(field_name, nb_components,
01875                    vector_mode, lookup_table, time_value)
01876 
01877     return plot3d
01878 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.process_prs_for_test (   prs,
  view,
  picture_name,
  show_bar = True 
)
Show presentation and record snapshot image.

Arguments:
  prs: the presentation to show
  view: the render view
  picture_name: the full name of the graphics file to save
  show_bar: to show scalar bar or not

Definition at line 171 of file presentations.py.

00171 
00172 def process_prs_for_test(prs, view, picture_name, show_bar=True):
00173     """Show presentation and record snapshot image.
00174 
00175     Arguments:
00176       prs: the presentation to show
00177       view: the render view
00178       picture_name: the full name of the graphics file to save
00179       show_bar: to show scalar bar or not
00180 
00181     """
00182     # Show the presentation only
00183     display_only(prs, view)
00184 
00185     # Show scalar bar
00186     if show_bar and _current_bar:
00187         _current_bar.Visibility = 1
00188 
00189     # Reset the view
00190     reset_view(view)
00191 
00192     # Create a directory for screenshot if necessary
00193     file_name = re.sub("\s+", "_", picture_name)
00194     pic_dir = os.path.dirname(picture_name)
00195     if not os.path.exists(pic_dir):
00196         os.makedirs(pic_dir)
00197 
00198     # Save picture
00199     pv.WriteImage(file_name, view=view, Magnification=1)
00200 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.reset_view (   view = None)
Reset the view.

Set predefined (taken from Post-Pro) camera settings.
If the view is not passed, the active view is used.

Definition at line 201 of file presentations.py.

00201 
00202 def reset_view(view=None):
00203     """Reset the view.
00204 
00205     Set predefined (taken from Post-Pro) camera settings.
00206     If the view is not passed, the active view is used.
00207 
00208     """
00209     if not view:
00210         view = pv.GetRenderView()
00211 
00212     # Camera preferences
00213     view.CameraFocalPoint = [0.0, 0.0, 0.0]
00214     view.CameraViewUp = [0.0, 0.0, 1.0]
00215     view.CameraPosition = [738.946, -738.946, 738.946]
00216 
00217     # Turn on the headligth
00218     view.LightSwitch = 1
00219     view.LightIntensity = 0.5
00220 
00221     # Use parallel projection
00222     view.CameraParallelProjection = 1
00223 
00224     view.ResetCamera()
00225     pv.Render(view=view)
00226 

Here is the caller graph for this function:

def presentations.ScalarMapOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  vector_mode = 'Magnitude' 
)
Creates Scalar Map presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Scalar Map as representation object.

Definition at line 1035 of file presentations.py.

01035 
01036                      vector_mode='Magnitude'):
01037     """Creates Scalar Map presentation on the given field.
01038 
01039     Arguments:
01040       proxy: the pipeline object, containig data
01041       entity: the entity type from PrsTypeEnum
01042       field_name: the field name
01043       timestamp_nb: the number of time step (1, 2, ...)
01044       vector_mode: the mode of transformation of vector values
01045       into scalar values, applicable only if the field contains vector values.
01046       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01047 
01048     Returns:
01049       Scalar Map as representation object.
01050 
01051     """
01052     # We don't need mesh parts with no data on them
01053     if entity == EntityType.NODE:
01054         select_cells_with_data(proxy, on_points=[field_name])
01055     else:
01056         select_cells_with_data(proxy, on_cells=[field_name])
01057 
01058     # Check vector mode
01059     nb_components = get_nb_components(proxy, entity, field_name)
01060     check_vector_mode(vector_mode, nb_components)
01061 
01062     # Get time value
01063     time_value = get_time(proxy, timestamp_nb)
01064 
01065     # Set timestamp
01066     pv.GetRenderView().ViewTime = time_value
01067     pv.UpdatePipeline(time_value, proxy)
01068 
01069     # Extract only groups with data for the field
01070     new_proxy = extract_groups_for_field(proxy, field_name, entity,
01071                                          force=True)
01072 
01073     # Get Scalar Map representation object
01074     scalarmap = pv.GetRepresentation(new_proxy)
01075 
01076     # Get lookup table
01077     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01078 
01079     # Set field range if necessary
01080     data_range = get_data_range(proxy, entity,
01081                                 field_name, vector_mode)
01082     lookup_table.LockScalarRange = 1
01083     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01084     # Set properties
01085     scalarmap.ColorAttributeType = EntityType.get_pvtype(entity)
01086     scalarmap.ColorArrayName = field_name
01087     scalarmap.LookupTable = lookup_table
01088 
01089     # Add scalar bar
01090     bar_title = field_name + ", " + str(time_value)
01091     if (nb_components > 1):
01092         bar_title += "\n" + vector_mode
01093     add_scalar_bar(field_name, nb_components, vector_mode,
01094                    lookup_table, time_value)
01095 
01096     return scalarmap
01097 

Here is the call graph for this function:

Here is the caller graph for this function:

Select all cell types.

Used in creation of mesh/submesh presentation.

Definition at line 721 of file presentations.py.

00721 
00722 def select_all_cells(proxy):
00723     """Select all cell types.
00724 
00725     Used in creation of mesh/submesh presentation.
00726 
00727     """
00728     ### Old API all_cell_types = proxy.CellTypes.Available
00729     all_cell_types = proxy.Entity.Available
00730     ### Old API proxy.CellTypes = all_cell_types
00731     proxy.Entity = all_cell_types
00732     proxy.UpdatePipeline()
00733 

Here is the caller graph for this function:

def presentations.select_cells_with_data (   proxy,
  on_points = None,
  on_cells = None 
)
Select cell types with data.

Only cell types with data for the given fields will be selected.
If no fields defined (neither on points nor on cells) only cell
types with data for even one field (from available) will be selected.

Definition at line 734 of file presentations.py.

00734 
00735 def select_cells_with_data(proxy, on_points=None, on_cells=None):
00736     """Select cell types with data.
00737 
00738     Only cell types with data for the given fields will be selected.
00739     If no fields defined (neither on points nor on cells) only cell
00740     types with data for even one field (from available) will be selected.
00741 
00742     """
00743     #all_cell_types = proxy.CellTypes.Available
00744     all_cell_types = proxy.Entity.Available
00745     all_arrays = list(proxy.CellArrays.GetData())
00746     all_arrays.extend(proxy.PointArrays.GetData())
00747 
00748     if not all_arrays:
00749         file_name = proxy.FileName.split(os.sep)[-1]
00750         print "Warning: " + file_name + " doesn't contain any data array."
00751 
00752     # List of cell types to be selected
00753     cell_types_on = []
00754 
00755     for cell_type in all_cell_types:
00756         #proxy.CellTypes = [cell_type]
00757         proxy.Entity = [cell_type]
00758         proxy.UpdatePipeline()
00759 
00760         cell_arrays = proxy.GetCellDataInformation().keys()
00761         point_arrays = proxy.GetPointDataInformation().keys()
00762 
00763         if on_points or on_cells:
00764             if on_points is None:
00765                 on_points = []
00766             if on_cells is None:
00767                 on_cells = []
00768 
00769             if (all(array in cell_arrays for array in on_cells) and
00770                 all(array in point_arrays for array in on_points)):
00771                 # Add cell type to the list
00772                 cell_types_on.append(cell_type)
00773         else:
00774             in_arrays = lambda array: ((array in cell_arrays) or
00775                                        (array in point_arrays))
00776             if any(in_arrays(array) for array in all_arrays):
00777                 cell_types_on.append(cell_type)
00778 
00779     # Select cell types
00780     #proxy.CellTypes = cell_types_on
00781     proxy.Entity = cell_types_on
00782     proxy.UpdatePipeline()
00783 

Here is the caller graph for this function:

def presentations.set_visible_lines (   xy_prs,
  lines 
)
Set visible only the given lines for XYChartRepresentation.

Definition at line 249 of file presentations.py.

00249 
00250 def set_visible_lines(xy_prs, lines):
00251     """Set visible only the given lines for XYChartRepresentation."""
00252     sv = xy_prs.GetProperty("SeriesVisibilityInfo").GetData()
00253     visible = '0'
00254 
00255     for i in xrange(0, len(sv)):
00256         if i % 2 == 0:
00257             line_name = sv[i]
00258             if line_name in lines:
00259                 visible = '1'
00260             else:
00261                 visible = '0'
00262         else:
00263             sv[i] = visible
00264 
00265     xy_prs.SeriesVisibility = sv
00266 

def presentations.StreamLinesOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  direction = 'BOTH',
  is_colored = False,
  color = None,
  vector_mode = 'Magnitude' 
)
Creates Stream Lines presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  direction: the stream lines direction ('FORWARD', 'BACKWARD' or 'BOTH')
  is_colored: this option allows to color the presentation according to
  the corresponding data values. If False - the presentation will
  be one-coloured.
  color: defines the presentation color as [R, G, B] triple. Taken into
  account only if is_colored is False.
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Stream Lines as representation object.

Definition at line 2169 of file presentations.py.

02169 
02170                        vector_mode='Magnitude'):
02171     """Creates Stream Lines presentation on the given field.
02172 
02173     Arguments:
02174       proxy: the pipeline object, containig data
02175       entity: the entity type from PrsTypeEnum
02176       field_name: the field name
02177       timestamp_nb: the number of time step (1, 2, ...)
02178       direction: the stream lines direction ('FORWARD', 'BACKWARD' or 'BOTH')
02179       is_colored: this option allows to color the presentation according to
02180       the corresponding data values. If False - the presentation will
02181       be one-coloured.
02182       color: defines the presentation color as [R, G, B] triple. Taken into
02183       account only if is_colored is False.
02184       vector_mode: the mode of transformation of vector values
02185       into scalar values, applicable only if the field contains vector values.
02186       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
02187 
02188     Returns:
02189       Stream Lines as representation object.
02190 
02191     """
02192     # We don't need mesh parts with no data on them
02193     if entity == EntityType.NODE:
02194         select_cells_with_data(proxy, on_points=[field_name])
02195     else:
02196         select_cells_with_data(proxy, on_cells=[field_name])
02197 
02198     # Check vector mode
02199     nb_components = get_nb_components(proxy, entity, field_name)
02200     check_vector_mode(vector_mode, nb_components)
02201 
02202     # Get time value
02203     time_value = get_time(proxy, timestamp_nb)
02204 
02205     # Set timestamp
02206     pv.GetRenderView().ViewTime = time_value
02207     pv.UpdatePipeline(time_value, proxy)
02208 
02209     # Extract only groups with data for the field
02210     new_proxy = extract_groups_for_field(proxy, field_name, entity)
02211 
02212     # Do merge
02213     source = pv.MergeBlocks(new_proxy)
02214 
02215     # Cell data to point data
02216     if is_data_on_cells(proxy, field_name):
02217         cell_to_point = pv.CellDatatoPointData(source)
02218         cell_to_point.PassCellData = 1
02219         cell_to_point.UpdatePipeline()
02220         source = cell_to_point
02221 
02222     vector_array = field_name
02223     # If the given vector array has only 2 components, add the third one
02224     if nb_components == 2:
02225         calc = get_add_component_calc(source, EntityType.NODE, field_name)
02226         vector_array = calc.ResultArrayName
02227         calc.UpdatePipeline()
02228         source = calc
02229 
02230     # Stream Tracer
02231     stream = pv.StreamTracer(source)
02232     stream.SeedType = "Point Source"
02233     stream.Vectors = ['POINTS', vector_array]
02234     stream.SeedType = "Point Source"
02235     stream.IntegrationDirection = direction
02236     stream.IntegratorType = 'Runge-Kutta 2'
02237     stream.UpdatePipeline()
02238 
02239     # Get Stream Lines representation object
02240     if is_empty(stream):
02241         return None
02242     streamlines = pv.GetRepresentation(stream)
02243 
02244     # Get lookup table
02245     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
02246 
02247     # Set field range if necessary
02248     data_range = get_data_range(new_proxy, entity,
02249                                 field_name, vector_mode)
02250     lookup_table.LockScalarRange = 1
02251     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
02252 
02253     # Set properties
02254     if is_colored:
02255         streamlines.ColorAttributeType = EntityType.get_pvtype(entity)
02256         streamlines.ColorArrayName = field_name
02257     else:
02258         streamlines.ColorArrayName = ''
02259         if color:
02260             streamlines.DiffuseColor = color
02261 
02262     streamlines.LookupTable = lookup_table
02263 
02264     # Add scalar bar
02265     add_scalar_bar(field_name, nb_components,
02266                    vector_mode, lookup_table, time_value)
02267 
02268     return streamlines
02269 

Here is the call graph for this function:

Here is the caller graph for this function:

def presentations.VectorsOnField (   proxy,
  entity,
  field_name,
  timestamp_nb,
  scale_factor = None,
  glyph_pos = GlyphPos.TAIL,
  glyph_type = '2D Glyph',
  is_colored = False,
  vector_mode = 'Magnitude' 
)
Creates Vectors presentation on the given field.

Arguments:
  proxy: the pipeline object, containig data
  entity: the entity type from PrsTypeEnum
  field_name: the field name
  timestamp_nb: the number of time step (1, 2, ...)
  scale_factor: scale factor
  glyph_pos: the position of glyphs
  glyph_type: the type of glyphs
  is_colored: this option allows to color the presentation according to
  the corresponding data array values
  vector_mode: the mode of transformation of vector values
  into scalar values, applicable only if the field contains vector values.
  Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.

Returns:
  Vectors as representation object.

Definition at line 1384 of file presentations.py.

01384 
01385                    is_colored=False, vector_mode='Magnitude'):
01386     """Creates Vectors presentation on the given field.
01387 
01388     Arguments:
01389       proxy: the pipeline object, containig data
01390       entity: the entity type from PrsTypeEnum
01391       field_name: the field name
01392       timestamp_nb: the number of time step (1, 2, ...)
01393       scale_factor: scale factor
01394       glyph_pos: the position of glyphs
01395       glyph_type: the type of glyphs
01396       is_colored: this option allows to color the presentation according to
01397       the corresponding data array values
01398       vector_mode: the mode of transformation of vector values
01399       into scalar values, applicable only if the field contains vector values.
01400       Possible modes: 'Magnitude', 'X', 'Y' or 'Z'.
01401 
01402     Returns:
01403       Vectors as representation object.
01404 
01405     """
01406     # Check vector mode
01407     nb_components = get_nb_components(proxy, entity, field_name)
01408     check_vector_mode(vector_mode, nb_components)
01409 
01410     # Get time value
01411     time_value = get_time(proxy, timestamp_nb)
01412 
01413     # Set timestamp
01414     pv.GetRenderView().ViewTime = time_value
01415     pv.UpdatePipeline(time_value, proxy)
01416 
01417     # Extract only groups with data for the field
01418     new_proxy = extract_groups_for_field(proxy, field_name, entity)
01419     source = new_proxy
01420 
01421     # Cell centers
01422     if is_data_on_cells(proxy, field_name):
01423         cell_centers = pv.CellCenters(source)
01424         cell_centers.VertexCells = 1
01425         source = cell_centers
01426 
01427     vector_array = field_name
01428     # If the given vector array has only 2 components, add the third one
01429     if nb_components == 2:
01430         calc = get_add_component_calc(source, EntityType.NODE, field_name)
01431         vector_array = calc.ResultArrayName
01432         source = calc
01433 
01434     # Glyph
01435     glyph = pv.Glyph(source)
01436     glyph.Vectors = vector_array
01437     glyph.ScaleMode = 'vector'
01438     glyph.MaskPoints = 0
01439 
01440     # Set glyph type
01441     glyph.GlyphType = glyph_type
01442     if glyph_type == '2D Glyph':
01443         glyph.GlyphType.GlyphType = 'Arrow'
01444     elif glyph_type == 'Cone':
01445         glyph.GlyphType.Resolution = 7
01446         glyph.GlyphType.Height = 2
01447         glyph.GlyphType.Radius = 0.2
01448 
01449     # Set glyph position if possible
01450     if glyph.GlyphType.GetProperty("Center"):
01451         if (glyph_pos == GlyphPos.TAIL):
01452             glyph.GlyphType.Center = [0.5, 0.0, 0.0]
01453         elif (glyph_pos == GlyphPos.HEAD):
01454             glyph.GlyphType.Center = [-0.5, 0.0, 0.0]
01455         elif (glyph_pos == GlyphPos.CENTER):
01456             glyph.GlyphType.Center = [0.0, 0.0, 0.0]
01457 
01458     if scale_factor is not None:
01459         glyph.SetScaleFactor = scale_factor
01460     else:
01461         def_scale = get_default_scale(PrsTypeEnum.DEFORMEDSHAPE,
01462                                       new_proxy, entity, field_name)
01463         glyph.SetScaleFactor = def_scale
01464 
01465     glyph.UpdatePipeline()
01466 
01467     # Get Vectors representation object
01468     vectors = pv.GetRepresentation(glyph)
01469 
01470     # Get lookup table
01471     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
01472 
01473     # Set field range if necessary
01474     data_range = get_data_range(proxy, entity,
01475                                 field_name, vector_mode)
01476     lookup_table.LockScalarRange = 1
01477     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
01478 
01479     # Set properties
01480     if (is_colored):
01481         vectors.ColorArrayName = 'GlyphVector'
01482     else:
01483         vectors.ColorArrayName = ''
01484     vectors.LookupTable = lookup_table
01485 
01486     vectors.LineWidth = 1.0
01487 
01488     # Set wireframe represenatation mode
01489     vectors.Representation = 'Wireframe'
01490 
01491     # Add scalar bar
01492     add_scalar_bar(field_name, nb_components,
01493                    vector_mode, lookup_table, time_value)
01494 
01495     return vectors
01496 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 52 of file presentations.py.

Definition at line 45 of file presentations.py.

Definition at line 46 of file presentations.py.

Definition at line 48 of file presentations.py.

Definition at line 47 of file presentations.py.