\subsection{leaf\_add\_mgen}\label{section-leaf-add-mgen}

\begin{verbatim}
m = leaf_add_mgen( m, mgen_name, ... )
   Add a new morphogen to m with the given name.  If there is already a
   morphogen with that name, this command is ignored.  Any number of names
   can be given at once.

   Equivalent GUI operation: the "New" button on the "Morphogens" panel.
   A dialog will appear in which the user chooses a name for the new
   morphogen.

   See also:
       LEAF_DELETE_MGEN, LEAF_RENAME_MGEN
\end{verbatim}

\subsection{leaf\_add\_userdata}\label{section-leaf-add-userdata}

\begin{verbatim}
m = leaf_add_userdata( m, ... )
   Add fields to the userdata of m.  The arguments should be alternately a
   field name and a field value.  Existing fields of those names in
   m.userdata will be left unchanged.

   See also: LEAF_SET_USERDATA, LEAF_DELETE_USERDATA.

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_addbioregion}\label{section-leaf-addbioregion}

\begin{verbatim}
m = leaf_addbioregion( m, cells )
   Add the specified finite element patches to the region within which
   biological cells will be simulated, or remove them if they are already
   included.  The patches are identified by their number, which is not
   easily ascertained by the user.  This command is primarily intended to
   be generated by the GUI when the user clicks to select a patch.
   Arguments:
   1: A list of the patches to add to the region.

   Equivalent GUI operation: clicking on the mesh when "3rd layer" is
   selected in the "Mouse mode" pull-down menu.
\end{verbatim}

\subsection{leaf\_addpicture}\label{section-leaf-addpicture}

\begin{verbatim}
m = leaf_addpicture( m, ... )
   Create a new picture window to plot the mesh in.  This is primarily
   intended for plotting the mesh in multiple windows simultaneously.

   Options:
       'figure'    A handle to a window.  The previous contents of the
                   window will be erased.
       'position'  An array [x y w h] specifying the position and size of the
                   window relative to the bottom left corner of the screen.
                   x is horizontal from the left, y is vertical from the
                   bottom, w is the width and h is the height, all in pixels.
       'relpos'    A similar array, but this time measured relative to the
                   bottom left corner of the previous picture, if there is
                   one, otherwise the bottom left corner of the screen.
       Only one of position or relpos may be supplied.
       w and h can be omitted from relpos, in which case the size defaults
       to the size of the existing window, if any, otherwise the default
       size for a new window.
       x and y can be omitted from position, in which case the new window
       is centred on the screen.
       If both position and relpos are omitted, a window of default size
       and position is created.
       'vergence'  A number in degrees, default 0.  The azimuth of the
                   figure is offset by this amount, so that the eye seeing
                   the figure sees it as if the eye was turned towards the
                   centre line by this angle.
       'eye'       'l' or 'r', to specify which eye this is for.
       If no eye is specified, vergence defaults to zero.  If
       vergence is specified, an eye must also be specified.
       'properties'   A structure containing any other attribute of the
                   figure that should be set.
\end{verbatim}

\subsection{leaf\_addseam}\label{section-leaf-addseam}

\begin{verbatim}
m = leaf_addseam( m, ... )
   Marks some edges of m as being or not being seams, according to
   criteria given in the options.  Unlike all other toolbox commands, the
   options to this command are processed sequentially and the same option
   may occur multiple times in the list.

   Options:
       'init'      Either 'all' or 'none'.  Sets either all of the edges,
                   or none of them, to be seam edges.
       'edges'     An array of edge indexes.  All of these edges will
                   become seam edges.
       'nonedges'  An array of edge indexes.  All of these edges will
                   become non-seam edges.
       'nodes'     An array of node indexes.  All edges joining two edges
                   in this set will become seam edges.
       'nonnodes'  An array of node indexes.  All edges touching any node
                   in this set will become non-seam edges.
       'morphogen' A cell array of two elements.  The first is a
                   morphogen name or index.  The second is a string
                   specifying how the value of the morphogen will be used
                   as a criterion for deciding whether an edge should
                   become a seam.  It consists of three parts.  It begins
                   with one of 'min', 'mid', or 'max'.  This is followed
                   by one of '<', '<=', '>=', or '>'.  This is followed by
                   a number.  Examples: 'min>0.5' means that an edge
                   becomes a seam if the minimum value of the morphogen at
                   either end is greater than 0.5.  'max' would take the
                   maximum of the ends, and 'mid' would take the average.
\end{verbatim}

\subsection{leaf\_allowmutant}\label{section-leaf-allowmutant}

\begin{verbatim}
m = leaf_allowmutant( m, enable )
   Enable or disable the whole mutation feature.

 Arguments:
   enable: 1 to allow mutation, 0 to disable mutation.
\end{verbatim}

\subsection{leaf\_alwaysflat}\label{section-leaf-alwaysflat}

\begin{verbatim}
m = leaf_alwaysflat( m, flat )
   If FLAT is 1, force the mesh to never bend out of the XY plane.  The
   mesh will be flattened if it is not already flat, by setting the Z
   coordinate of every node to zero.
   If FLAT is 0, allow the mesh to bend out of the XY plane.  If the mesh
   happens to be flat, it will not actually bend unless it is perturbed
   out of the XY plane, e.g. by adding a random Z displacement with the
   leaf_perturbz command.
   Example:
       m = leaf_alwaysflat( m, 1 );

   Equivalent GUI operation: clicking the "Always flat" checkbox on the
   "Mesh editor" panel.
\end{verbatim}

\subsection{leaf\_archive}\label{section-leaf-archive}

\begin{verbatim}
m = leaf_archive( m )
   Create an archive of the current state of the project.
   Archived states are kept in a subfolder ARCHIVE of the current project.
   Each archived state is in a project folder whose name is the name of
   the current project, with '_Ann' appended, where nn is a number 1
   greater than the maximum number that has already been used, or 1 for
   the first created archive.

   Arguments: none.

   Equivalent GUI operation: clicking the "Archive" button.

   INCOMPLETE -- DO NOT USE.
\end{verbatim}

\subsection{leaf\_attachpicture}\label{section-leaf-attachpicture}

\begin{verbatim}
m = leaf_attachpicture( varargin )
   NOT SUPPORTED.  INCOMPLETE.  NON-OPERATIONAL.
   Load a picture from a file.  Create a rectangular mesh of the same
   proportions.
   If no filename is given for the picture, a dialog will be opened to
   choose one.

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_bowlz}\label{section-leaf-bowlz}

\begin{verbatim}
m = leaf_bowlz( m, ... )
   Add a bowl-shaped perturbation to the z coordinate of every point of
   the finite element mesh.  The z displacement will be proportional to
   the square of the distance from the origin of coordinates.
   Arguments:
       A number, being the maximum displacement.  The displacement will be
       scaled so that the farthest point from the origin is displaced by
       this amount.  The default is 1.
   Examples:
       m = leaf_bowlz( m, 2 );

   Equivalent GUI operation: the "Bowl Z" button on the "Mesh editor"
   panel. The amount of bowl deformation is specified by the value in the
   upper of the two text boxes to the right of the button.
\end{verbatim}

\subsection{leaf\_circle}\label{section-leaf-circle}

\begin{verbatim}
m = leaf_circle( m, ... )
   Create a new circular mesh.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the circle.  Default 1.
       'rings'         The number of circular rings of triangles to divide
                       it into. Default 4.
       'circumpts'     The number of vertexes around the circumference.
                       The default is rings*6.  It must be at least 4, and
                       for best results should be at least rings*4.  As a
                       special case, if zero is specified, rings*6 is
                       chosen.
       'innerpts'      The number of vertexes around the innermost ring of
                       points. Default is max( floor(circum/nrings), 3 ).
       'dealign'       Dealign the vertexes on adjacent rings. Default
                       false.  Only applies when circumpts is nonzero.
       'hemisphere'    Create a hemisphere instead of a flat circle.  The
                       argument is the height of the hemisphere as a
                       proportion of the radius.  Default is 0, i.e. make
                       a flat circle.  It can be negative.

   Example:
       m = leaf_circle( [], 'radius', 2, 'rings', 4 );

   Equivalent GUI operation: selecting "Circle" or "Hemisphere" on the
   pulldown menu on the "Mesh editor" panel, and clicking the "Generate
   mesh" button.
\end{verbatim}

\subsection{leaf\_colourA}\label{section-leaf-colourA}

\begin{verbatim}
m = leaf_colourA( m )
   Assign colours to all the cells in the bio-A layer.  If there is no
   bio-A layer, the command is ignored.

   Optional arguments:
       colors:  The colour of the cells, as a pair of RGB values.  The
                first is for the unshocked state and the second for the
                shocked state.  If this is not specified, the command does
                nothing.
       colorvariation:  The amount of variation in the colour of the new
                cells. Each component of the colour value will be randomly
                chosen within this ratio of the value set by the 'color'
                argument.  That is, a value of 0.1 will set each component
                to between 0.9 and 1.1 times the corresponding component of
                the specified colour.  (The variation is actually done in
                HSV rather than RGB space, but the difference is slight.)
                The default is zero.
\end{verbatim}

\subsection{leaf\_cylinder}\label{section-leaf-cylinder}

\begin{verbatim}
m = leaf_cylinder( m, ... )
   Create a new surface, in the form of an open-ended cylinder whose axis
   is the Z axis, centred on the origin.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the cylinder.  Default 2.
       'height'        The height of the cylinder.  Default 2.
       'circumdivs'    The number of divisions around the cylinder.
                       Default 12.
       'heightdivs'    The number of divisions along the axis of the
                       cylinder.  Default 4.
   Example:
       m = leaf_cylinder( [], 'radius', 2, 'height', 2, 'circumdivs', 12,
                          'heightdivs', 4 );
   See also: LEAF_CIRCLE, LEAF_LUNE, LEAF_ONECELL,
   LEAF_RECTANGLE, LEAF_SEMICIRCLE.

   Equivalent GUI operation: selecting "Cylinder" on the pulldown menu on
   the "Mesh editor" panel, and clicking the "Generate mesh" button.  The
   radius, height, number of divisions around, and number of divisions
   vertically are given by the values of the text boxes named "radius",
   "y width", "x divs", and "y divs" respectively.
\end{verbatim}

\subsection{leaf\_delete\_mgen}\label{section-leaf-delete-mgen}

\begin{verbatim}
m = leaf_delete_mgen( m, mgen_name, ... )
   Delete from m the morphogen that has the given name.  If there is no
   such morphogen, or if the name is one of the reserved morphogen names,
   this command is ignored.  Any number of names can be given at once.

   Equivalent GUI operation: clicking the "Delete" button in the
   "Morphogens" panel, which deletes the currely selected morphogen.

   See also:
       LEAF_ADD_MGEN, LEAF_RENAME_MGEN
\end{verbatim}

\subsection{leaf\_delete\_userdata}\label{section-leaf-delete-userdata}

\begin{verbatim}
m = leaf_delete_userdata( m, ... )
   Delete specified fields from the userdata of m.  The arguments should
   be strings.  If no strings are given, all the user data is deleted.

   If a named field does not exist, it is ignored.

   See also: LEAF_SET_USERDATA, LEAF_ADD_USERDATA.

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_deletecells}\label{section-leaf-deletecells}

\begin{verbatim}
m = leaf_deletecells( m )
   Delete all the biological cells in the third layer.  The region within
   which biological  cells may be created is left unchanged.

   Example:
       m = leaf_deletecells( m );

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_deletepatch}\label{section-leaf-deletepatch}

\begin{verbatim}
m = leaf_deletepatch( m, cells )
   Delete the specified finite element patches from the leaf.
   Arguments:
   1: A list of the cells to add to the region.

   Equivalent GUI operation: clicking on the mesh when the "Delete canvas"
   item is selected in the "Mouse mode" pulldown menu.
\end{verbatim}

\subsection{leaf\_deletepatch\_from\_morphogen\_level}\label{section-leaf-deletepatch-from-morphogen-level}

\begin{verbatim}
    ind=find(wound>0.5);
    listcells=[];
    for i=1:size(m.tricellvxs,1)
        if length(intersect(m.tricellvxs(i,:),ind'))==3
            listcells(end+1)=i;
       end
    end
\end{verbatim}

\subsection{leaf\_deletesecondlayer}\label{section-leaf-deletesecondlayer}

\begin{verbatim}
m = leaf_deletesecondlayer( m )
   Delete the first biological layer.

   Equivalent GUI operation: clicking the "Delete all cells" button in the
   "Bio 1" panel.
\end{verbatim}

\subsection{leaf\_deletestages}\label{section-leaf-deletestages}

\begin{verbatim}
m = leaf_deletestages( m )
   Delete all the stage files for m, and optionally, the stage times.
   Deleted files are gone at once, not put in the wastebasket.

   Options:
   'times'     Boolean.  If true, also delete the stored stage times from
               the mesh.

   Equivalent GUI operation: the "Delete All Stages..." and "Delete Stages
   and Times" commands on the Stages menu.
\end{verbatim}

\subsection{leaf\_deletethirdlayer}\label{section-leaf-deletethirdlayer}

\begin{verbatim}
m = leaf_deletethirdlayer( m )
   Delete the second biological layer.

   Equivalent GUI operation: clicking the "Delete all cells" button in the
   "Bio 2" panel.
\end{verbatim}

\subsection{leaf\_destrain}\label{section-leaf-destrain}

\begin{verbatim}
m = leaf_destrain( m )
   Remove all residual strain from the mesh.

   Equivalent GUI operation: clicking the "De-strain" button on the
   "Simulation" panel.
\end{verbatim}

\subsection{leaf\_dissect}\label{section-leaf-dissect}

\begin{verbatim}
m = leaf_dissect( m )
   Cut m along all of its seam edges.

   Arguments and options: none.
\end{verbatim}

\begin{verbatim}
[m,ok] = leaf_dointeraction( m, enable )
   Execute the interaction function once, without doing any simulation
   steps.  This will happen even if the do_interaction property of the mesh
   is set to false, 
   If there is no interaction function, this has no effect.
   If there is an interaction function and it throws an exception, OK will
   be returned as FALSE.

   Arguments:
       enable: 1 if the interaction function should be enabled for all
       subsequent simulation steps, 0 if its state of enablement should be
       left unchanged (the default).  If the i.f. throws an error then it
       will be disabled for subsequent steps regardless of the setting of
       this argument.
\end{verbatim}

\begin{verbatim}
m = leaf_edit_interaction( m, ... )
   Open the interaction function in the Matlab editor.
   If there is no interaction function, create one.

   Options:
       'force'     If true, the interaction function will be opened even
                   if the model m is marked read-only.  If false (the
                   default) a warning will be given and the function not
                   opened.

   Extra results:
       ok is true if the function was opened, false if for any reason it
       was not.
\end{verbatim}

\subsection{leaf\_enablelegend}\label{section-leaf-enablelegend}

\begin{verbatim}
m = leaf_enablelegend( m, enable )
   Cause the legend to be drawn or not drawn.
   When not drawn, the graphic item that holds the legend text will be
   made invisible.

   Arguments:
       1.  A boolean specifying whether to draw the legend (default true).
\end{verbatim}

\subsection{leaf\_enablemutations}\label{section-leaf-enablemutations}

\begin{verbatim}
m = leaf_enablemutations( m, enable )
   Enable or disable mutations.

   Arguments:
   enable:  True to enable all mutations, false to disable them.

   Examples:
       m = leaf_enablemutant( m, 0 );
           % Disable all mutations, i.e. revert to wild-type.
\end{verbatim}

\subsection{leaf\_explode}\label{section-leaf-explode}

\begin{verbatim}
m = leaf_explode( m, amount )
   Separate the connected components of m.

   Arguments:
       amount: Each component of m is moved so as to increase the distance
       of its centroid from the centroid of m by a relative amount AMOUNT.
       Thus AMOUNT==0 gives no movement and AMOUNT < 0 will draw the
       pieces inwards.
\end{verbatim}

\subsection{leaf\_fix\_mgen}\label{section-leaf-fix-mgen}

\begin{verbatim}
m = leaf_fix_mgen( m, morphogen, ... )
   Make the current value of a specified morphogen at a specified vertex
   or set of vertexes be fixed or changeable.

   Arguments:
   1: The name or index of a morphogen.

   Options:
       'vertex'  Indexes of the vertexes.  The default is the empty list
                 (i.e. do nothing).
       'fix'     1 or true if the value is to be made fixed, 0 or false if
                 it is to be made changeable.  The default is true.

   Equivalent GUI operation: control-clicking or right-clicking on the
   canvas when the Morphogens panel is selected.
\end{verbatim}

\subsection{leaf\_fix\_vertex}\label{section-leaf-fix-vertex}

\begin{verbatim}
m = leaf_fix_vertex( m, ... )
   Constrain vertexes of the mesh so that they are only free to move along
   certain axes.

   Options:
       'vertex'    The vertexes to be constrained.  If the empty list is
                   supplied, the constraint is applied to all vertexes.
       'dfs'       The degrees of freedom to be constrained.  This is a
                   string made of the letters 'x', 'y', and 'z'.  This
                   defaults to 'xyz', i.e. fix the vertexes completely.
   Each degree of freedom not in dfs will be made unconstrained for all of
   the given vertexes. Vertexes not in the list of vertexes will have
   their constraints left unchanged.

   It is only possible to constrain vertexes in directions parallel to the
   axes.

   Equivalent GUI operation: clicking on the mesh while the Mesh editor
   panel is selected and 'Fix' is selected in the Fix/Delete menu.  The
   'x', 'y', and 'z' checkboxes specify which degrees of freedom to
   constrain or unconstrain.
\end{verbatim}

\subsection{leaf\_flatstrain}\label{section-leaf-flatstrain}

\begin{verbatim}
m = leaf_flatstrain( m )
   Set the residual strains in the mesh to what they would be if the whole
   mesh were flat.

   Arguments: none.

   Options: none.

   Equivalent GUI operation: clicking the "Flat strain" button in the
   "Simulation" panel.
\end{verbatim}

\begin{verbatim}
[m,ok] = leaf_flatten( m )
   Flatten each of the connected components of m.

   Options:
       interactive: If true (default is false), then the flattening will
                    be carried out interactively.  The user can skip the
                    flattening of components that appear not to be well
                    flattenable, or cancel the whole operation.
\end{verbatim}

\subsection{leaf\_flattenX}\label{section-leaf-flattenX}

\begin{verbatim}
m = leaf_flatten( m )
   Flatten each of the connected components of m.

   Options:
       ratio: This is the proportion of the flattening displacements to
              apply.  The default value is 1, i.e. complete flattening.
\end{verbatim}

\subsection{leaf\_fliporientation}\label{section-leaf-fliporientation}

\begin{verbatim}
m = leaf_fliporientation( m )
   Interchange the two surfaces of the mesh.
\end{verbatim}

\subsection{leaf\_gyrate}\label{section-leaf-gyrate}

\begin{verbatim}
m = leaf_gyrate( m, ... )
   Spin and/or tilt the mesh about the Z axis, leaving it at the end in
   exactly the  same orientation as when it started.  If a movie is currently being
   recorded, the animation will be appended to the movie.  The current view
   is assumed to have already been written to the movie.

   Options:
       'frames':  The number of frames to be added.  Default 32.
       'spin':    The number of complete rotations about the Z axis.
                  Default 1.
       'tilt':    The number of cycles of tilting up, down, and back to
                  the initial elevation.  Default 1.
       'tiltangle':    The angle to tilt up and down to, in degrees from
                       the horizontal.  Default 89.99.
\end{verbatim}

\subsection{leaf\_hemisphere}\label{section-leaf-hemisphere}

\begin{verbatim}
m = leaf_hemisphere( m, ... )
   Create a new hemispherical mesh.  The mesh is oriented so that the cell
   normals point outwards.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the hemisphere.  Default 1.
       'divisions'     The number of divisions around the circumference.
                       Default 20.
       'rings'         The number of circular rings of triangles to divide
                       it into.  Default is floor(divisions/6).
   Example:
       m = leaf_hemisphere( [], 'radius', 2, 'divisions', 15, 'rings', 3 );

   Equivalent GUI operation: selecting "Hemisphere" on the pulldown menu on
   the "Mesh editor" panel, and clicking the "Generate mesh" button.  The
   radius and the number of rings are specified in the text boxes with
   those labels.
\end{verbatim}

\subsection{leaf\_icosahedron}\label{section-leaf-icosahedron}

\begin{verbatim}
m = leaf_icosahedron( m, ... )
   Create a new icosahedral mesh.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the icosahedron.  Default 1.

   Example:
       m = leaf_circle( [], 'radius', 2, 'rings', 4 );

   Equivalent GUI operation: selecting "Circle" or "Hemisphere" on the
   pulldown menu on the "Mesh editor" panel, and clicking the "Generate
   mesh" button.
\end{verbatim}

\begin{verbatim}
[m,ok] = leaf_iterate( m, numsteps, ... )
   Run the given number of iterations of the growth process.
   In each iteration, the following things happen:
       * Strains are set up in the leaf according to the effects of the
         morphogens at each point causing the material to grow.
       * The elasticity problem is solved to produce a new shape for the
         leaf.
       * Morphogens which have a nonzero diffusion coefficient are allowed 
         to diffuse through the mesh.
       * If dilution by growth is enabled, the amount of every morphogen
         is diluted at each point according to how much that part of the
         leaf grew.
       * A user-supplied routine is invoked to model local interactions
         between the morphogens.
       * The layer of biological cells is updated.
       * If requested by the options, the mesh is plotted after each
         iteration.

   Results:
   ok: True if there was no problem (e.g. invalid arguments, a user
   interrupt, or an error in the interaction function).  False if there
   was.

   Arguments:
   1: The number of iterations to perform.  If this is zero, the
   computation will continue indefinitely or until terminated by the
   'until' or 'targetarea' options.

   Options:
   'until'       Run the simulation until this time has been reached or
                 exceeded.  A value of zero disables this option.
   'targetarea'  Run the simulation until the area of the canvas is at
                 least this number times the initial area.  A value of
                 zero disables this option.
   'plot'  An integer n.  The mesh will be plotted after every n
           iterations.  0 means do not plot the mesh at all; -1 means plot
           the mesh only after all the iterations have been completed.
           The default value is 1.
   Example:
       m = leaf_iterate( m, 20, 'plot', 4 );

   Equivalent GUI operation: clicking one of the following buttons in the
   "Simulation" panel: "Run" (do a specified number of steps), "Step" (do
   one step), or "Run to..." (run until the area has increased by a
   specified factor).
\end{verbatim}

\subsection{leaf\_load}\label{section-leaf-load}

\begin{verbatim}
m = leaf_load( m, filename, ... )
   Load a leaf from a file.  If no filename is given, a dialog will be
   opened to choose one.
   The expected format depends on the extension of the filename:
       .MAT    The leaf is contained in the file as a Matlab object called
               m.
       .M      The file contains Matlab commands to create or modify a
               leaf.  These commands will be executed.
       .OBJ    Contains only nodes and triangles, in OBJ format.  All
               other properties of the mesh will be set to their default
               values.
   If no filename is given, a dialog will be opened to choose one.
   If the filename consists of just an extension (including the initial
   "."), a dialog will be opened showing only files with that extension.

   All of these formats can be generated by leaf_save.
   In the case of .MAT and .OBJ files, the existing leaf will be
   discarded.  A .M file will discard the current leaf only if it contains
   a command to create a new leaf; otherwise, it will apply its commands
   to the current leaf.

   Equivalent GUI operation: the "Load..." button.
\end{verbatim}

\subsection{leaf\_loadgrowth}\label{section-leaf-loadgrowth}

\begin{verbatim}
m = leaf_loadgrowth( m, filename )
   Load growth data for the leaf from an OBJ or MAT file.  If no filename
   is given, one will be asked for.

   This assumes the mesh is in growth/anisotropy mode.

   Equivalent GUI operation: the "Load Growth..." button on the
   "Morphogens" panel.
\end{verbatim}

\begin{verbatim}
[m,ok] = leaf_loadmodel( m, modelname, projectdir, ... )
   Load a model.  If no model name is given or the model name is empty, a
   dialog will be opened to choose one.  The model will be looked for in
   projectdir, if given, otherwise the project directory of m, if any,
   otherwise the current directory.  The argument m can be empty; in fact,
   this will be the usual case.

   If the model is successfully loaded, the new model is returned in M and
   the (optional) return value OK is set to TRUE.  Otherwise M is left
   unchanged and OK is set to FALSE.

   Options:
       rewrite:  Normally, when a model is loaded, its interaction
                 function (if there is one) is read, parsed, and
                 rewritten.  This is because it may have been created with
                 an older version of GFtbox.  Specifying the rewrite
                 option as false prevents this from being done.  This may
                 be necessary when running several simulations
                 concurrently on a parallel machine, all using the same
                 project.  Note that when rewrite is true (the default),
                 the interaction function will not actually be rewritten
                 until the first time it is called, or any morphogen is
                 added, deleted, or renamed.
       copyname, copydir:
                 If either of these is given, a new copy of the project
                 will be made and saved with the specified project name
                 and parent folder.  The original project folder will be
                 unmodified.  If one of these options is given, the other
                 can be omitted or set to the empty string, in which
                 case it defaults to the original project name or project
                 folder respectively.  If the value of copyname is '?',
                 then the user will be prompted to select or create a
                 project folder.  In this case, copydir will be the folder
                 at which the select-folder dialog starts.  If both
                 options are empty, this is equivalent to omitting both of
                 them (the default).  If copydir and copyname are the same
                 as modelname and projectdir, a warning will be given, and
                 the copy options ignored.

   If for any reason the model cannot be saved, a warning will be output,
   the loaded model will be discarded, and the empty list returned.

   Equivalent GUI operation: the "Load model..." button, or the items on
   the Projects menu.  The items on the Motifs menu use copyname and
   copydir to force the "motif" projects to be opened as copies in the
   user's default project directory.

   Examples:
       m = leaf_loadmodel( [], 'flower7', 'C:\MyProjects\flowers', ...
                           'copyname', 'flower8', ...
                           'copydir', 'C:\MyProjects\flowers' );
       This loads a model from the folder 'C:\MyProjects\flowers\flower7',
       and saves it into a new project folder 'C:\MyProjects\flowers\flower8'.
       Since the value of copydir is the same as the projectdir argument,
       the copydir option could have been omitted.
\end{verbatim}

\subsection{leaf\_lobes}\label{section-leaf-lobes}

\begin{verbatim}
m = leaf_lobes( m, ... )
   Create a new mesh in the form of one or more lobes joined together in a
   row.  A lobe is a semicircle on top of a rectangle.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the semicircle.  Default 1.
       'rings'         The number of circular rings of triangles to divide
                       it into. Default 4.
       'height'        The height of the rectangle, as a multiple of the
                       semicircle's diameter.  Default 0.7.
       'strips'        The number of strips of triangles to divide the
                       rectangular part into.  If 0 (the default), this will
                       be calculated from the height so as to make the
                       triangles similar in size to those in the lobes.
       'lobes'         The number of lobes.  The default is 1.
       'base'          Half the number of divisions along the base of a
                       lobe.  Defaults to rings.
       'cylinder'      The series of lobes is to behave as if wrapped
                       round a cylinder and the two ends stitched
                       together.  This is implemented by constraining the
                       nodes on the outer edges in such a way that the
                       outer edges remain parallel to the y axis.

   Example:
       m = leaf_lobes( 'radius', 2, 'rings', 4, 'lobes', 3, 'base', 2 );
   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_LUNE, LEAF_ONECELL,
   LEAF_RECTANGLE.

   Equivalent GUI operation: selecting "Lobes" in the pulldown menu in the
   "Mesh editor" panel and clicking the "Generate mesh" button.
\end{verbatim}

\subsection{leaf\_locate\_vertex}\label{section-leaf-locate-vertex}

\begin{verbatim}
m = leaf_locate_vertex( m, ... )
   Ensure that certain degrees of freedom of a single node remain
   constant.  This is ensured by translating the mesh so as to restore the
   values of the specified coordinates, after each iteration.

   Options:
       'vertex'    The vertex to be held stationary.  If the empty list is
                   supplied, no vertex will be fixed and dfs is ignored.
       'dfs'       The degrees of freedom to be held stationary.  This is a
                   string made of the letters 'x', 'y', and 'z'.  This
                   defaults to 'xyz', i.e. fix the vertex completely.
   Each degree of freedom not in dfs will be unconstrained.

   It is only possible to fix a vertex in directions parallel to the
   axes.

   Equivalent GUI operation: clicking on the mesh while the Mesh editor
   panel is selected and 'Locate' is selected in the Fix/Delete menu.  The
   'x', 'y', and 'z' checkboxes specify which degrees of freedom to
   constrain or unconstrain.
\end{verbatim}

\subsection{leaf\_lune}\label{section-leaf-lune}

\begin{verbatim}
m = leaf_lune( m, ... )
   NOT IMPLEMENTED.
   Create a new mesh in the shape of a stereotypical leaf, oval with
   pointed ends.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'xwidth'        The diameter in the X dimension.  Default 3.
       'ywidth'        The diameter in the Y dimension.  Default 2.
       'xdivs'         The number of segments to divide it into along the
                       X axis.  Default 8.
   Example:
       m = leaf_lune( [], 'xwidth', 3, 'ywidth', 2, 'xdivs', 8 );

   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_ONECELL,
   LEAF_RECTANGLE, LEAF_SEMICIRCLE, LEAF_LOBES.

   Equivalent GUI operation: selecting "Leaf" in the pulldown menu in the
   "Mesh editor" panel and clicking the "Generate mesh" button.
\end{verbatim}

\subsection{leaf\_makecells}\label{section-leaf-makecells}

\begin{verbatim}
m = leaf_makecells( m, numcells, numcvt )
   Create a layer of biological cells.  If there is already a biological
       layer, it is discarded.
   Arguments:
   1: The total number of biological cells to create.
   2: The number of iterations of the CVT transformation to apply
      to the cells.  The more iterations, the more nearly the
      cells will be of equal sizes, and with walls tending to
      meet at 120 degrees.  The default is 10.
   Examples:
       m = leaf_makecells( m, 100 );

   Equivalent GUI operation: clicking the "Make cells" button.
\end{verbatim}

\subsection{leaf\_makesecondlayer}\label{section-leaf-makesecondlayer}

\begin{verbatim}
m = leaf_makesecondlayer( m, ... )
   Make a new Bio-A layer, either adding to or discarding any existing one.

   Options:
       mode:   One of the following strings:
           'full': cover the entire surface with a continuous sheet of
               cells.  There will be one cell per FE cell plus one cell
               per FE vertex.
           'grid': cover the entire surface with a continuous sheet of
               square cells.
           'voronoi': cover the entire surface with a continuous sheet of
               cells.  The 'numcells' option specifies how many.  This is
               only valid for flat or nearly flat meshes.
           'single': make a single second layer cell in a random position.
           'few': make a specified number of second layer cells, each in a
               different randomly chosen FEM cell.
           'each': make one second layer cell within each FEM cell.
       abssize:   Not valid for mode=full.  In all other cases, this is a real
               number, being the diameter of a single cell.
       relsize:   Not valid for mode=full.  In all other cases, this is a real
               number, being the diameter of a single cell as a proportion
               of the average diameter of the current mesh.
       relinitarea:   Not valid for mode=full.  In all other cases, this is a real
               number, being the area of a single cell as a proportion
               of the initial area of the mesh.
       relFEsize:   Not valid for mode=full.  In all other cases, this is a real
               number, being the diameter of a single cell as a proportion
               of the average diameter of a typical FE cell in the current mesh.
       numcells:    Valid only for mode='voronoi' or mode='few'.  Am integer
               specifying the number of cells to create.
       fraccells:   Valid only for mode='each'.  A real number between 0
               and 1, it specifies the proportion of FEs that should
               have a bio cell placed in them.
       add:    Boolean.  If true, existing cells are retained and new
               cells are added to them.  If false, any existing biological
               layer is discarded.  If 'mode' is 'full' or 'voronoi', the
               old layer is always discarded, ignoring the 'add' argument.
       colors:  The colour of the new cells, as an RGB value.
       colorvariation:  The amount of variation in the colour of the new
               cells. Each component of the colour value will be randomly
               chosen within this ratio of the value set by the 'color'
               argument.  That is, a value of 0.1 will set each component
               to between 0.9 and 1.1 times the corresponding component of
               the specified colour.  (The variation is actually done in
               HSV rather than RGB space, but the difference is slight.)
       probperFE:  For 'each' mode, a probability for each FE that a cell
               will be created there.  Any value less than 0 is equivalent
               to 0, and any value greater than 1 is equivalent to 1.
       probpervx:  Like probperFE, but the values are given per vertex.
               Alternatively, the value can be a morphogen name or index,
               in which case the values of that morphogen at each vertex
               will be used.
       The options 'fraccells', 'probperFE', and 'probpervx' are mutually
       exclusive.  If 'probperFE' or 'probpervx' is given, the
       probabilities will also be weighted by the areas of the finite
       elements.  Thus a uniform probability field will give a uniform
       density of biological cells, regardless of the sizes of the finite
       elements.

   At most one of ABSSIZE, RELSIZE, RELINITAREA, and RELFESIZE should be given.

   Equivalent GUI operation: clicking the "Make cells" button on the Bio-A
   panel.  This is equivalent to m = leaf_makesecondlayer(m,'mode','full').
\end{verbatim}

\subsection{leaf\_mgen\_absorption}\label{section-leaf-mgen-absorption}

\begin{verbatim}
m = leaf_mgen_absorption( m, morphogen, absorption )
   Set the rate at which a specified morphogen is absorbed.
   Arguments:
   1: The name or index of a morphogen.
   2: The rate of absorption of the morphogen.  A value of 1 means that
      the morphogens decays by 1% every 0.01 seconds.
   Examples:
       m = leaf_mgen_absorption( m, 'growth', 0.5 );

   Equivalent GUI operation: setting the value in the "Absorption"
   text box in the "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_mgen\_conductivity}\label{section-leaf-mgen-conductivity}

\begin{verbatim}
m = leaf_mgen_conductivity( m, morphogen, conductivity )
   Set the rate at which a specified morphogen diffuses through the leaf.
   Arguments:
   1: The name or index of a morphogen.
   2: The conductivity of the surface to the morphogen.  This is in
   dimensionless units: try a value of 1.
   Examples:
       m = leaf_mgen_conductivity( m, 'growth', 0.5 );

   Equivalent GUI operation: setting the value in the "Diffusion"
   text box in the "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_mgen\_const}\label{section-leaf-mgen-const}

\begin{verbatim}
m = leaf_mgen_const( m, morphogen, amount )
   Add a constant amount to the value of a specified morphogen everywhere.
   Arguments:
   1: The name or index of a morphogen.  Currently, if
      the name is provided, it must be one of the following:
          'growth', 'polariser', 'anisotropy',
          'bend', 'bendpolariser', 'bendanisotropy'.
      These are respectively equivalent to the indexes 1 to 6 (which
      are the only valid indexes).  There is no default for this option.
   2: The amount of morphogen to add to every node.  A value
      of 1 will give moderate growth or bend, and a maximum growth or
      bend anisotropy.  A constant field of growth or bend polarizer
      has no effect: polarising morphogen has an effect only through
      its gradient.
   Examples:
       m = leaf_mgen_const( m, 'growth', 1 );
       m = leaf_mgen_const( m, 3, 0.8 );
   See also: LEAF_MGEN_RADIAL.

   Equivalent GUI operation: clicking the "Add const" button in the
   "Morphogens" panel.  The amount is specified by the "Amount slider and
   test item.
\end{verbatim}

\subsection{leaf\_mgen\_dilution}\label{section-leaf-mgen-dilution}

\begin{verbatim}
m = leaf_mgen_dilution( m, morphogen, enable )
   Set the rate at which a specified morphogen is absorbed.
   Arguments:
   1: The name or index of a morphogen.
   2: A boolean specifying whether to enable dilution by growth
   Examples:
       m = leaf_mgen_dilution( m, 'growth', 1 );

   Equivalent GUI operation: setting the "Dilution" checkbox in the
   "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_mgen\_edge}\label{section-leaf-mgen-edge}

\begin{verbatim}
m = leaf_mgen_edge( m, morphogen, amount, ... )
   Set the value of a specified morphogen to a given amount everywhere on
   the edge of the leaf.
   Arguments:
   1: The name or index of a morphogen.
   2: The maximum amount of morphogen to add to every node.
   Examples:
       m = leaf_mgen_edge( m, 'growth', 1 );
   See also: leaf_mgen_const.

   Equivalent GUI operation: clicking the "Add edge" button in the
   "Morphogens" panel.  The amount is specified by the "Amount slider and
   test item.
\end{verbatim}

\subsection{leaf\_mgen\_linear}\label{section-leaf-mgen-linear}

\begin{verbatim}
m = leaf_mgen_linear( m, morphogen, amount, ... )
   Set the value of a specified morphogen to a linear gradient.
   Arguments:
   1: The name or index of a morphogen.
   2: The maximum amount of morphogen to add to every node.
   Options:
       'direction'     Either a single number (the angle in degrees
                       between  the gradient vector and the X axis, the
                       gradient vector lying in the XY plane; or a triple
                       of numbers, being a vector in the direction of the
                       gradient.  The length of the vector does not
                       matter.  Default is a gradient parallel to the
                       positive X axis. 
   Examples:
       m = leaf_mgen_linear( m, 'growth', 1, 'direction', 0 );
   See also: leaf_mgen_const.

   Equivalent GUI operation: clicking the "Add linear" button in the
   "Morphogens" panel.  The amount is specified by the "Amount slider and
   test item.  Direction is specified in degrees by the "Direction" text
   box.
\end{verbatim}

\subsection{leaf\_mgen\_modulate}\label{section-leaf-mgen-modulate}

\begin{verbatim}
m = leaf_mgen_modulate( m, ... )
   Set the switch and mutant levels of a morphogen.

   Options:
   morphogen:   The name or index of a morphogen.  If omitted, the
                properties are set for every morphogen.
   switch, mutant:  Value by which the morphogen is multiplied to give its
                effective level.

   If either switch or mutant is omitted its current value is
   left unchanged. 

   The effective value of a morphogen is the product of the actual
   morphogen amount, the switch value, and the mutant value.  So
   mutant and switch have the same effect; the difference is
   primarily in how they are intended to be used.  Mutant value is
   settable in the Morphopgens panel of the GUI and is intended to have a
   constant value for each morphogen throughout a run.  There is also a
   checkbox in the GUI to turn all mutations on and off.  Switch value has
   no GUI interface, and is intended to be changed in the interaction
   function.  The switch values are always effective.

   The initial values for switch and mutant in a newly created leaf are 1.

   Examples:
       m = leaf_mgen_modulate( m, 'morphogen', 'div', ...
                                  'switch', 0.2, ...
                                  'mutant', 0.5 );
       Sets the switch level of 'div' morphogen to 0.2 and the mutant
       level to 0.5.  The effective level will then be 0.1 times the
       actual morphogen.
\end{verbatim}

\subsection{leaf\_mgen\_radial}\label{section-leaf-mgen-radial}

\begin{verbatim}
m = leaf_mgen_radial( m, morphogen, amount, ... )
   Add to the value of a specified morphogen an amount depending on the
   distance from an origin point.
   Arguments:
   1: The name or index of a morphogen.
   2: The maximum amount of morphogen to add to every node.
   Options:
       'x', 'y', 'z'   The X, Y, and Z coordinates of the centre of the
                       distribution, relative to the centre of the mesh.
                       Default is (0,0,0).
   Examples:
       m = leaf_mgen_radial( m, 'growth', 1, 'x', 0, 'y', 0, 'z', 0 );
       m = leaf_mgen_radial( m, 'g_anisotropy', 0.8 );
   See also: leaf_mgen_const.

   Equivalent GUI operation: clicking the "Add radial" button in the
   "Morphogens" panel.  The amount is specified by the "Amount slider and
   test item.  x, y, and z are specified in the text boxes of those names.
\end{verbatim}

\subsection{leaf\_mgen\_random}\label{section-leaf-mgen-random}

\begin{verbatim}
m = leaf_mgen_random( m, morphogen, amount, ... )
   Add a random amount of a specified morphogen at each mesh point.
   Arguments:
   1: The name or index of a morphogen.
   2: The maximum amount of morphogen to add to every node.
   Options:
       'smooth'        An integer specifying the smoothness of the
                       distribution.  0 means no smoothing: the value at
                       each node is independent of each of its neighbours.
                       Greater values imply more smoothness.  Default is
                       2.
   Examples:
       m = leaf_mgen_random( m, 'growth', 1 );
       m = leaf_mgen_random( m, 'g_anisotropy', 0.8 );
   See also: LEAF_MGEN_CONST.

   Equivalent GUI operation: clicking the "Add random" button in the
   "Morphogens" panel.  The amount is specified by the "Amount slider and
   test item.
\end{verbatim}

\subsection{leaf\_mgen\_reset}\label{section-leaf-mgen-reset}

\begin{verbatim}
m = leaf_mgen_reset( m )
   Set the value of all morphogens and all conductivities to zero
   everywhere.
   Example:
       m = leaf_mgen_reset( m );

   Equivalent GUI operation: clicking the "Set zero all" button in the
   "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_mgen\_scale}\label{section-leaf-mgen-scale}

\begin{verbatim}
m = leaf_mgen_scale( m, morphogen, scalefactor )
   Scale the value of a given morphogen by a given amount.
   Arguments:
   1: The name or index of a morphogen.
   2: The scale factor.
   Examples:
       m = leaf_mgen_scale( m, 'bpar', -1 );
   See also: leaf_mgen_const.

   Equivalent GUI operation: clicking the "Invert" button in the
   "Morphogens" panel will scale the current morphogen by -1. There is not
   yet a user interface for a general scale factor.
\end{verbatim}

\subsection{leaf\_mgen\_zero}\label{section-leaf-mgen-zero}

\begin{verbatim}
m = leaf_mgen_zero( m, morphogen )
   Set the value of a specified morphogen to zero everywhere.
   Arguments:
   1: The name or index of a morphogen.
   Examples:
       m = leaf_mgen_zero( m, 'growth' );
   See also: LEAF_MGEN_CONST.

   Equivalent GUI operation: clicking the "Set zero" button in the
   "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_mgeninterpolation}\label{section-leaf-mgeninterpolation}

\begin{verbatim}
m = leaf_mgeninterpolation( m, ... )
   Set the interpolation mode of morphogens of m.  When an edge of the
   mesh is split, this determines how the morphogen values at the new
   vertex are determined from the values at either end of the edge.

   Options:

   'morphogen'     This can be a morphogen name or index, a cell array of
                   morphogen names and indexes, or a vector of indexes.
   'interpolation' Either 'min', 'max', or 'average'.  If 'min', the new
                   values are the minimum of the old values, if 'max' the
                   maximum, and if 'average' the average.

   GUI equivalent: the radio buttons in the "On split" subpanel of the
   "Morphogens" panel.  These set the interpolation mode for the current
   morphogen.  As of the version of 2008 Sep 03, new meshes are created
   with the interpolation mode for all morphogens set to 'min'.
   Previously the default mode was 'average'.

   Example:
       m = leaf_mgeninterpolation( m, ...
               'morphogen', 1:size(m.morphogens,2), ...
               'interpolation', 'average' );
       This sets the interpolation mode for every morphogen to 'average'.
\end{verbatim}

\begin{verbatim}
                 disp(sprintf('%d %f',i,dt(i)))
\end{verbatim}

\begin{verbatim}
     ind=find(pm_l>0.95*max(pm_l(:)));
\end{verbatim}

\begin{verbatim}
         [m,tube_l]=leaf_morphogen_switch(m,...
             'StartTime',OnsetOfTubeGrowth,'EndTime',FinishTubeGrowth,...
             'Morphogen_l','tube','RealTime',realtime);
 Alternatively, these can be specified
         [m,basemid_l]=leaf_morphogen_switch(m,...
             'StartTime',OnsetOfTubeGrowth,'EndTime',FinishTubeGrowth,...
             'Morphogen_l','basemid','RealTime',realtime,...
             'OnValue',1.0,'OffValue',0.0);
\end{verbatim}

\subsection{leaf\_movie}\label{section-leaf-movie}

\begin{verbatim}
m = leaf_movie( m, ... )
   Start or stop recording a movie.
   Any movie currently being recorded will be closed.
   If the first optional argument is 0, no new movie is started.
   Otherwise, the arguments may contain the following option-value pairs:
   FILENAME    The name of the movie file to be opened.  If this is not
               given, and m.globalProps.autonamemovie is true, then a name
               will be generated automatically, guaranteed to be different
               from the name of any existing movie file. Otherwise, a file
               selection dialog is opened.
   MODE        (NOT IMPLEMENTED)  This is one of 'screen', 'file', or 'fig'.
                   'screen' will capture the movie frames from the figure
               as drawn on the screen, using avifile().
                   'file' will use print() to save the
               figure to a file, then load the file and add it to the
               movie.  This allows arbitrarily high resolution movies to
               be made, not limited to the size drawn on the screen.
                   'fig' will save each frame as a MATLAB .fig file
               and will not generate a movie file.  The figures can later
               be assembled into a movie file by running the command
               fig2movie.  The reason for this option is that when
               running in an environment with no graphics, I have been
               unable to find a way of creating images from figures.
   FPS, COMPRESSION, QUALITY, KEYFRAME, COLORMAP, VIDEONAME: These options
   are passed directly to the Matlab function AVIFILE.  LEAF_MOVIE provides
   defaults for some of these:
       FPS          15
       COMPRESSION  'Cinepak'
       QUALITY      100
       KEYFRAME     5

   Equivalent GUI operation: clicking the "Record movie..." button.

   See also AVIFILE.
\end{verbatim}

\subsection{leaf\_onecell}\label{section-leaf-onecell}

\begin{verbatim}
m = leaf_onecell( m, ... )
   Create a new leaf consisting of a single triangular cell.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'xwidth'        The diameter in the X dimension.  Default 1.
       'ywidth'        The diameter in the Y dimension.  Default 1.
   Example:
       m = leaf_onecell( [], 'xwidth', 1, 'ywidth', 1 );
   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_LUNE,
   LEAF_RECTANGLE, LEAF_SEMICIRCLE.

   Equivalent GUI operation: selecting "One cell" in the pulldown menu in
   the "Mesh editor" panel and clicking the "Generate mesh" button.
\end{verbatim}

\subsection{leaf\_paintpatch}\label{section-leaf-paintpatch}

\begin{verbatim}
m = leaf_paintpatch( m, cells, morphogen, amount )
   Apply the given amount of the given morphogen to every vertex of each
   of the cells.  The cells are identified numerically; the numbers are
   not user-accessible.  This command is therefore not easily used
   manually; it is generated when the user clicks on a cell in the GUI.
   Arguments:
   1: A list of the cells to apply the morphogen to.
   2: The morphogen name or index.
   3: The amount of morphogen to apply.

   Equivalent GUI operation: clicking on every vertex of the cell to be
   painted, with the "Current mgen" item selected in the "Mouse mode" menu.
   The morphogen to apply is specified in the "Displayed m'gen" menu in
   the "Morphogens" panel.
\end{verbatim}

\subsection{leaf\_paintvertex}\label{section-leaf-paintvertex}

\begin{verbatim}
m = leaf_paintvertex( m, morphogen, ... )
   Apply the given amount of the given morphogen to all of the given
   vertexes.  The vertexes are identified numerically; the numbers are
   not user-accessible.  This command is therefore not easily used
   manually; it is generated when the user clicks on a vertex in the GUI.

   Arguments:
   1: The morphogen name or index.

   Options:
       'vertex'    The vertexes to apply morphogen to.
   	'amount'    The amount of morphogen to apply.  This can be either a
                   single value to be applied to every specified vertex,
                   or a list of values of the same length as the list of
                   vertexes, to be applied to them respectively.
       'mode'      Either 'set' or 'add'.  'set sets the vertex to the
                   given value, 'add' adds the given value to the current
                   value.

   Equivalent GUI operation: clicking on the mesh when the "Morphogens"
   panel is selected.  This always operates in 'add' mode.  The morphogen
   to apply is specified in the "Displayed m'gen" menu in the "Morphogens"
   panel. Shift-clicking or middle-clicking will subtract the morphogen
   instead of adding it.
\end{verbatim}

\subsection{leaf\_perturbz}\label{section-leaf-perturbz}

\begin{verbatim}
m = leaf_perturbz( m, ... )
   Add a random perturbation to the Z coordinate of every node.
   Arguments:
       A number z, the amplitude of the random displacement.  The
       displacements will be randomly chosen from the interval -z/2 ...
       z/2.
   Example:
       m = leaf_perturbz( m, 0.5 )

   Equivalent GUI operation: the "Random Z" button on the "Mesh editor"
   panel. The amount of random deformation is specified by the value in
   the upper of the two text boxes to the right of the button.
\end{verbatim}

\subsection{leaf\_plot}\label{section-leaf-plot}

\begin{verbatim}
m = leaf_plot( m, ... )
   Plot the leaf.
   There are many options:
    figure             The figure to plot in.  By default, the current
                       figure.
    plotquantity       String.  This determines what sort of quantity is
                       to be plotted.
                       'morphogen': plot a morphogen.  (The default.)
                       'specifiedgrowth': the quantity of growth specified
                       by the morphogens.
                       'specifiedbend': the quantity of bending specified
                       by the morphogens.
                       'actualgrowth', 'actualbend': the actual amount of
                       growth or bend in the last timestep.
                       'residualgrowth', 'residualbend': the amount of
                       growth or bend in the last timestep that was
                       specified but which did not happen.  The difference
                       between specified and actual.
                       'strain' the magnitude of the residual strain
    morphogen          String or number: the name or index of a morphogen
                       to be plotted.  The default is 1.
    drawedges          Integer, determines which edges of the finite
                       element cells to draw. 0 = draw no edges, 1 = draw
                       only edges on the edge of the leaf, 2 = draw all
                       edges.
    drawgradients      Boolean.  Draw gradient vectors for the growth
                       polarising morphogen.
    drawcmap           Boolean.  Specifies whether to draw a colour bar at
                       the foot of the plot, to show the mapping between
                       colours and values.
    cmap               Color map.  Specifies how to map values to colours.
                       This should be an array suitable for passing to
                       Matlab's COLORMAP function.  Default:
                           For morphogens, minimum value = blue, maximum =
                               red, with intermediate values going round
                               the hue space.
                           For labels, yellow for unlabelled, blue for
                               labelled.
                           For stress and strain:
                               white       0%
                               blue        10%
                               green       20%
                               yellow      30%
                               red         40%
                               purple      90%
                               black       100% and above
    crange             1x2 element array, specifying the range of values
                       which is mapped to the colour range specified by
                       cmap.  This value will be supplied to Matlab's
                       CRANGE function.  The default is the range of the
                       data, min(data)..0 or 0..max(data), whichever is
                       narrowest and contains all the data.
    plottensors        Boolean.  Display the growth tensors based on
                       morphogens 1 to 3 (growth, polarisation, and
                       anisotropy).
                       Default 0.
    numbering          Boolean.  If true, draw the number of each finite
                       element cell.  Default 0.
    axisRange          Range of axes.  This should be a 1x6 array
                       [XLO,XHI,YLO,YHI,ZLO,ZHI] suitable for passing to
                       Matlab's AXIS function.  The default is chosen to
                       ensure the entire leaf lies within the range.
    axisVisible        Boolean: specifies whether to draw the axes.
                       Default true.
    alpha              Real number: transparency of the mesh. (0=invisible,
                       1=opaque.) Default 0.8 (slightly transparent).
    autoScale          Boolean, default 1.  If 1, axisRange will be
                       ignored and the current value used.

 leaf_plot stores all of the plotting options in the mesh, so that a
 subsequent call to leaf_plot with only the mesh as an argument will plot
 the same thing.

   Equivalent GUI operation: none.  The leaf is plotted automatically.
   Various options may be set in the "Plot options" panel, and the scroll
   bars on the picture change the orientation.
\end{verbatim}

\subsection{leaf\_plotoptions}\label{section-leaf-plotoptions}

\begin{verbatim}
leaf_plot( m, ... )
   Set default plotting options.
   See LEAF_PLOT for details.

   Equivalent GUI operation: plotting options may be set in the "Plot
   options" panel, and the scroll bars on the picture change the
   orientation.
\end{verbatim}

\begin{verbatim}
m = leaf_recomputestages( m, ... )
   Recompute a set of stages of the project, starting from the current
   state of m.  If this is after any of the stages specified, those stages
   will not be recomputed.

   Options:
       'stages'    A list of the stages to be recomputed as an array of
                   numerical times.  The actual times of the saved stages
                   will be the closest possible to those specified, given
                   the starting time and the time step.  If this option is
                   omitted, it will default to the set of stage times
                   currently stored in m, which can be set by
                   leaf_requeststages.

   See also: leaf_requeststages
\end{verbatim}

\subsection{leaf\_record\_mesh\_frame}\label{section-leaf-record-mesh-frame}

\subsection{leaf\_rectangle}\label{section-leaf-rectangle}

\begin{verbatim}
m = leaf_rectangle( m, varargin )
   Create a new rectangular mesh.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'xwidth'  The width of the rectangle in the X dimension.  Default 2.
       'ywidth'  The width of the rectangle in the Y dimension.  Default 2.
       'xdivs'   The number of finite element cells along the X dimension.
                 Default 8.
       'ydivs'   The number of finite element cells along the Y dimension.
                 Default 8.
       'base'    The number of divisions along the side with minimum Y
                 value.  The default is xdivs.
   Example:
       m = leaf_rectangle( [], 'xwidth', 2, 'ywidth', 2, 'xdivs', 8,
                           'ydivs', 8, 'base', 5 )
   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_LEAF, LEAF_ONECELL,
   LEAF_SEMICIRCLE.

   Equivalent GUI operation: selecting "Rectangle" in the pulldown menu in
   the "Mesh editor" panel and clicking the "Generate mesh" button.
\end{verbatim}

\subsection{leaf\_refineFEM}\label{section-leaf-refineFEM}

\begin{verbatim}
m = leaf_refineFEM( m, amount )
   AMOUNT is between 0 and 1.  Split that proportion of the edges of the
   finite element mesh, in random order.
   Example:
       m = leaf_refineFEM( m, 0.3 );

   Equivalent GUI operation: clicking the "Refine mesh" button in the
   "Mesh editor" panel.  The scroll bar and text box set the proportion of
   edges to be split.
\end{verbatim}

\subsection{leaf\_reload}\label{section-leaf-reload}

\begin{verbatim}
m = leaf_reload( m, stage, varargin )
   Reload a leaf from the MAT, OBJ, or PTL file it was last loaded from,
   discarding all changes made since then.  If there was no such previous
   file, the mesh is left unchanged.

   Arguments:
       stage:  If 0 or more, the indicated stage of the mesh, provided
               there is a saved state from that stage.  If 'reload', the
               stage that the mesh was loaded from or was last saved to,
               whichever is later.  If 'restart', the initial stage of the
               mesh.  If the indicated stage does not exist a warning is
               given and the mesh is left unchanged.  The default is
               'reload'.

   Options:
       rewrite:  Normally, when a model is loaded, its interaction
                 function (if there is one) is read, parsed, and
                 rewritten.  This is because it may have been created with
                 an older version of GFtbox.  Specifying the rewrite
                 option as false prevents this from being done.  This may
                 be necessary when running several simulations
                 concurrently on a parallel machine, all using the same
                 project.

   Equivalent GUI operations:  The "Restart" button is equivalent to
           m = leaf_reload( m, 'restart' );
       The "Reload" button is equivalent to
           m = leaf_reload( m, 'reload' );
       or
           m = leaf_reload( m );
       The items on the "Stages" menu are equivalent to
           m = leaf_reload( m, s );
       for each valid s.  s should be passed as a string.  For example, if
       the Stages menu has a menu item called 'Time 315.25', that stage
       can be loaded with
           m = leaf_reload( m, '315.25' );
\end{verbatim}

\subsection{leaf\_rename\_mgen}\label{section-leaf-rename-mgen}

\begin{verbatim}
 m = leaf_rename_mgen( m, oldMgenName, newMgenName, ... )
   Rename one or more morphogens.  Any number of old name/new name pairs
   can be given.  The standard morphogens cannot be renamed, and no
   morphogen can be renamed to an existing name.

   Equivalent GUI operation: clicking the "Rename" button in the
   "Morphogens" panel.

   See also:
       LEAF_ADD_MGEN, LEAF_DELETE_MGEN
\end{verbatim}

\begin{verbatim}
m = leaf_requeststages( m, ... )
   Add a set of stage times to the mesh.  None of these will be computed,
   but a subsequent call to leaf_recomputestages with no explicit stages
   will compute them.

   Options:
       'stages'    A list of numerical stage times.  These do not have to
                   be sorted and may contain duplicates.  The list will be
                   sorted and have duplicates removed anyway.
       'names'     A cell array of names in 1-1 correspondence with the
                   list of stage times.  These names will appear along
                   with the stage times on the Stages menu.  They default
                   to empty strings.
       'mode'      If 'replace', the list will replace any stage times
                   stored in m.  If 'add' (the default), they will be
                   combined with those present.  If 'names' is not
                   supplied or is the empty cell array, existing names
                   will be retained.

   GUI equivalent: Stages/RequestMore Stages... menu item.  This does not
   support the 'names' or 'mode' options and always operates in 'add' mode.
\end{verbatim}

\subsection{leaf\_rescale}\label{section-leaf-rescale}

\begin{verbatim}
m = leaf_rescale( m, ... )
   Rescale a mesh in space and/or time.

   Arguments:
   
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'spaceunitname'     The name of the new unit of distance.
       'spaceunitvalue'    The number of old units that the new unit is
                           equal to.
       'timeunitname'      The name of the new unit of time.
       'timeunitvalue'     The number of old units that the new unit is
                           equal to.
       If either spaceunitname or timeunitname is omitted or empty, no
       change will be made to that unit.

   Example:
       Convert a leaf scaled in microns to millimetres, and from days to
       hours:
           m = leaf_rescale( m, 'spaceunitname', 'mm', ...
                                'spaceunitvalue', 1000, ...
                                'timeunitname', 'hour', ...
                                'timeunitvalue', 1/24 );

   Equivalent GUI operation: the 'Params/Rescale...' menu item.
\end{verbatim}

\subsection{leaf\_rewriteIF}\label{section-leaf-rewriteIF}

\begin{verbatim}
m = leaf_rewriteIF( m, ... )
   Rewrite the interaction function of m.

   Normally the interaction function is rewritten the first time that it
   is called after loading a mesh.  This is to ensure that it is always
   compatible with the current version of GFtbox.  Sometimes it is
   necessary to prevent this from happening.  In this case, if it is later
   desired to force a rewrite, this function can be called.

   leaf_rewriteIF will do nothing if the i.f. has already been rewritten,
   unless the 'force' option has value true.

   Note that a rewrite always happens when a morphogen is added, deleted,
   or renamed, or when the standard morphogen type (K/BEND or A/B) is
   changed.

   Equivalent GUI operation: the Rewrite button on the Interction function
   panel.
\end{verbatim}

\subsection{leaf\_rotate}\label{section-leaf-rotate}

\begin{verbatim}
m = leaf_rotate( m, type1, rot1, type2, rot2, ... )
   Rotate the mesh about the given axes.  The rotations are performed in
   the order they are given: the order matters.  Each type argument is one
   of 'M', 'X', 'Y', or 'Z' (case is ignored).  For a type 'M', the
   following rotation should be a 3*3 rotation matrix.  For 'X', 'Y', or
   'Z' it should be an angle in degrees.  Any sequence of rotations can be
   given.

   See also: leaf_rotatexyz.
\end{verbatim}

\subsection{leaf\_rotatexyz}\label{section-leaf-rotatexyz}

\begin{verbatim}
m = leaf_rotatexyz( m, varargin )
   Rotate the coordinates of the leaf: x becomes y, y becomes z, and z
   becomes z.  If the argument -1 is given, the opposite rotation is
   performed.

   Equivalent GUI operation: clicking on the "Rotate xyz" button in the
   "Mesh editor" panel.

   See also: leaf_rotate.
\end{verbatim}

\subsection{leaf\_saddlez}\label{section-leaf-saddlez}

\begin{verbatim}
m = leaf_saddlez( m, ... )
   Add a saddle-shaped displacement to the nodes of m.
   Options:
       'amount'    The maximum amount of the displacement, which is
                   proportional to the distance from the origin.  Default
                   1.
       'lobes'     How many complete waves the displacemnt creates on the
                   edge (an integer, minimum value 2).  Default 2.
   Example:
       m = leaf_saddlez( m, 'amount', 1, 'lobes', 2 );

   Equivalent GUI operation: the "Saddle Z" button on the "Mesh editor"
   panel. The amount of saddle deformation is specified by the value in
   the upper of the two text boxes to the right of the button.  The number
   of waves is specified by the lower text box.
\end{verbatim}

\subsection{leaf\_save}\label{section-leaf-save}

\begin{verbatim}
m = leaf_save( m, filename, folderpath, ... )
   Save the leaf to a file.
   The way the leaf is saved depends on the extension of the filename:
       .MAT    The leaf is saved in a MAT file as a Matlab object called
               m.
       .M      Matlab commands to recreate this leaf are saved in a .M
               file.
       .OBJ    Only the nodes and triangles are saved, in OBJ format.
       .FIG    The current plot of the leaf is saved as a figure file.
   All of these formats except FIG can be read back in by leaf_load.
   Note that OBJ format discards all information except the geometry of
   the mesh.

   If the filename is just an extension (including the initial "."), then
   a filename will be prompted for, and the specified extension will be
   the default.  If no filename is given or the filename is empty, then
   one will be prompted for, and any of the above extensions will be accepted.

   The folder path specifies what folder to save the file in.  If not
   specified, then the default folder will be chosen, which depends on the
   file extension.  If a filename is then prompted for, the file dialog
   will open at that folder, but the user can navigate to any other.
   If the filename is a full path name then the folder name will be
   ignored and the file will be stored at the exact location specified by
   filename.

   Options:
       overwrite:  If true, and the output file exists already, it will
           be overwritten without warning.  If false (the default), the
           user will be asked whether to overwrite it.
       minimal:  For OBJ files, if this is true, then only the vertexes
           and triangles of the mesh will be written.  OBJ files of this
           form should be readable by any program that claims to read OBJ
           files.  If false (the default), all of the information in the
           mesh will be written, in an ad-hoc extension of OBJ format.

   Equivalent GUI operations: the "Save model..." button (saves as MAT
   file) or the "Save script...", "Save OBJ...", or "Save FIG..." menu
   commands on the "Mesh" menu.
\end{verbatim}

\begin{verbatim}
[m,ok] = leaf_savemodel( m, modelname, projectdir, ... )
   Save the model to a model directory.

   MODELNAME is the name of the model folder.  This must not be a full
   path name, just the base name of the folder itself.  It will be looked
   for in the folder PROJECTDIR, if specified, otherwise in the parent
   directory of m, if any, otherwise the current directory.

   If MODELNAME is not specified or empty, the user will be prompted for a
   name using the standard file dialog.  

   The model directory will be created if it does not exist.

   If the model is being saved into its own model directory:
       If it is in the initial state (i.e. no simulation steps have been
       performed, and the initialisation function has not been called) then
       it is saved into the file MODELNAME.mat.
       If it is in a later state, it will be saved to MODELNAME_Snnnn.mat,
       where nnnn is the current simulation time as a floating point
       number with the decimal point replaced by a 'd'.

   If the model is being saved into a new directory:
       The current state will be saved as an initial state or a later
       stage file as above.
       If the current state is not the initial state, then the initial
       state will be copied across.  Furthermore, the initial state of the
       new project will be loaded.
       The interaction function and notes file will be copied, if they
       exist.  If the notes file exists, the new notes file will also be
       opened in the editor.
       Stage files, movies, and snapshots are NOT copied across.

   If for any reason the model cannot be saved, OK will be false.

   Options:
       new:   If true, the mesh will be saved as the initial state of a
              project, even if it is not the initial state of the current
              simulation.  The default is false.
       strip:    If true, as many fields as possible of the mesh will be
              deleted before saving.  They will be reconstructed as far as
              possible when the mesh is loaded.  The only information that
              is lost is the residual strains and effective growth tensor
              from the last iteration.  The default is false.

   Equivalent GUI operation: the "Save As..." button prompts for a
   directory to save a new project to; the "Save" button saves the current
   state to its own model directory.  The "strip" option can be toggled
   with the "Misc/Strip Saved Meshes" menu command.
\end{verbatim}

\subsection{leaf\_semicircle}\label{section-leaf-semicircle}

\begin{verbatim}
m = leaf_semicircle( m, ... )
   Create a new semicircular mesh.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'radius'        The radius of the semicircle.  Default 1.
       'rings'         The number of circular rings of triangles to divide
                       it into. Default 4.
   Example:
       m = leaf_semicircle( [], 'radius', 2, 'rings', 4 );
   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_LEAF, LEAF_ONECELL,
   LEAF_RECTANGLE.

   Equivalent GUI operation: selecting "Semicircle" in the pulldown menu
   in the "Mesh editor" panel and clicking the "New" button.
\end{verbatim}

\subsection{leaf\_set\_mousemode}\label{section-leaf-set-mousemode}

\begin{verbatim}
m = leaf_set_mousemode( m, varargin )
   Set the effect of clicking on the mesh.

   Arguments
       1: the name of the mode.  This is a string, the name of the
       required mode.
   Options:
       Dependent on the mode.  Some modes take extra parameters and some
       take none.

   Whether a click is considered to be on a finite element, a biological
   cell, an edge, or a node is determined by the click mode.  When an edge
   or a node is required to be clicked, a click on a cell will be
   interpreted as a click on the nearest edge or node.

   The possible arguments and their options are as follows:
       'morphadd':  Clicking adds the current amount to the current
           morphogen at the clicked vertex.
       'morphset':  Clicking sets the current amount of the current
           morphogen at the clicked vertex.
       'morphfix':  Clicking fixes the amount of the current morphogen at
           the clicked vertex to its current value, regardless of the
           effects of diffusion or dilution.  Clicking to add or set the
           morphogen is still effective, as are modifications made by the
           interaction function.
       'morphshow':  Clicking displays the value of the quantity currently being
           plotted.  If the value is defined per vertex, the value at the
           vertex nearest to the click point will be shown; if per
           element, the value for the element clicked will be shown.  If
           the GUI is running, the value will be displayed there,
           otherwise printed to the command window.
       'Fix node': Clicking fixes or unfixes one or more degrees of
           freedom of movement of the node, as specified by the optional
           argument, which a string containing any of the letters 'xyz'.
           If the string is empty, the node becomes unfixed.  If the
           string is nonempty, the node becomes unfixed if its current
           fixed degrees of freedom coincide with the string; otherwise,
           the degrees of freedom specified by the string become fixed and
           the others unfixed.
       'Locate node': Clicking nominates this node to remain stationary
           with respect to the specified degrees of freedom.  This differs
           from 'Fix node' in that no more than one node can be specified
           for each degree of freedom, and the mesh is rigidly translated
           so as to maintain the constraint.
       'deletecell': clicking on a cell deletes it from the mesh.
       'seam': Toggle an edge between being a seam or not.
       'split': Toggle an edge between being designated for splitting or
           not.
\subsection{leaf\_set\_userdata}\label{section-leaf-set-userdata}

\begin{verbatim}
m = leaf_set_userdata( m, ... )
   Set fields of the userdata of m.  The arguments should be alternately a
   field name and a field value.

   You can store anything you like in the userdata field of the canvas.
   The growth toolbox will never use it, but your own callbacks, such as
   the morphogen interaction function, may want to make use of it.

   See also: LEAF_ADD_USERDATA, LEAF_DELETE_USERDATA.

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_setbgcolor}\label{section-leaf-setbgcolor}

\begin{verbatim}
m = leaf_setbgcolor( m, color )

   Set the background colour of the picture, and of any snapshots or
   movies taken.  COLOR is a triple of RGB values in the range 0..1.
\end{verbatim}

\subsection{leaf\_setgrowthmode}\label{section-leaf-setgrowthmode}

\begin{verbatim}
m = leaf_setgrowthmode( m, mode )

   Specify whether growth is described by growth and anisotropy, or by
   growth parallel and perpendicular to the polarisation gradient.
   Allowable values for MODE are 'ga' or 'pp' respectively.

   THIS FUNCTION HAS BEEN WITHDRAWN, 2008 May 15.
\end{verbatim}

\subsection{leaf\_setmutant}\label{section-leaf-setmutant}

\begin{verbatim}
m = leaf_setmutant( m, ... )
   Set the mutant level of a morphogen.

   Options:
   morphogen:   The name or index of a morphogen.  If omitted, the
                mutation properties are set for every morphogen.
   value:       The value the morphogen has in the mutant state, as a
                proportion of the wild-type state.

   Examples:
       m = leaf_setmutant( m, 'morphogen', 'div', 'value', 0 );
           % Set the mutated level of the 'div' morphogen to zero.
\end{verbatim}

\subsection{leaf\_setproperty}\label{section-leaf-setproperty}

\begin{verbatim}
m = leaf_setproperty( m, ... )
   Set global properties of the leaf.
   The arguments are a series of name/value pairs.

   The property names that this applies to are:
       'poisson'       Poisson's ratio.  The normal value is 0.35 and
                       there is little need to change this.
       'bulkmodulus'   The bulk modulus.  The normal value is 3000 and
                       there is little need to change this.
       'cvtperiter'    The amount of CVT transformation to be carried out
                       per iteration.
       'jiggle'        The amount of jiggling of the biological cells to
                       be carried out per iteration.
       'validate'      Whether to validate the mesh after every iteration.
                       This is for debugging purposes and should normally
                       be off.
       'displayedgrowth'    Specifies which morphogen to plot.

       ...and many others I have omitted to document.

   Example:
       m = leaf_setproperty( m, 'poisson', 0.49 );

   Equivalent GUI operation: several GUI elements are implemented by this
   command:
       poisson:        Text box in "Mesh editor" panel.
       bulkmodulus:    No GUI equivalent.
       residstrain:    "Strain retention" in "Simulation" panel.
       cvtperiter:     "CVT per iter" in "Simulation" panel.
       jiggle:         "Jiggle" in "Simulation" panel.
       validate:       No GUI equivalent.
       displayedgrowth:  "Displayed m'gen" menu in "Morphogens" panel.
       ...etc.
\end{verbatim}

\subsection{leaf\_setsecondlayerparams}\label{section-leaf-setsecondlayerparams}

\begin{verbatim}
m = leaf_setsecondlayerparams( m, varargin )

   Set various general properties of the second layer.  If the second
   layer does not exist an empty second layer will be created, and the
   properties set here will be the defaults for any subsequently created
   nonempty second layer.

   If m already has a second layer, this procedure does not affect the
   colours of existing cells, only the colours that may be chosen by
   subsequent recolouring operations.

   Options:
       colors: An N*3 array of RGB values.  These are the colours
               available for colouring cells.  The special value 'default'
               will use the array [ [0.1 0.9 0.1]; [0.9 0.1 0.1] ].
               N should be 2.  "Ordinary" cells will be coloured with the
               first colour, while "shocked" cells will be coloured with
               the second colour.
       colorvariation: A real number between 0 and 1.  When a colour for a
               cell is selected from the colour table, this amount of
               random variation will be applied to the value selected from
               colors.  A suitable value is 0.1, to give a subtle
               variation in colour between neighbouring cells.
\end{verbatim}

\subsection{leaf\_setthicknessparams}\label{section-leaf-setthicknessparams}

\begin{verbatim}
m = leaf_setthicknessbyarea( m, value )
   Set the thickness of the leaf as a function of its current area:
   thickness = K*area^(P/2).
   K may have any positive value.  P must be between 0 and 1.

   Options:
       'scale'    K.  Default is 0.5.
       'power'    P.  Default is 0.
\end{verbatim}

\subsection{leaf\_setzeroz}\label{section-leaf-setzeroz}

\begin{verbatim}
m = leaf_setzeroz( m )
   Set the Z displacement of every node to zero.

   Equivalent GUI operation: the "Zero Z" button on the "Mesh editor"
   panel.
\end{verbatim}

\subsection{leaf\_shockA}\label{section-leaf-shockA}

\begin{verbatim}
m = leaf_shockB( m, amount )
   AMOUNT is between 0 and 1.  Mark that proportion of randomly selected
       cells of the A layer with random colours.  At least one cell will
       always be marked.  If there is no A layer, the command is ignored.
   Example:
       m = leaf_shockA( m, 0.3 );

   Equivalent GUI operation: "Shock cells" button on the Bio-A panel.
   The accompanying slider and text box set the proportion of cells to shock.
\end{verbatim}

\subsection{leaf\_shockB}\label{section-leaf-shockB}

\begin{verbatim}
m = leaf_shockB( m, amount )
   AMOUNT is between 0 and 1.  Mark that proportion of randomly selected
       cells of the B layer with random colours.  At least one cell will
       always be marked.  If there is no B layer, the command is ignored.
   Example:
       m = leaf_shockB( m, 0.3 );

   Equivalent GUI operation: "Shock cells" button on the Bio-B panel.
   The accompanying slider and text box set the proportion of cells to shock.
\end{verbatim}

\subsection{leaf\_showaxes}\label{section-leaf-showaxes}

\begin{verbatim}
m = leaf_showaxes( m, axeson )

   Make the axes visible or invisible, according as AXESON is true or false.
\end{verbatim}

\subsection{leaf\_snapdragon}\label{section-leaf-snapdragon}

\begin{verbatim}
m = leaf_snapdragon( m, ... )
 Make an early stage of a snapdragon flower.  This consists of a number of
 petals, each of which consists of a rectangle surmounted by a semicircle.
 The rectangular parts of the petals are connected to form a tube.
 The mesh is oriented so that the cell normals point outwards.

   Arguments:
       M is either empty or an existing mesh.  If it is empty, then an
       entirely new mesh is created, with the default set of morphogens
       If M is an existing mesh, then its geometry is replaced by the new
       mesh.  It retains the same set of morphogens (all set to zero
       everywhere on the new mesh), interaction function, and all other
       properties not depending on the specific geometry of the mesh.

   Options:
       'petals'        The number of petals.  Default 5.
       'radius'        The radius of the tube.  Default 1.
       'rings'         The number of circular rings of triangles to divide
                       the semicircular parts into. Default 3.
       'height'        The height of the rectangle, as a multiple of the
                       semicircle's diameter.  Default 0.7.
       'base'          The number of divisions along half of the base of
                       each  petal. By default this is equal to rings,
                       i.e. the same as the number at the top of the tube.
       'strips'        The number of strips of triangles to divide the
                       tubular part into.  If 0 (the default), this will
                       be calculated from the height so as to make the
                       triangles similar in size to those in the lobes.
   Example:
       m = leaf_snapdragon( [], 'petals', 5, 'radius', 2, 'rings', 4 );
   See also: LEAF_CIRCLE, LEAF_CYLINDER, LEAF_LEAF, LEAF_ONECELL,
   LEAF_RECTANGLE, LEAF_LOBE.
\end{verbatim}

\subsection{leaf\_snapshot}\label{section-leaf-snapshot}

\begin{verbatim}
m = leaf_snapshot( m, filename, ... )
 Take a snapshot of the current view of the leaf into an image file.
 A name for the image file will be automatically generated if none is
 given.

   Arguments:
       1: The name of the file to write.  The extension of
          the filename specifies the image format.  This may be
          any format acceptable to the Matlab function IMWRITE.
          These include 'png', 'jpg', 'tif', and others.

   Options:
       'newfile': if true (the default), the file name given will be
           modified so as to guarantee that it will not overwrite any
           existing file. If false, the filename will be used as given and
           any existing file will be overwritten without warning.
       'thumbnail': if true (the default is false), the other arguments
           and options will be ignored (the filename must be given as the
           empty string), and a snapshot will be saved to the file
           thumbnail.png in the project directory.

   All remaining arguments will be passed as options to IMWRITE.  Any
   arguments taken by IMWRITE may be given.  If any such arguments are
   provided, the filename must be present (otherwise the first argument
   for IMWRITE would be taken to be the filename).  If you do not want to
   provide a filename, specify it as the empty string.  The image will be
   saved in the 'snapshots' folder of the current project folder, if any,
   otherwise the current folder.  You can override this by specifying an
   absolute path.

   Example:
       m = leaf_snapshot( m, 'foo.png' );

   Equivalent GUI operation: clicking the "Take snapshot" button.  This
   saves an image in PNG format into a file with an automatically
   generated name.  A report is written to the Matlab command window.
   The 'thumbnail' option is equivalent to the "Add Thumbnail" menu
   command.

   See also:
       IMWRITE
\end{verbatim}

\subsection{leaf\_spin}\label{section-leaf-spin}

\begin{verbatim}
m = leaf_spin( m )
   Spin the mesh by 360 degrees about the Z axis, leaving it in exactly the
   same orientation as when it started.  If a movie is currently being
   recorded, the animation will be appended to the movie.  The current view
   is assumed to have already been written to the movie.

   Options:
       'frames':  The number of frames to be added.  Each frame will
                  rotate the mesh by 360/frames degrees.
\end{verbatim}

\subsection{leaf\_splitbio}\label{section-leaf-splitbio}

\begin{verbatim}
m = leaf_splitbio( m )
   Split all biological cells that are currently too large.

   Equivalent GUI operation: "Split cells" button.
\end{verbatim}

\subsection{leaf\_splitsecondlayer}\label{section-leaf-splitsecondlayer}

\begin{verbatim}
m = leaf_splitsecondlayer( m )
   Split every cell in the second layer.  Reset the splitting threshold
   to make the new cell sizes the target sizes.

   Equivalent GUI operation: "Split L2" button.
\end{verbatim}

\subsection{leaf\_stitch\_vertex}\label{section-leaf-stitch-vertex}

\begin{verbatim}
m = leaf_stitch_vertex( m, dfs )
   Constrain sets of vertexes of the mesh so that they move identically.

   Arguments:
       dfs: a cell array of vectors of degree of freedom indexes.  Dfs in
            the same vector will be constrained to change identically.
            No index may occur more than once anywhere in dfs.

   Equivalent GUI operation: none.
\end{verbatim}

\subsection{leaf\_subdivide}\label{section-leaf-subdivide}

\begin{verbatim}
m = leaf_subdivide( m, ... )
   Subdivide every edge of m where a specified morphogen is above and/or below
   thresholds, and the length of the current edge is at least a certain
   value.

   NB. This function is currently NOT suitable for calling from an
   interaction function.  It will go wrong.

   Note that this command will subdivide every eligible edge every time it
   is called.  It does not remember which edges it has subdivided before
   and refrain from subdividing them again.

   Options:
       'morphogen': The name or index of the morphogen
       'min':       The value that the morphogen must be at least equal to.
       'max':       The value that the morphogen must not exceed.
       'mode':      'all' [default], 'any', or 'mid'.
       'minabslength': A real number.  No edge shorter than this will be
                    subdivided.
       'minrellength': A real number.  This is a fraction of the current
                    threshold for automatic splitting of edges.  No edge
                    shorter than this will be subdivided.  The current
                    threshold value is returned by currentEdgeThreshold(m).
       'levels':    The levels of morphogen the new vertices will adopt
                    'all','interp','none'

   An edge will be subdivided if and only if it satisfies all of the
   conditions that are specified.  Any combination of the arguments can be
   given.  No arguments gives no subdivision.

   'mode' is only relevant if 'min' or 'max' has been specified.
   If mode is 'all', then each edge is split for which both ends satisfy
   the min/max conditions.
   If mode is 'any', each edge is split for which either edge
   satisfies the conditions.
   If mode if 'mid', each edge is split for which the average of the
   morphogen values at its ends satisfies the conditions.

   This command ignores the setting, that can be set through the GUI or
   leaf_setproperty(), that enables or disables automatic splitting of
   long edges.
\end{verbatim}

\subsection{leaf\_unshockA}\label{section-leaf-unshockA}

\begin{verbatim}
m = leaf_unshockA( m )
   Restore all cells of the Bio-A layer to their unshocked state.
   Example:
       m = leaf_unshockA( m );

   Equivalent GUI operation: "Unshock all cells" button on the Bio-A panel.
\end{verbatim}

\subsection{leaf\_vertex\_monitor}\label{section-leaf-vertex-monitor}

\begin{verbatim}
     setaxis(gca,[0,ax(2),ax(3)-0.5,ax(4)+0.5]);
\end{verbatim}

\subsection{leaf\_vertex\_set\_monitor}\label{section-leaf-vertex-set-monitor}

\begin{verbatim}
             case 'MARK'
                 marker=arg{2};
                 region=arg{1};
\end{verbatim}

