Example 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/ae

The comfile run by this example is as follows:

# 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
# Old versions of cmgui automatically created lines; create manually now
gfx modify g_element grid_cube general clear;
gfx modify g_element grid_cube lines coordinate coordinates material default;
# Create a window showing grid_cube in perspective.
gfx create window 1
gfx modify window 1 view perspective
# Create a spectrum to be later used to show the range of the 'grid2' field.
gfx create 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!"
# Beware that the glyph centre option takes the negative of the coordinates
# where the annotation is shown. The scene editor shows the proper value.
gfx modify g_element "/" point glyph none 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;
# 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 17-Mar-2014 4.8k COPYRIGHT 17-Mar-2014 504 grid_cube.exelem 17-Mar-2014 9.2k grid_cube.exnode 17-Mar-2014 2.1k

Download the entire example:

Name                  Modified     Size

examples_a_ae.tar.gz 09-Mar-2016 76k

Testing status by version:

StatusTestedReal time (s)
cmgui-wxFailureSun Mar 6 00:10:46 20163
last breakTue Feb 24 00:02:00 20152
cmgui-wx-debugFailureSun Mar 6 00:10:14 20162
last breakTue Feb 24 00:02:00 20152
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:10:16 20162
last breakTue Feb 24 00:02:00 20153
cmgui-wx-debug-valgrindFailureSun Mar 6 00:52:32 201633
last breakSun Mar 6 00:51:00 201633
cmgui-wxFailureSun Mar 6 00:01:27 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debugFailureSun Mar 6 00:01:27 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:27 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:24 20169
last breakSun Mar 6 00:02:00 20169
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:23 20167

Testing status by file:

Html last generated: Wed Mar 9 16:01:18 2016

Input last modified: Wed Mar 9 15:49:42 2016

CMISS Help / Examples / a / ae