Homework 3
DUE: Dec 4, 2001
THIS SECTION CONTAINS INFORMATION POSTED AFTER ORIGINAL HANDOUT |
---|
(0) Solutions from two groups: Gleyzer | Xing Xia |
(1) For Stage B, there is an alternative data structure that
can be used, based on our lecture on "Window Queries".
We introduced three problems, the first two of which
are (I) Orthogonal Range Queries and
(II) Intersecting a vertical query segment with a set of
horizontal segments. Using these, you can retrieve
all the necessary TLines (viewed as bounding boxs).
N.B. Replacing a TLine by its bounding box may retrieve
some spurious TLines, but this effect only occurs at the
four corners of the query window, so it is not serious.
But this solution does seem practical: you would need to construct three search structures: D1 for orthogonal range queries, and D2 and D3 for two versions of problem (II). D2 and D3 corresponds to querying the horizontal segments and vertical segments, respectively. We next describe a simplification, which you can implement.
|
(2)
The simplification is simply to construct D1 but skip D2 and D3.
Why is this justified?
The only TLines we might miss if we do not have D2 and D3 are
those that are long enough to cross the query window entirely!
This will not happen if we make sure that our query windows
are always longer the the longest sides of bounding boxes.
Hence, if a query window is too small, we artificially increase
it to this longest side length.
|
We continue to put more pieces together for our final project. This is split into 4 parts:
(a) Create a map of all the counties in the USA. Construct a simple program that can display this information and also support zooming and panning, as in hw1.
(b) Construct range-retrieval data structure for the map in (a): for any rectangle on the map, you need to retrieve all the TLines that intersect that rectangle.
(c) Use (b) to improve on the panning and zooming method in (a). E.g., in panning, you only retrieve those lines that are new in the image, and only redraw those. The previous image that is already on the screen should simply be copied as pixels.
(d) Transform your solution in (c) into a server-client program. Commands that the server sends are (x,y,w,h) information. The client in this solution need only store a limited amount of information from the recent past.
(i) First we want to construct a map for all the 3000+ counties in the whole USA. Fortunately, Yunyue has already much of this work for us - go to the TIGER RESOURCE webpage in our visualization project home, and click Yunyue's boundary page.
(ii) We will also need a fairly small pixel image of the overall map. Call this the ``iconic'' image. We suggest that you draw the above map into a buffer, and save this image. The program pan.cc in Lecture 10 allows you to do this (in BMP format).
(iii) We want you to process the above map into a half-edge data structure (the Subdivision class of hw2).
(iv) Now display both the iconic image in a navigation subwindow and the main map in a larger viewing subwindow. The display in the viewing window is determined by a current zoom level and a current position. This information should be represented by a rectangle of the appropriate size in the navigation window.
(v) The user can issue three kinds of commands: zoom, pan and jump. Zoom is achieved by pressing the keys 'i' (zoom in) or 'o' (zoom out). Panning is achieved by dragging the mouse in the viewing subwindow. Jumping is achieved by mouse clicks in the navigation window - it causes the current position to jump to the new position.
REMARK: at this point, you can do a naive panning and zooming (just redraw everything, whether the line will show up on the screen or not). This can be slow, but we will improve it below. Note that your solution in hw1 and hw2 can be reused.
There are data structures for range retrieval. However, because of our half-edge data structure, we only need to solve the simpler problem of point location.
Suppose you want to retrieve all the TLines that intersect a give rectangle with corners (A, B, C, D). We simply do point location on point A, say. This locates the county containing A. Then we "walk" along a straight line from A to towards B. As we walk, we collect a list of all TLines whose bounding box intersects AB. [Note that this is conservative because it is possible that we may collect some spurious TLines that does not intersect AB.] Now, from this list of TLines, we ``sweep'' the edge AB towards the DC, adding more TLines to our list. Encode this as the method TList TigerSubdiv::retrieveLines(left, right, top, bot) which returns an object of type TList (i.e., a list of TLines). To test this, write a main program that reads mouse input position on the image (based on Stage A) and prints on the screen the list of Tlines.
Exploit the retrieveLines() method in Stage B to improve the performance of your program in Stage A. When panning, you first copy the parts of of your current buffer that can be re-used to the back buffer. Then you use retrieveLines() to get the new data, and draw them on the back buffer. Then you swap buffer. The programs pixmap.cc and pan.cc in Lecture 10 should be useful for code base.
Modify your solution in Stage C into a networking solution. Your server basically accepts commands of the form retrieveLines(l, r, t, b) as in Stage B. Your client has only limited memory (it should just remember a few of the last retrievals, and avoids asking for information from the server which it already has. The client-server programs are meant to be simple! The programs client.c and server.c in Lecture 9 is useful as the code base.
Please review the instructions found in Homework 1.
In particular, there should be a Makefile that contains the targets ä", "testa", "b", "testb", etc. I should be able to type "make a" to compile, and 'make testa" to get run and test your solution for Stage A. Similar for Stage B, etc.
To help my grading of your programs, you MUST use the Makefile in pan.cc as a model. That is because I need to test your code in various environments, as encoded in that file. DO NOT DELETE THE SETTINGS THAT ARE THERE: just add your modification AFTER the settings I use. For instance, if you want want to define the library searchy directory to LIBS = -LC:\WINNT\myownlib then simply add this line after my settings.
VERY IMPORTANT: I need a README file that carefully describes what you have done, how the various programs are related to each other, etc. Mention any interesting features of your work. Mention any quirks or difficulties or bugs.