Example a_backup/field_dependent_visibility: Field dependent visibility: Using field to determine the visibility of each node.

Using a boolean field to determine the visibility of each node/data point. This boolean field can be created at run time as shown below. This example requires cmgui 2.6.1 or greater.

Created May, 2009 by Alan Wu.

Screenshot of example a_backup/field_dependent_visibility


The comfile run by this example is as follows:

# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is CMISS Field Dependent Visibility example.
#
# The Initial Developer of the Original Code is
# Auckland Uniservices Ltd, Auckland, New Zealand.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****


#A short example to demostrate how to control the visiblity of node/data points 
#using field in cmgui.

#Read in the coordinate and the field containing information of
#the period of time which each node is visible at.
gfx read nodes $example/cube;
gfx read elements $example/cube;
gfx read nodes $example/line;

# create initial visualisation
gfx modify g_element "/" general clear;
gfx modify g_element cube lines coordinate coordinates material default;

#First define a field which contains the value of current time in 
#time keeper
gfx define field time_value time_value;
#Compare the current time value with the life time period specified in
#the visible_time field. The resultant visibility field will be 1 if 
#the current time is within the visible_time.
gfx define field greater greater_than field visible_time.end time_value;
gfx define field less less_than field visible_time.start time_value;
gfx define field equal equal_to field visible_time.start time_value;
gfx define field less_or_equal or field less equal;
gfx define field visibility and field less_or_equal greater;

#create a spectrum
gfx modify spectrum default clear overwrite_colour;
gfx modify spectrum default linear reverse range 1 8 extend_above extend_below rainbow colour_range 0 1 component 1;

#Create a set of node points for cube which visibility is controlled by the subgroup field (note command token changed from 'visibility' to 'subgroup').
gfx modify g_element "/" node_points glyph sphere general size "0.1*0.1*0.1" centre 0,0,0 font default subgroup visibility data cmiss_number select_on material default selected_material default_selected;
# Old command for cmgui 2.8:
#gfx modify g_element cube node_points glyph sphere general size "0.1*0.1*0.1" centre 0,0,0 font default visibility visibility data cmiss_number select_on material default selected_material default_selected;


#create a field which is used as the iso-scalar of an iso-surface
gfx define field coord.y composite coordinates.y;
gfx define field nine constant 9;
gfx define field mul multiply field coord.y nine;
gfx define field div divide field mul time_value;

gfx modify g_element cube iso_surfaces iso_scalar div iso_values 1 use_elements select_on material default data mul spectrum default selected_material default_selected render_shaded;

#create a visibility field which controls the visibility of node points in line group.
gfx define field line_multiply multiply field coordinates.y nine;
gfx define field line_visibility greater_than field time_value line_multiply;

#Create a set of node points for line which visibility is controlled by the line_visibility field.
gfx define field final_line_visibility and fields line.cmiss_nodes line_visibility;
gfx modify g_element line node_points glyph sheet general size "0.1*0.1*0.1" centre 0,0,0 font default subgroup final_line_visibility select_on material default data line_multiply spectrum default selected_material default_selected;
# Old command for cmgui 2.8:
#gfx modify g_element line node_points glyph sheet general size "0.1*0.1*0.1" centre 0,0,0 font default visibility line_visibility select_on material default data line_multiply spectrum default selected_material default_selected;

gfx cre win 1;
gfx modify window 1 view parallel eye_point 3.3986 -1.29312 1.43081 interest_point 0.5 0.5 0.5 up_vector -0.223722 0.139112 0.964674 view_angle 40 near_clipping_plane 0.0353321 far_clipping_plane 12.6265 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1;
gfx timekeeper default maximum 9;
if ($TESTING)
{
	gfx timekeeper default set_time 5;
	gfx export vrml file field_dependent_visibility.wrl scene default;
} else {
	gfx timekeeper default play;
}


Files used by this example are:

Name                                    Modified     Size

example_field_dependent_visibility.com 20-Apr-2012 5.3k COPYRIGHT 20-Apr-2012 504 cube.exelem 20-Apr-2012 4.9k cube.exnode 20-Apr-2012 592 line.exnode 20-Apr-2012 451

Download the entire example:

Name                                                 Modified     Size

examples_a_backup_field_dependent_visibility.tar.gz 12-Aug-2014 16k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxSuccessSun Mar 6 00:13:23 20162
cmgui-wx-debugSuccessSun Mar 6 00:11:00 20162
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:11:01 20163
cmgui-wx-debug-valgrindFailureSun Mar 6 00:56:32 201639
last breakSun Mar 6 00:55:00 201639
last successTue Feb 10 00:47:00 201539
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debugFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-valgrindFailureSun Mar 6 00:03:09 20169
last breakSun Mar 6 00:03:00 20169
last successWed Jun 3 00:27:00 201531

Testing status by file:


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

Input last modified: Fri Apr 20 15:59:08 2012


CMISS Help / Examples / a_backup / field_dependent_visibility