Example a_backup/ae: Element_glyphs, annotation, spectrum, colour_bar: element-based fields

Shows how to display element-based fields (grids) at native discretization with element_glyphs. Also demonstrates how to create a colour_bar to show a spectrum scale, and how to add annotation to your display.

Screenshot of example a_backup/ae


The comfile run by this example is as follows:

#Example_ae:
# Element_points, annotation, spectrum, colour_bar: element-based fields
#
# Previous examples have already shown how to use spectrums to map colours to
# field values. This example shows how to display a colour_bar showing the scale
# of values in the spectrum on the graphics window. Annotation - adding extra
# text to describe the image - is also explained.
#
# The example uses field 'grid2' that is "element-based". That means its field
# values are given at a regular array of points throughout the volume of each of
# its elements. The number of grid points may vary from element to element,
# requiring graphics objects to be drawn at the "native" discretization of that
# field in order to get an accurate image of the body. This example creates
# element_points at the native discretization of grid2, which show the value of
# the grid2 at the points they were originally given.
#
#----------
#
# Create some useful materials:
gfx cre mat copper ambient 1 0.2 0 diffuse 0.6 0.3 0 specular 0.7 0.7 0.5 shininess 0.3
gfx cre mat gold ambient 1 0.4 0 diffuse 1 0.7 0 specular 0.5 0.5 0.5 shininess 0.8
gfx create material silver ambient 0.4 0.4 0.4 diffuse 0.7 0.7 0.7 emission 0 0 0 specular 0.7 0.7 0.7 alpha 1 shininess 0.6
gfx create material red ambient 1 0 0 diffuse 1 0 0
gfx create material green ambient 0 1 0 diffuse 0 1 0
#
# Read in the grid_cube mesh, including the element-based field 'grid2'.
gfx read nodes example grid_cube.exnode
gfx read elements example grid_cube.exelem
#
# Create a window showing grid_cube in perspective.
gfx create window 1
gfx mod win 1 view perspective
#
# Create a spectrum to be later used to show the range of the 'grid2' field.
gfx cre spectrum grid2
#
# Create element_points throughout the single element. By specifying
# 'cell_corners' and 'native_discretization grid2', and 'data grid2' spheres are drawn at
# each of the grid points.
gfx modify g_element grid_cube element_points glyph sphere general size "1*1*1" centre 0,0,0 use_elements cell_corners discretization "1*1*1" native_discretization grid2 select_on material default data grid2 spectrum grid2 selected_material default_selected;
#
# Make sure spectrum 'grid2' shows the entire range of the grid2 field:
gfx mod spectrum grid2 autorange
#
# Create a colour_bar for spectrum 'grid2':
gfx create colour_bar spectrum grid2 material copper
#
# Note that by default the colour_bar will be created with an upright bar with
# ticks pointing to the right on the screen. It can be oriented in any direction
# by the axis # # # option of the above command, while the tick_direction # # #
# controls which side the labels are written on and the ticks leading to them.
# Note that you should keep these directions different. Other parameters to this
# command, listed by typing "gfx create colour_bar ??" should be largely
# self-explanatory.
#
# Draw the colour bar as an overlay graphic using fit_left coordinate_system
gfx modify g_element "/" point glyph colour_bar general size "1*1*1" centre 0,0,0 select_on material copper selected_material copper normalised_window_fit_left;
#
# Create some annotation describing the spectrum shown. Note that you can enter
# text containing special delimiter and comment characters by enclosing it in
# either single or double quotes. To include a quote character you must precede
# it by a backslash, ie. \" -> " and \' -> '.
# Consequently, you must also enter \\ to put a single backslash in the text.
#
gfx define field annotation string_constant "The \"grid2\" field!"
gfx modify g_element "/" point glyph empty general size "1*1*1" label annotation centre -0.95,0.9,0.0 select_on material default selected_material default normalised_window_fit_left;
gfx
#
#----------
#
# This example has introduced how to create scenes. Scenes are containers for
# 3-D graphics objects, and have several interesting uses. The default scene is
# the one usually used to draw your model. You can equally create another scene
# with a different name, and display it in a different graphics window, eg:
# gfx cre win 2
# gfx cre scene bob g_element
# gfx mod win 2 image scene bob
# Here, by specifying 'g_element', scene 'bob' is capable of holding graphical
# element groups, editable with the graphical element editor.
# Furthermore, you can draw one scene inside another scene to create a
# hierarchical scene graph, eg. to draw a new scene 'fred' in scene 'bob', try:
# gfx cre scene fred
# gfx draw child_scene fred scene bob
# (You can also erase child scenes and any other graphics object with the
# 'gfx erase' command.)

Files used by this example are:

Name              Modified     Size

example_ae.com 20-Apr-2012 4.5k COPYRIGHT 19-Apr-2012 504 grid_cube.exelem 20-Apr-2012 9.2k grid_cube.exnode 20-Apr-2012 2.1k

Download the entire example:

Name                         Modified     Size

examples_a_backup_ae.tar.gz 12-Aug-2014 77k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxSuccessSun Mar 6 00:13:18 20162
cmgui-wx-debugSuccessSun Mar 6 00:13:19 20163
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:10:01 20163
cmgui-wx-debug-valgrindFailureSun Mar 6 00:49:41 201633
last breakSun Mar 6 00:49:00 201633
last successTue Feb 10 00:40:00 201533
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:36 20161
last breakSun Mar 6 00:01:00 20161
last successWed Jun 3 00:04:00 20151
cmgui-wx-debugFailureSun Mar 6 00:01:36 20161
last breakSun Mar 6 00:01:00 20161
last successWed Jun 3 00:04:00 20150
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:36 20161
last breakSun Mar 6 00:01:00 20161
last successWed Jun 3 00:04:00 20151
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:33 20169
last breakSun Mar 6 00:02:00 20169
last successWed Jun 3 00:23:00 201526
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:13 20167

Testing status by file:


Html last generated: Sun Mar 6 05:50:51 2016

Input last modified: Fri Apr 20 15:56:06 2012


CMISS Help / Examples / a_backup / ae