## Functions

boolvec * contour (const char *cntr_name="*")

boolvec * contour_add (REAL weight=50, const char *cntr_name="*")

boolvec * smooth_contour (const char *cntr_name="*", REAL penalty_factor=0)

boolvec * contour_leq (const char *cntr_name="*", REAL penalty_factor=0)

boolvec * contour_geq (const char *cntr_name="*", REAL penalty_factor=0)

## Function Documentation

 boolvec* surfit::contour ( const char * cntr_name = "*" )
Tcl syntax:
contour cntr_name
Description:
Using this rule the resulting surface approximates contour values.
Parameters
 cntr_name contour name
Math:
This command adds the following functional to the functional sequence:

where (i,j) - indices of the cells cross with contour, - contour mean value for the (i,j) cell.
 boolvec* surfit::contour_add ( REAL weight = 50, const char * cntr_name = "*" )
Tcl syntax:
Description:
This rule modifies a previous (modifiable) rule by adding the contour rule with some weight. Use this rule if you don't know contour values exactly. Using this rule the resulting surface approximates contour taking into account a previous (modifiable) rule.
Parameters
 weight informational weight for this rule cntr_name contour name
Math:
This command modifies previous functional by adding :

where - informational weight,

where (i,j) - indices of the cells cross with contour, - contour mean value for the (i,j) cell.
 boolvec* surfit::contour_geq ( const char * cntr_name = "*", REAL penalty_factor = 0 )
Tcl syntax:
contour_geq cntr_name penalty_factor
Description:
This rule adds the surface condition - "the resulting surface at contour should be greater than or equal to contour values".
Parameters
 cntr_name contour name penalty_factor parameter for penalty algorithm
Math:

where (i,j) - indices of the cells cross with contour, - contour mean value for the (i,j) cell
 boolvec* surfit::contour_leq ( const char * cntr_name = "*", REAL penalty_factor = 0 )
Tcl syntax:
contour_leq cntr_name penalty_factor
Description:
This rule adds the surface condition - "the resulting surface at contour should be lower than or equal to the contour values".
Parameters
 cntr_name contour name penalty_factor parameter for penalty algorithm
Math:

where (i,j) - indices of the cells cross with contour, - contour mean value for the (i,j) cell
 boolvec* surfit::smooth_contour ( const char * cntr_name = "*", REAL penalty_factor = 0 )
\par Tcl syntax:
smooth_contour \ref str "cntr_name" penalty_factor

\par Description:
This rule tells surfit that resulting surface should approximate contour Z-values.
The result of approximation is that resulting surface should be very similar to given contours.
The main difference with \ref contour gridding rule is that resulting surface is
more smooth near contours.

\param cntr_name \ref d_cntr "contour" \ref str "name"
\param penalty_factor parameter for \ref penalty

\par Math:

Problem: we need to approximate contours (or isolines with different values) by adjusting


cell values. Let consider Figure 1: solid straight lines show cells borders, dot lines connect cells centers (black squares), thick black curves shows contours projection to the XoY plane. Red points on the figure are intersections of curves and dot lines.

\image html matr_sect.gif


Consider the case then the contours cross one of the dot lines, i.e. contours lay between two cells centers (see Figure 2). On the figure and are cells centers coordinates (X or Y), and are adjustable values for those cells. Red circles are points where contours cross vertical plane (this plane comes through points and ). - are points coordinates (X or Y), - Z coordinates.

We are trying to approximate points with straight line. To do this we are going to find a minimum of the following functional:

where

To solve our problem we should write this functional for each pair of neighbour cells, if at least one of contours lays between them.

For more details see f_cntr_smooth.tex

surfit: gridding and contouring software.