This example shows how to use cmgui to fit a curve through data points. The curve is then written out to an exnode file. This file can be used to generate a sequence of digitisation planes, one for each node.
Created by Peter Bier, September 2002.
# This examples fits a curve through user defined data points using snake # The curve created is then written out to use as a line of digitisation # for MRI data of the vocal tract during voicing of the vowel a sub create_curve { # Create new_curve from all selected data points # A density of 0 gives approximately equal element spacing # A stiffness must be set if you have more specified the curve to have more # elements than there are data points # Note you must select at least two data points to create a curve # Command updated by fixcom.pl on Thu Apr 13 15:10:47 2006 # Old command: gfx create snake coord coordinates dest new_curve num $num_elements density 0 stiffness 0.01 gfx create snake number_of_fitting_fields 1 fitting_fields coordinates coord coordinates dest new_curve number_of_elements $num_elements density 0 stiffness 0.01 gfx write node group new_curve curve.exnode } # For convenience store the number of elements to use along the curve # at the top of the file. # Note that there will be one more node than the number of elements specified # Each node is used to generate one digitisation plane so for 20 planes # we use 19 elements $num_elements = 19; # Load up one mri slice as a reference image. This image can then be used to # determine where to place the initial data points that the curve will be # fitted through. # Create a volume texture gfx create texture tract image dcm:$example/middle_slice.ima width 256 height 256 depth 0 distortion 0 0 0 colour 0 0 0 alpha 0 decal linear_filter resize_nearest_filter clamp_wrap; # Next create a material containing the texture so that we can display it on # an element gfx create material tract texture tract # Create some other useful materials to colour things gfx create material purple ambient 0 0 0 diffuse 0.55 0.35 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.5 gfx create material bluey ambient 0 0.25 0.5 diffuse 0 0.4 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.3 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 a plane to view the texture on gfx read nodes $example/middle_slice.exnode gfx read elements $example/middle_slice.exelem # Draw the texture on the plane gfx modify g_element middle_slice surfaces material tract texture_coordinates coordinates selected_material default_selected render_shaded; # Create a group to put the curve data points into gfx create dgroup new_curve # Create a field to represent the derivatives of the curve at each node gfx define field dx_ds1 coordinate_system rectangular_cartesian node_value fe_field coordinates d/ds1 version 1 if($TESTING) { # read in some data points to test fitting a curve gfx read data $example/test.exdata gfx select data 1..10 create_curve } else { # Create the window with a special view gfx create window 1 gfx modify window 1 view parallel eye_point 128 128 738.522 interest_point 128 128 0 up_vector 0 1 0 view_angle 31.391 near_clipping_plane 7.38522 far_clipping_plane 2639.22 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1; # Set the data_tool as the current tool in the window gfx modify win 1 set data_tool # Enable editing and creating of data by the data tool - with the new # coordinate field and group gfx data_tool edit define create coordinate_field coordinates group new_curve constrain_to_surface; # Make sure new_curve data is visible once created gfx modify g_element new_curve general clear circle_discretization 6 element_discretization "16*16*16" native_discretization none gfx modify g_element new_curve data_points glyph sphere general size "4*4*4" centre 0,0,0 label cmiss_number select_on material green selected_material default_selected gfx modify g_element new_curve node_points glyph sphere general size "4*4*4" centre 0,0,0 label cmiss_number select_on material default selected_material default_selected gfx modify g_element new_curve node_points glyph arrow_solid general size "0*2*2" centre 0,0,0 label cmiss_number orientation dx_ds1 scale_factors "0.5*0*0" select_on material default selected_material default_selected gfx modify g_element new_curve cylinder constant_radius 0.4 select_on material green selected_material default_selected } #Don't do these steps automatically but allow the user to double click them in the command window history. if (0) { # By default the curve will follow the data points in the same order that you # created them. If you want a different order then you will need to renumber them. # You can renumber your data points and sort them by any other field, i.e. to # sort them by the x coordinate. gfx change_id data_offset 1000 sort_by coordinates.x; # # Example instructions: # # Create your data points by clicking on the image. # # When finished select all data points (to do this double click on data # to bring up the data tool menu and deselect create - you can now select # multiple points by dragging a box around them) or type gfx select data all; # To fit a curve through the selected data points and then write the # curve to a file run the sub routine create_curve by typing create_curve; # at the cmgui command line }
Name Modified Size
snake.com 20-Apr-2012 5.1k COPYRIGHT 19-Apr-2012 504 middle_slice.exelem 20-Apr-2012 1.5k middle_slice.exnode 20-Apr-2012 358 middle_slice.ima 20-Apr-2012 134k test.exdata 20-Apr-2012 814
Name Modified Size
examples_a_backup_snake.tar.gz 12-Aug-2014 504k
Status | Tested | Real time (s) | |
i686-linux | |||
cmgui-wx | Success | Sun Mar 6 00:06:44 2016 | 1 |
cmgui-wx-debug | Success | Sun Mar 6 00:06:44 2016 | 0 |
cmgui-wx-debug-memorycheck | Success | Sun Mar 6 00:06:45 2016 | 1 |
cmgui-wx-debug-valgrind | Success | Sun Mar 6 00:30:11 2016 | 20 |
x86_64-linux | |||
cmgui-wx | Success | Thu Jan 7 00:01:30 2016 | 0 |
cmgui-wx-debug | Success | Thu Jan 7 00:01:30 2016 | 0 |
cmgui-wx-debug-memorycheck | Success | Thu Jan 7 00:01:30 2016 | 0 |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 00:03:44 2016 | 13 |
last break | Sun Mar 6 00:03:00 2016 | 13 | |
last success | Wed Jun 3 00:14:00 2015 | 14 | |
cmgui-wx-gcc-cad-debug-valgrind | Success | Thu Jan 7 00:04:08 2016 | 13 |
i686-linux | |||
Success | cmgui-wx: | diff test: no differences with linux answer. | |
Success | cmgui-wx-debug: | diff test: no differences with linux answer. | |
Success | cmgui-wx-debug-memorycheck: | diff test: no differences with linux answer. | |
Success | cmgui-wx-debug-valgrind: | diff test: no differences with linux answer. | |
x86_64-linux | |||
Success | cmgui-wx: | diff test: no differences with linux answer. | |
Success | cmgui-wx-debug: | diff test: no differences with linux answer. | |
Success | cmgui-wx-debug-memorycheck: | diff test: no differences with linux answer. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with linux answer; Test output. |
i686-linux | |||
Success | cmgui-wx: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-valgrind: | ndiff test: no significant differences with generic answer. | |
x86_64-linux | |||
Success | cmgui-wx: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-valgrind: | ndiff test: no significant differences with generic answer. |
Html last generated: Sun Mar 6 05:51:01 2016
Input last modified: Fri Apr 20 16:01:25 2012