Graphical Visualization of a Tree Growth Process Model


The Visualization Program: Module Descriptions 
createTree Module
Contains functions that send the appropriate commands to Geomview in order to
draw a given tree.
View the code.
void InitializeTrees ()
parameters: none
returns: nothing
task: Initializes the Geomview camera in which the tree will be
drawn. The background is set to light blue, the appearance controls are
overridden (the appearance of the tree depends on the settings given by the
visualization program and not by the default Geomview ones), and defines the
standard cylindrical object used later to create the tree branches.
void GenerateTree (int treeID, treeData t)
parameters: which tree is being drawn and the data for that
tree
returns: nothing
task: checks to see which parts of the tree (branches, leaves, or
roots), if any, need to be drawn. The appropriate functions are then called
to define those parts of the tree. (See GenerateBranches, GenerateLeaves, and
GenerateRoots)
void GenerateLeaves (int treeID, eco_leafType leafType, float min, float
max, float minOrig, float maxOrig, eco_color color, lfStructPtr L)
parameters: which tree is being drawn, how the leaves are to be
colored (normal, psyn, LPI, percent shaded, ppfd-sun, ppfd-shade), the minimum
and maximum value of the attributes for leaves that should be drawn, the
minimum and maximum values of the attributes for all the leaves on this tree,
the base color for the leaves, and the leaf data.
returns: nothing
task: draws the leaves for the tree by determining how they should
be colored and which leaves should be drawn, then sending the information to
Geomview.
void GenerateBranches (int treeID, bool display, brchSegPtr B)
parameters: which tree is being drawn, whether the branches should
be drawn, and the data for the branches.
returns: nothing
task: If the branches are to be displayed, the branch segments are
calculated and defined by sending the information to Geomview. If the branches
are not to be displayed, the branches object is defined to Geomview as
empty.
void GenerateRoots (int treeID, bool showRoots, eco_rootType rootType, float
min, float max, float minOrig, float maxOrig, eco_color color, rtStructPtr
R)
parameters: which tree is being drawn, whether the roots are to be
displayed, how the roots are to be colored, the minimum and maximum value of
the attributes for roots that should be drawn, the minimum and maximum values
of the attributes for all the roots on this tree, the base color for the roots,
and the data for the roots.
returns: nothing
task: If the roots are to be drawn, the color of the root segments
and which segments should be drawn are determined. Each segment is defined
as an instance of a standard cylinder (height of 1, radius of 1, and positioned
on the +y-axis) and a transformation on that cylinder to the correct
coordinates. For normal roots, all root segments are drawn and only one
standard cylinder is defined with the color baseColor. For roots
colored according to attribute values, only root segments with values falling
into the range min to max should be drawn. The color of each segment is
determined by calling pickRootCylinder. If the roots are not to be
displayed, they root system is defined as an empty list.
void GenerateTrans (float x0, float y0, float z0, float x1, float y1, float
z1, float radius)
parameters: the three-dimensional coordinates of both axis
endpoints and the radius for a cylinder being drawn.
returns: nothing
task: Calculates the transformation matrix that will move the base
cylinder (radius = 1.0, positioned with axis on +y-axis starting at the origin)
to the position it should be at. (Used for defining root and branch
segments)
void multMatrices (matrix product, matrix m1, matrix m2)
parameters: the matrix in which the product should be placed, and
the two matrices being multiplied.
returns: the product of the two matrices
task: multiplies two matrices together and places the product into
the proper parameter.
void defineRootSegments (int numGrps,eco_color baseColor)
parameters: the number of cyliders to define and the base color
used in coloring the roots.
returns: nothing
task: defines the cylinders to be used in the coloring of root
segments according to attribute values. Each cylinder is colored according to
the number of cylinders being defined. The first cylider will be black and
the last white, and any remaining cyliders inbetween are colored from dark
shades to lighter shades of the color. See description of the
pickRootCylinder (...) function to see how these are used.
void pickRootCylinder (string rtStr,float value,float min,float max,int
numGrps)
parameters: the string that the cylinder name is returned in, the
value of the attribute for the current root segment, the minimum and maximum
possible values for the root attribute, and the number of cylinders that were
defined in defineRootSegments.
returns: the name of the cylinder that should be used to define the
current root segment.
task: determines the range that the root segment falls into
according to the segment's attribute value. There are numGrps equal
ranges between the values of min and max, each represented by one of the
cylinders defined in defineRootSegments. The lowest range of numbers is
represented by the black cylinder, the next range by the next darkest, and so on
until the highest range which has the white cylinder. The cylinder representing
the corresponding range is returned in rtStr.
processAttribs Module
View the code.
Contains functions dealing with the coloring of leaves and/or root segments
according to certain characteristics that they possess.
void pickAttribColor (float value, float min, float max, eco_color
startColor, eco_color *newColor)
parameters: the value of the attribute for the current leaf or root
segment, the minimum and maximum values for that attribute, the base color for
the leaves or roots, and the new color for the leaf or root segment.
returns: the shade of the base color that the current leaf or root
segment should be colored.
task: calculates the shade of the base color the current leaf or
root segment should be colored with the higher the value of the attribute, the
lighter the shade.
void setLeafAttributeRange (lfStructPointer L, eco_leafType lfType, float
*min, float *max)
parameters: the data for the current tree's leaves and the
attribute that the leaves are being colored according to.
returns: the minimum and maximum attribute value for the
leaves.
task: goes through leaf data and finds the smallest and largest
attribute value for the leaves.
void setRootAttributeRange (rtStructPointer R, eco_rootTyper rtType, float
*min, float *max)
parameters: the data for the current tree's roots and the attribute
that the roots are being colored according to.
returns: the minimum and maximum attribute value for the roots.
task: goes through root data and finds the smallest and largest
attribute value for the roots.
treeSwap Module
Contains functions that handle the swaping of tree data both on the user
interface form and in the tree database.
View the code.
void copyTree (treeData *t1, treeData t2)
parameters: the tree that the new data is copied to and the tree
that the new data is being copied from.
returns: the first tree containing the information from the second
tree.
task: copies the data from t2 into t1.
void setForm (treeData t)
parameters: the tree data for the tree currently represented on the
user interface form.
returns: nothing
task: sets the form objects (buttons, input fields, choice objects)
to the settings corresponding to the tree data of the tree being represented
treelist Module
Contains functions for the tree database.
View the code.
void newBrchSeg (brchSegPtr *B)
parameters: a pointer to the parent branch segment of the segment
being created
returns: the branch segment pointer with a new branch segment
pointed to by its "next" pointer
task: allocates memory for a new branch segment and points the
given branch segment to the new segment
void newLeafStruct (lfStructPtr *L)
parameters: a pointer to the parent leaf of the leaf being
created
returns: the leaf structure pointer with a new leaf pointed to by
its "next" pointer
task: allocates memory for a new leaf and points the given leaf to
the new structure
void newRootSeg (rtSegPtr *R)
parameters: a pointer to the parent root segment of the segment
being created
returns: the root segment pointer with a new root segment pointed
to by its "next" pointer
task: allocates memory for a new root segment and points the given
root segment to the new segment
void addBranchSeg (brchSegPtr *B, float x1, float y1, float z1, float x2,
float y2, float z2, float radius)
parameters: the branch segment to add the new segment to, the
three-dimensional coordinates for the endpoints of the new segment's axis
((x1,y1,z1) & (x2,y2,z2)), and the radius of the segment.
returns: a new branch segment pointed to by the given segment in
the first parameter and
initialized with the segment data in the remaining parameters.
task: creates a new branch segment with a call to
newBrchSeg, and initializes it with the data from the parameters.
void addLeafStruct (lfSegPtr *L, float psyn, float shade, float lpi, float
ppfdSUN, float ppfdSHADE, float x1, float y1, float z1, float x2, float y2,
float z2, float x3, float y3, float z3, float x4, float y4, float z4)
parameters: the leaf pointer to add the new leaf to, the attribute
values for the new leaf, and the three-dimensional coordinates for the four
vertices of the new leaf ((x1,y1,z1) ... (x4,y4,z4))
returns: a new leaf pointed to by the given leaf in the first
parameter and initialized with the leaf data in the remaining parameters.
task: creates a new leaf structure with a call to
newLeafStruct, and initializes it with the data from the parameters.
void addRootSeg (rtSegPtr *R, float order, float x1, float y1, float z1,
float x2, float y2, float z2, float radius)
parameters: the root segment to add the new segment to, the
three-dimensional coordinates for the endpoints of the new segment's axis
((x1,y1,z1) & (x2,y2,z2)), and the radius of the segment.
returns: a new root segment pointed to by the given segment in the
first parameter and initialized with the segment data in the remaining
parameters.
task: creates a new root segment with a call to newRootSeg,
and initializes it with the data from the parameters.
void clearBrchList (brchSegPtr *B)
parameters: the pointer to the list of branch segments to be
cleared
returns: the empty list
task: removes each segment in the list and frees the memory for
it
void clearLeafList (lfStructPtr *L)
parameters: the pointer to the list of leaves to be cleared
returns: the empty list
task: removes each leaf in the list and frees the memory for it
void clearRootList (rootSegPtr *R)
parameters: the pointer to the list of root segments to be
cleared
returns: the empty list
task: removes each segment in the list and frees the memory for
it
void readBrchList (brchSegPtr *B, FILE *fp)
parameters: a pointer to the list to add the branch segments to and
a file pointer to the file to read the information from.
returns: the list with all the data read in from the branches
file.
task: opens the file pointed to by fp, reads in the branch
segments one at a time, calling addBranchSeg if no errors are found.
void readRootList (rootSegPtr *R, FILE *fp)
parameters: a pointer to a root segment and a file pointer.
returns: the list of all the data read in from the roots file.
task: opens the file pointed to by fp, reads in the root
segment data one root segment at a time, calling addRootSeg if no errors
are found.
void readLeafList (lfStructPtr *L, FILE *fp)
parameters: a pointer to a leaf structure and a file pointer.
returns: the list of all data read in from the leaves file.
task: opens the file pointed to by fp, reads in the leaf
structure data one leaf at a time, calling addLeafStruct if no errors are
found.
void printBrch (branchSegPtr B)
parameters: a pointer to a branch segment.
returns: nothing
task: prints out the data in the segment pointed to by B in
a single line.
void printRoot (rootSegPtr R)
parameters: a pointer to a root segment.
returns: nothing
task: prints out the data in the segment pointed to by R in
a single line.
void printLeaf (leafStructPtr L)
parameters: a pointer to a leaf structure.
returns: nothing
task: prints out the data in the segment pointed to by L in
a single line.
ecoform Module
Contains a function that defines the interface form.
View the code.
void create_ecoform ()
parameters: none
returns: nothing
task: builds the form for the ECOPHYS Visualization Program using
the FORMS Library.
formCallbacks Module
Contains the callback functions that are associated with the interface form's
objects.
View the code.
assignDefaults ()
parameters: none
returns: nothing
task: initializes the tree data structures used to hold the tree
information and calls setForm to make the form correspond to the current
tree's settings
void updateButton_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (the update button) and an argument that allows the callback to take
different actions for different types
returns: nothing
task: determines which tree is being updated and whether a file has
been loaded for that tree. If it has, GenerateTree is called and the
boolean tree variables that state which parts of the tree have been changed are
adjusted to indicate no changes (since the most recent settings for the tree
have been drawn)
void treeButton_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (tree1Button or tree2Button) and an argument that allows
the callback to take different actions for different types
returns: nothing
task: determine which tree button has been selected, copies the
current tree's settings into the tree that is not selected, copies the selected
tree's information into the current tree, and sets the form to correspond with
the new current tree's settings.
loadFile_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (the load button for Tree 1 or Tree 2) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: determines which tree the file is being loaded for and calls
loadTreeFiles with the info for that tree.
void leafType_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (leafType choice object) and an argument that allows the callback
to take different actions for different types
returns: nothing
task: determines which leaf type option was selected by the user
and adjusts the tree variables and the form to correspond to it.
void leafColorChoice_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (leafColorChoice choice object) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: determines what color was selected for the leaves, puts that
color value into the tree variables corresponding to the leaf color, and adjusts
the boolean tree variable leavesChanged to indicate that the leaves need
to be redrawn on the next update.
void leafminValue_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (lfmin input field) and an argument that allows the callback to
take different actions for different types
returns: nothing
task: takes the new float value typed into the input field
lfmin on the interface form and determines if it is within the maximum
and minimum range of the leaf attributes for the current tree. If it is within
the range, it sets the tree variable minLfValue to that value.
void leafmaxValue_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (lfmax input field) and an argument that allows the callback to
take different actions for different types
returns: nothing
task: takes the new float value typed into the input field
lfmax on the interface form and determines if it is within the maximum
and minimum range of the leaf attributes for the current tree. If it is within
the range, it sets the tree variable maxLfValue to that value.
void resetLeaves_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (resetLvsButton button object) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: returns the minimum and maximum values for the current leaf
attribute choice back to the initial values (values may have been changed by
user)
void rootType_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (rootType choice object) and an argument that allows the callback
to take different actions for different types
returns: nothing
task: determines which root type option was selected by the user
and adjusts the tree variables and the form to correspond to it.
void rootColorChoice_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (branchChoice choice object) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: determines which color option was selected for the roots,
puts that color value into the tree variables corresponding to the root color,
and adjusts the boolean tree variable rootsChanged to indicate that the
roots need to be redrawn on the next update.
void rootminValue_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (rtmin input field) and an argument that allows the callback to
take different actions for different types
returns: nothing
task: takes the new float value typed into the input field
rtmin on the interface form and determines if it is within the maximum
and minimum range of the root attributes for the current tree. If it is within
the range, it sets the tree variable minRtValue to that value.
void rootmaxValue_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (rtmax input field) and an argument that allows the callback to
take different actions for different types
returns: nothing
task: takes the new float value typed into the input field
rtmax on the interface form and determines if it is within the maximum
and minimum range of the root attributes for the current tree. If it is within
the range, it sets the tree variable maxRtValue to that value.
void resetRoots_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (resetRtsButton button object) and an argument that allows the
call-back to take different actions for different types
returns: nothing
task: returns the minimum and maximum values for the current root
attribute choice back to the initial values (values may have been changed by
user)
void branchChoice_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (branchChoice choice object) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: determines which of the two choices were picked ("Show
branches" or "No branches"), sets the tree variable showBranches to TRUE
if they are to be shown and FALSE if not, and sets the tree variable
branchesChanged to TRUE to indicate that the branches have to be redrawn
on the next update.
void rootChoice_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (rootChoice choice object) and an argument that allows the
callback to take different actions for different types
returns: nothing
task: determines which of the two choices were picked ("Show roots"
or "No roots"), sets the tree variable showRoots to TRUE if they are to
be shown and FALSE if not, and sets the tree variable rootsChanged to
TRUE to indicate that the roots have to be redrawn on the next update.
void sunChoice_cb (FL_OBJECT *obj, long arg)
parameters: the object that caused the callback routine to be
called (sunChoice choice object) and an argument that allows the callback
to take different actions for different types
returns: nothing
task: determines which of the two choices were picked ("Sunlight"
or "No sunlight"), sets the tree variable displaySun to TRUE if it is to
be shown and FALSE if not.
loadfiles Module
Contains functions for loading the ECOPHYS tree files.
View the code.
bool loadSubFiles (string brchFile , string lvsFile,
string rtsFile, bool fSelect, bool fFirst, treeData tree)
parameters: the object that caused the call-back routine to be
called and an argument that allows the call-back to take different actions for
different types
returns: TRUE if no errors occurred or FALSE if the load was not
successful.
task: reads in the information contained in files named
"brchFile", "lvsFile", and "rtsFile" and with
calls to readBrchList, readRootList, and readLeafList.
void getSubFileNames (strpointer bFile, strpointer lFile, strpointer
rFile,strpointer dir, string bStr, string lStr, string rStr)
parameters: string pointers representing the three tree data files,
the directory name that the files are located in, and the names of the three
tree files.
returns: the full path of the three tree files pointed to by
bFile, lFile, and rFile.
task: concatenates each of the three tree files with the directory
to get the full path of the files.
void loadTreeFiles (strpointer brchFile, strpointer
lvsFile, strpointer rtsFile, bool fileSelected, bool fileFirst, FL_OBJECT
*fileBox)
parameters: the full paths of the three tree files, a boolean
describing whether or not a tree file has been selected for this tree, a boolean
describing if this is the first tree file that has been loaded for the tree, and
the form box object for the tree file that has been selected (either
tree1Box or tree2Box)
returns: nothing
task: if a file has been selected, the three tree file names are
read in from the *.eco file along with the sun vector for the tree, the minimum
and maximum leaf and root attribute values are determined (if the leaf type is
not NORMAL or if the root type is not NORMAL or DOUBLE), the tree files are
loaded with a call to loadSubFiles, the tree variables are adjusted to
indicate that the branches, leaves, and roots have been change (so when the user
presses the update button, all three sections will be redrawn), and the name of
the tree file (*.eco) that was choosen is placed in the file box for either
Tree 1 or Tree 2 on the form.
main Module
Contains the main program function.
View the code.
void main ()
parameters: none
returns: nothing
task: sets up the interface form by calling
create_ECOPHYS_form and by setting up a few form settings, and runs the
main loop for the program, only terminating when the exitButton object on
the interface form is pressed.
Next: The Interface
Main Page
Contents
Author : Jennifer Messel,
jmessel1@d.umn.edu