This software implements an algorithm from the paper Generating discrete Morse functions from point data by Henry King, Kevin Knudson, and Neža Mramor.  This algorithm takes a function on the vertices of a 3 dimensional simplicial complex and converts it into a discrete Morse function in the sense of Forman.  It also cancels pairs of critical simplices which are connected by a single gradient path and whose values differ by less than a prescribed persistence.


Compiling the programs:

    These programs can be compiled using the commands:
    The last command works on a Mac running OSX but needs to be changed for other platforms so  OpenGL can be accessed.  Perhaps the following will work:

Running the programs:

    Here is a sample run.

./randomvertices 30000 > fv
./enclose fv
./qhprep fv | qdelaunay QJ i > ft
./extract -v fv -q ft

    The first command generates 30000 random points and assigns a value to each.  The second command encloses the points in a tetrahedron. The third finds a triangulation with the points as vertices.  The last command computes a discrete Morse function and allows you to visualize it.  You should be presented with a window with a black background, some white dots (which are the vertices) and some colored balls, some with lines coming from them (these are the critical simplices, The balls are around the barycenter of the simplex and the lines go to the barycenters of its codimension one faces.  Possibly a purple ball representing a critical vertex fills the window initially.) 

Navigating in the viewer:

Keyboard actions:
Mouse actions:
Command line options:

    extract has the following command line options:

-v fv  A file of vertices, must be present

-q ft  A file of tetrahedra, in the format output by qdelaunay.  If neither the -q or -t option is given, it is assumed the tetrahedron file is on stdin in the qdelaunay format.

-t file  Use instead of -q if you have a plain tetrahedron file,  without the extra stuff from qdelaunay.
       
-p persistence  The persistence amount, default = .1.
       
-h maxh  any two vertices with values above this will be considered to have equal value for persistence purposes, default = 1.
       
-l minh  any two vertices with values below this will be considered to have equal value for persistence purposes. default = 0.
       
-x scalex  scale all x values by dividing by this factor, default = 1.

-y scaley  scale all x values by dividing by this factor, default = 1.

-z scalez  scale all x values by dividing by this factor, default = 1.

-o val  A more complicated method is used to assign values to vertices in the lower link which might give a discrete vector field which more closely approximates an underlying smooth vector field.  It's not clear it makes much difference.  The following argument val is ignored, but must be present.


Older version:

Following is an older version of this software.  The main difference is that internally, in the new version of the software above, the only explicitly represented simplices are vertices and tetrahedra, a la CGAL's representation.  So an edge, say, would be referred to as the edge in some specific tetrahedron thus there would be many ways of referring to the same edge since it is in many tetrahedra (a bit less than 6 on average).  In the old version, all simplices are explicitly represented. The tradeoffs are:


Running the programs:

    Here is a sample run.

./randomvertices 30000 > randv
./qhprep randv v.tmp | ./qdelaunay QJ -Fx i >qdata
./xqhconvert v.tmp < qdata >sdata
./MorseExtract 100 randv < sdata

    The first command generates 30000 random points and assigns a value to each.  The second command encloses the points in a tetrahedron and finds a triangulation with the points as vertices.  The third command converts the triangulation to a form suitable for input to MorseExtract.  The last command computes a discrete Morse function and allows you to visualize it.  It does little cancelation because the persistence is set to 100 which is small compared to the 65000 range of function values.

Navigating around the complex using view:

    view could use a great deal of improvement, but this is a start.

File formats:

    I'll refer to the filenames given in the sample run above.  All files are ascii text files.