Example a_backup/decimation: Decimation: Isosurface decimation and finite element creation

Shows how to create decimated isosurfaces and create finite element meshes from these isosurfaces. Decimation is where the original dense triangulation is simplified adaptively according to the curvature of the triangulation.

Screenshot of example a_backup/decimation


The comfile run by this example is as follows:

#Example a/decimation: Isosurface decimation and conversion of graphics objects to finite_elements.
#
#
#----------
gfx read node $example/cube8.exnode;
gfx read elem $example/cube8.exelem;

gfx define field sum sum field coordinates;
gfx define field sphere magnitude field coordinates;

# Create the isosurfaces and decimate them.
# The decimation threshold is a non dimensional number which determines the cost of collapse
# for an edge based on how far normal to the surface a potential vertex will move relative to the triangle size.
# Therefore 0.01 is quite a conservative value.

gfx modify g_element cube8 general clear circle_discretization 6 default_coordinate coordinates element_discretization "10*10*10" native_discretization none;
gfx modify g_element cube8 iso_surfaces iso_scalar sphere iso_values 2 use_elements select_on material default selected_material default_selected render_wireframe as isosphere1 decimation_threshold 0.01;
gfx modify g_element cube8 iso_surfaces iso_scalar sphere iso_values 2.5 use_elements select_on material default selected_material default_selected render_wireframe as isosphere2 decimation_threshold 0.01;
gfx modify g_element cube8 lines select_on material default selected_material default_selected;

# Generate a sin curve.

# The decimation algorithm is adaptive, so on this sin curve the edges collapse along the flat direction
# rather than along the curve direction.

gfx define field scaled_x scale field coordinates.x scale_factors 2;
gfx define field sin sin field scaled_x;
gfx define field bob add fields coordinates.z sin scale_factors -1 1;

gfx modify g_element cube8 iso_surfaces as sin iso_scalar bob iso_values 0 use_elements select_on material default selected_material default_selected render_wireframe decimation_threshold 0.01;

if (! defined $TESTING)
{
  gfx create win 1;
}

# Convert the first isosurface into a finite_element surface mesh.

# The conversion can work on a whole scene, "default", or on parts of it by specifying the 
# component required "default.cube8.1" refers to the default scene, the cube8 element_group
# in that scene and the 1st setting.  Alternatively to using the setting number 1, the setting
# name which was specified in the "as NAME" option above can be used: "default.cube8.isosphere1"
# Only visible parts of a scene will create elements so that the new mesh represents the visible
# scene.

gfx create egroup surface_mesh;
#gfx create region surface_mesh;
#gfx define field surface_mesh/coordinates coordinate_system rectangular_cartesian finite_element number_of_components 3 coordinate real component_names x y z;

# Command updated by fixcom.pl on Thu Apr 13 14:46:37 2006
# Old command: gfx convert scene default.cube8.1 region surface_mesh coordinate coordinates render_linear_product_elements;
gfx define graphics_filter isosphere1 match_graphic_name isosphere1;
gfx define scene isosphere1 filter isosphere1;
gfx convert graphics scene isosphere1 region surface_mesh coordinate coordinates render_linear_product_elements;
gfx define faces egroup surface_mesh;

#Display this new representation of the isosurface created above.

gfx modify g_element surface_mesh surfaces select_on material default selected_material default_selected render_shaded;

gfx write nodes group surface_mesh surface_mesh.exnode;
gfx write elements group surface_mesh surface_mesh.exelem;

# Convert the second isosurface into a cloud of nodes.

# Alternatively to creating a mesh, a cloud of nodes can be created.
# The data field of the iso_surface is used to control the density of points, the expected number
# of points in any surface patch is the area of that patch multiplied by the first component of the
# data field evaluated on that patch.

# A constant density field would probably be most usual
# gfx define field density constant 100;

# but here we will show a varying density based on the x coordinate scaled up so there are a reasonable number of points.
# Where the density field is negative no points are produced.

gfx define field density scale field coordinates.x scale_factor 100;

gfx modify g_element cube8 iso_surfaces iso_scalar sphere iso_values 2.5 use_elements select_on material default selected_material default_selected render_wireframe as isosphere2 decimation_threshold 0.01 data density;

gfx create egroup surface_cloud;
#gfx create region surface_cloud;
#gfx define field surface_cloud/coordinates coordinate_system rectangular_cartesian finite_element number_of_components 3 coordinate real component_names x y z;


# Command updated by fixcom.pl on Thu Apr 13 14:46:37 2006
# Old command: gfx convert scene default.cube8.isosphere2 region surface_cloud coordinate coordinates render_surface_node_cloud;
gfx define graphics_filter isosphere2 match_graphic_name isosphere2;
gfx define scene isosphere2 filter isosphere2;
gfx convert graphics scene isosphere2 region surface_cloud coordinate coordinates render_surface_node_cloud;


# Display this cloud of nodes.

gfx modify g_element surface_cloud node_points glyph point general size "1*1*1" centre 0,0,0 font default select_on material default selected_material default_selected;

# Write the node cloud to a file

gfx write nodes group surface_cloud surface_cloud.exnode;


Files used by this example are:

Name            Modified     Size

decimation.com 20-Apr-2012 5.1k COPYRIGHT 19-Apr-2012 504 cube8.exelem 20-Apr-2012 9.5k cube8.exnode 20-Apr-2012 816

Download the entire example:

Name                                 Modified     Size

examples_a_backup_decimation.tar.gz 12-Aug-2014 1.3M

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxSuccessSun Mar 6 00:13:22 20163
cmgui-wx-debugSuccessSun Mar 6 00:10:35 20162
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:15:16 20163
cmgui-wx-debug-valgrindFailureSun Mar 6 01:07:01 201644
last breakSun Mar 6 01:06:00 201644
last successTue Feb 10 00:55:00 201544
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:36 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20150
cmgui-wx-debugFailureSun Mar 6 00:01:36 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:36 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20152
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:37 201610
last breakSun Mar 6 00:02:00 201610
last successWed Jun 3 00:30:00 201534
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:15 20168

Testing status by file:


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

Input last modified: Fri Apr 20 15:57:05 2012


CMISS Help / Examples / a_backup / decimation