There are two different data structures used by the traverse functions. One
structure is defined by the user and contains the element specific data. The
other is of the type HM2_GENERAL
and consists of pointers to objects
and data structures that usually are needed in the
action_on_element
-routine but are not element specific, e.g. a pointer
to the graphic device or the colorbar. The definition of this structure is
given below.
typedef struct hm2_general{ struct graphicdevice* dev; struct colorbar* colorbar; struct hmesh2d_lens* lens; F_HDATA2D* f_hdata2d; } HM2_GENERAL;Note that it is not compulsory to fill all entries of this structure. If for example the
action_on_element
-routine does not need the colorbar the
entry may be ignored by the user.
The user defined data structure with the element specific data may contain vertex coordinates, nodal function values or color values. The data structure used by the isoline display method for example employs all of the entries:
typedef struct hm2_coord_color_fct_data { VEC3 vertex_coord[MESH2D_MAX_VERTEX]; VEC3 vertex_color[MESH2D_MAX_VERTEX]; double vertex_value[MESH2D_MAX_VERTEX]; int in_lens_area; } HM2_COORD_COLOR_FCT_DATA;Memory for an array of these structure variables must be allocated. The length of this array is given by the maximal depth of the hierachical tree. As an example we have again printed part of the display method
hmesh2d-shrink-disp
.
HMESH2D* hmesh2d_shrink_disp(void) { ... HM2_GENERAL general; HM2_COORD_DATA** hm2_shrink_data; int i,max; /* get hmesh, graphic device, ... and initialize interactives */ ... /* prepare mesh-traverse */ max = hmesh->level_of_interest + 1; general.dev = dev; general.lens = lens; G_MEM_ALLOC(hm2_shrink_data,max); for(i=0;i<max;i++) G_MEM_ALLOC(hm2_shrink_data[i],1); /* traverse the mesh */ g_traverse_hmesh2d(hmesh, &general, G_LEAVES, hmesh->level_of_interest, hm2_coord_projection, hm2_geom_test_if_proceed, hm2_shrink_draw_element, (void**)hm2_shrink_data, NULL, hefVertex|hefVinh); /* free memory */ for(i=0;i<max;i++) G_MEM_FREE(hm2_shrink_data[i],1); G_MEM_FREE(hm2_shrink_data,max); END_METHOD(hmesh); }
The functions hm2_coord_projection
, hm2_geom_test_if_proceed
and
hm2_shrink_draw_element
must be defined somewhere else. The
GRAPE-library contains several projection and test-if-proceed routines that
can be reused and are explained in the next sections.
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.