+def GaussPointsOnField1(proxy, entity, field_name,
+ timestamp_nb,
+ is_colored=True, color=None,
+ primitive=GaussType.SPHERE,
+ is_proportional=True,
+ max_pixel_size=256,
+ multiplier=None,
+ vector_mode='Magnitude'):
+ """Creates Gauss Points on the given field. Use GaussPoints() Paraview interface.
+
+ 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_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.
+
+ """
+ proxy.UpdatePipeline()
+ select_cells_with_data(proxy, on_gauss=[field_name])
+
+ nb_components = get_nb_components(proxy, entity, field_name)
+
+ # Get time value
+ time_value = get_time(proxy, timestamp_nb)
+
+ # Set timestamp
+ pvs.GetRenderView().ViewTime = time_value
+ proxy.UpdatePipeline(time=time_value)
+
+ # Create Gauss Points object
+ source = pvs.GaussPoints(proxy)
+ source.UpdatePipeline()
+
+ # Get Gauss Points representation object
+ gausspnt = pvs.GetRepresentation(source)
+
+ # Get lookup table
+ lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
+
+ # Set field range if necessary
+ data_range = get_data_range(proxy, entity,
+ field_name, vector_mode)
+ if hasattr(lookup_table,"LockDataRange"):
+ lookup_table.LockDataRange = 1
+ elif hasattr(lookup_table,"LockScalarRange"):
+ lookup_table.LockScalarRange = 1
+ else:
+ raise RuntimeError("Object %s has no 'LockDataRange' or 'LockScalarRange' attribute!"%(lookup_table))
+
+ lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
+
+ # Set display properties
+ if is_colored:
+ gausspnt.ColorArrayName = (EntityType.get_pvtype(entity), field_name)
+ else:
+ gausspnt.ColorArrayName = (None, '')
+ if color:
+ gausspnt.DiffuseColor = color
+
+ gausspnt.LookupTable = lookup_table
+
+ # Add scalar bar
+ add_scalar_bar(field_name, nb_components,
+ vector_mode, lookup_table, time_value)
+
+ # Set point sprite representation
+ gausspnt.Representation = 'Point Sprite'
+
+ # Point sprite settings
+ gausspnt.InterpolateScalarsBeforeMapping = 0
+ gausspnt.MaxPixelSize = max_pixel_size
+
+ # Render mode
+ gausspnt.RenderMode = GaussType.get_mode(primitive)
+
+ #if primitive == GaussType.SPRITE:
+ # Set texture
+ # TODO(MZN): replace with pvsimple high-level interface
+ # texture = sm.CreateProxy("textures", "SpriteTexture")
+ # alphamprop = texture.GetProperty("AlphaMethod")
+ # alphamprop.SetElement(0, 2) # Clamp
+ # alphatprop = texture.GetProperty("AlphaThreshold")
+ # alphatprop.SetElement(0, 63)
+ # maxprop = texture.GetProperty("Maximum")
+ # maxprop.SetElement(0, 255)
+ # texture.UpdateVTKObjects()
+
+ # gausspnt.Texture = texture
+ #gausspnt.Texture.AlphaMethod = 'Clamp'
+ #gausspnt.Texture.AlphaThreshold = 63
+ #gausspnt.Texture.Maximum= 255
+
+ # Proportional radius
+ gausspnt.RadiusUseScalarRange = 0
+ gausspnt.RadiusIsProportional = 0
+
+ if is_proportional:
+ mult = multiplier
+ if mult is None and data_range[1] != 0:
+ mult = abs(0.1 / data_range[1])
+
+ gausspnt.RadiusScalarRange = data_range
+ gausspnt.RadiusTransferFunctionEnabled = 1
+ gausspnt.RadiusMode = 'Scalar'
+ gausspnt.RadiusArray = ['POINTS', field_name]
+ if nb_components > 1:
+ v_comp = get_vector_component(vector_mode)
+ gausspnt.RadiusVectorComponent = v_comp
+ gausspnt.RadiusTransferFunctionMode = 'Table'
+ gausspnt.RadiusScalarRange = data_range
+ gausspnt.RadiusUseScalarRange = 1
+ if mult is not None:
+ gausspnt.RadiusIsProportional = 1
+ gausspnt.RadiusProportionalFactor = mult
+ else:
+ gausspnt.RadiusTransferFunctionEnabled = 0
+ gausspnt.RadiusMode = 'Constant'
+ gausspnt.RadiusArray = ['POINTS', 'Constant Radius']
+
+ return gausspnt