next up previous contents
Next: The .elev File Up: Program Execution & Data Previous: Program Execution & Data
Go to: SmartForest Home Printer-friendly: sf-impl.pdf

main()

main() is located in the file named g.c. It performs the following sequence of operations:

  1. The random number generator is seeded with the process identifier.
  2. Process the optional command-line arguments.
  3. Several X Windows arguments are prepared to create the main window. When the arguments are ready, the main X Windows application window is created. Note that the window's contents are not yet drawn.
  4. The mapping between events and callbacks is established.
  5. Initialize the data elements in the legend and in the stand legend.
  6. The Data Preferences file is loaded. The file name is sf.prf where the directory is relative to the directory where SmartForest is run. The subdirectory may be overridden by setting the SMARTFOREST_APPDIR environment variable. Only the directory may be overridden. The file's name (sf.prf) may not be overridden. (This should be changed so that this file is handled consistently with the other files.)
  7. Determine the size of datamap's and standDatamap's entries. Update each entry's length field with the size.
  8. The .elev file is parsed. See Section 4.2.2.
  9. The .trl file is parsed. See Section 4.2.3.
  10. The .slf file is parsed. See Section 4.2.4.
  11. The default image file name that is used when the user selects File-Save Image As is set to ./ImageFiles/default.jpg. The directory may be overridden by setting the SMARTFOREST_PROJDIR environment variable. Again, only the subdirectory may be overridden. The file name, default.jpg, may not be overridden at initialization time. However, this file name may be overridden in the dialog box that appears when the user selects File-Save Image As. (This should be changed so that this file is handled consistently with the other files.)
  12. The .stnd file is parsed. See Section 4.2.5.
  13. The headers of the .elev and .stnd files should be identical for SmartForest to run properly. Verify that they are the same.
  14. The normals data structure is initialized. According to the comment in the function initialize_normals(), these values are used to ``compute where the person stands when they are in the middle of a dem grid...Initially, map$[a][b]$ is the $(x, y, z)$ position in space of the DEM sample at $(a, b)$.'' The map structure is initialized when the .elev file is parsed, above. See Section 4.2.2. ``[We] later mangle map$[a][b][0]$ and map$[a][b][1]$, but leave map$[a][b][2]$ alone, using it as the height of each DEM sample.

  15. The colors that are used to draw the ground, water, roads, fields, trees and tree stems are initialized. Each of these is implemented as a two-dimensional array: the first dimension varies the color based on the height of the object and the second dimension represents the RGB values at that height.

  16. If the user specified -installc as a command-line option, then a private color map is used for the application. Note that this command-line option is currently not permitted as our check for the number of arguments only allows for the data file names.

  17. The contents of the windows are finally drawn.

  18. Initialize the map message and the stand message. These show the current mode of the map and the stand, respectively.

  19. A remote-procedure-call server is initialized (AIX only).

  20. Finally, XtAppMainLoop is called and main() terminates.


next up previous contents
Next: The .elev File Up: Program Execution & Data Previous: Program Execution & Data
Matthew S. Davis
2002-08-07