[Bowdoin Computer Science]

Project 3: Contour lines

Due: May 19th

The goal of this project is to develop a tool for computing and displaying contour lines on terrains. This tool will allow the user to load a terrain, specify the contour lines wanted and visualize the resulting contour lines rendered on top of the terrain.

Ideally your program would work for both grids and triagulations (as output by your terrain simplification project).

Interface: The interface is open-ended. One possibility is to have a loadgrid command that loads a grid and displays it. And a contour line computation command contours that displays the desired contours.

Specifying the contour lines: the user should be able to specify either a particular elevation, or a certain number of contour lines. Iff the user specifies a specific elevation, your program chould compute and render the corresponding contour line. If the user specifies a number of contour lines, say n, then your program should find out the corresponding elevations by dividing the range of the terrain into n intervals and compute and render the corresponding contour lines at those elevations.

Here is an example:

lynx20: > myGIS
myGIS> loadgrid set1.asc
..Loading set1.asc
myGIS> contours elev=100.3
..computing contour lines for set1.asc at elevation 100.3 
myGIS>  contours num=5
..computing contour lines for set1.asc at elevation 10.2 40.2 70.2 100.2 130.2
myGIS> exit
..Bye. 
lynx20: > 

Contour lines: Start by implementing the brute-force approach: walk through the list of triangles, compute the z-span of each triangle, decide whether it intersects the contour plane, find the two adges that two, compute the intersection points, and send the segment of the contour line to a list.

One you got your brute-force approach to work, you'll hopefully feel motivated to improve on it. Use the interval-tree to store the z-spans of triangles, as discussed in class. You'll have to write a function tha builds an interval tree; it is easy to make it recursive, but you don't need to. Given the interval tree, use it to figure out fast what are the triangles that intersect the given height. You could write a function

stabbingQuery(ITree * it, height h)
that computes all the triangles whose z-span contains h.

To refresh your memory on interval trees and contour lines read the following:

What to turn in: Make a directory called Contours-yourname, put all your code there (clean it up beforehands), and copy it into the Projects folder in the class space. In the same folder also include a brief writeup describing your project. The writeup should include a summary of the functionality of your code, the overall outline of the algorithm, the data structures you chose, and some discussion on what was the most difficult part of the project.