The gts_surface_coarsen() function allows to reduce the number of edges (and of course faces and vertices) of a given surface. Each edge is collapsed according to an order described by a user-defined cost function. It is then replaced by a single vertex given by another user-defined function. Two sets of cost and replacement functions are provided with the library. The default uses the squared length of the segment as cost and replaces the segment with its midpoint.
The functions gts_volume_optimized_cost() and gts_volume_optimized_vertex() are an implementation of an algorithm proposed by Lindstrom and Turk called "memoryless simplification". This algorithm has been shown to be both computationally efficient and very accurate in terms of error between the simplified surface and the original one. It also preserves the volume enclosed by the surface both globally and locally.
Surface refinement is obtained by splitting the edges in two equal parts according to an order described by a user-defined cost function. The default is to use the squared length of the segments as cost.
The coarsening or refinement processes are stopped using a user-defined stop function. Two functions are provided stopping either when the cost of collapsing an edge is too large (gts_coarsen_stop_cost()) or when the number of edges is too small (gts_coarsen_stop_number()).
Refine surface using a midvertex insertion technique. All the
edges of surface are ordered according to cost_func. The edges
are then processed in order until stop_func returns TRUE. Each
edge is split in two and new edges and faces are created.
If cost_func is set to NULL, the edges are sorted according
to their length squared (the longest is on top).
The edges of surface are sorted according to cost_func to
create a priority heap (a GtsEHeap). The edges are extracted in
turn from the top of the heap and collapsed (i.e. the vertices are
replaced by the vertex returned by the coarsen_func function)
until the stop_func functions returns TRUE.
If cost_func is set to NULL, the edges are sorted according
to their length squared (the shortest is on top).
The parameters for the volume optimization algorithm of Lindstrom and Turk. THey define the relative weight of the volume, boundary and shape optimization part of the algorithm. Lindstrom and Turk advice is to set them to 0.5, 0.5 and 0. You may want to experiment depending on your problem. Setting shape_weight to a very small value (1e-10) for example might help improve the quality of the resulting triangulation.
a GtsVertex which can be used to replace edge for an
edge collapse operation. The position of the vertex is optimized in
order to minimize the changes in area and volume for the surface
using edge. The volume enclosed by the surface is locally
preserved. For more details see "Fast and memory efficient
polygonal simplification" (1998) and "Evaluation of memoryless
simplification" (1999) by Lindstrom and Turk.