# Exercise 6

 Number of Points 100 Due Date Friday, December 9, 2005 at 11pm

Do the following problems:

• (40 points)
Consider the following equation:

It represents a very interesting algebraic surface, where a in the equation is a positive number and the shape would be very good looking if a is between 10 and 12, inclusive. Do some trial-and-error to find the best orientation. Clipping may be necessary.

Grading Policy: You will receive 25 points if the displayed surface is correct and used properly. To receive 40 points, you must have this surface in a non-trivial scene. An extra 10 to 15 bonus points will be given to those creative designs using this interesting surface.

Please name your scene file and image file as surface.pov and surface.jpg, respectively.

• (60 points)
Design and implement a program that does the Doo-Sabin. More precisely, your program should read in an input file representing a 2-manifold polyhedron without boundary using the winged-edge data structure, carry out the Doo-Sabin subdivision algorithm, and display the result in each subdivision step.

The display of each step may be in wireframe, randomly colored faces, flat shaded faces, or smooth shaded faces. From the second subdivision step and on, the display may also include the wireframe of the previous subdivision. Here is an example. Suppose we have the following polyhedron. All faces are shown in random colors initially.

Applying Doo-Sabin algorithm once yields the following. The left image shows the result in random colors while the right image the same color for flat shading.

 Random Color Faces Flat Shaded Faces

Apply Doo-Sabin algorithm once more yields the following. Note that the wireframe in blue color shows the previous subdivision shown in the above images.

 Random Color Faces with Previous Subdivision Flat Shaded Faces with Previous Subdivision

After six subdivisions, we have the following results in random and shaded colors. Due to the very dense wireframes, they are not shown.

 Random Color Faces After 6 Steps Flat Shaded Faces After 6 Steps

Your job is to read in an input file representing a 2-manifold without boundary with the winged-edge data structure, perform Doo-Sabin subdivision, and display the result in a window. You may use any environment of the previous exercises for window display. Your program executable must be named as doo-sabin and accept one command line argument, the input file name. I will run your program in the following way for testing:

```
doo-sabin  test-file.dat

```
where test-file.dat is the name of a test file. Your program must accept the following key presses and the Exit button:

• w or W:
Display the model with wireframe.
• r or R:
Display the model with random colors.
• f or F:
Display the model with flat shading. All faces use the same color.
• s or S:
Display the model with smooth shading. All faces use the same color.
• p or P:
Display the previous subdivision in wireframe and the current results based on the current display setting (i.e., wireframe, random color, flat shading or smooth shading). The wireframe of the previous subdivision must be shown in a color different from the color used for the current subdivision. Note that at the very beginning this key press should be ignored; however, once the Right Arrow is pressed, your program should display the wireframe of the initial model.
• Left and Right Arrow Keys:
The Right Arrow moves (or executes) to the next subdivision, and the Left Arrow moves back back to the previous subdivision. As your program moves back and forth, the current display setting (i.e., wireframe, random color, flat shading, smooth shading, and wireframe for the previous subdivision) should be maintained.
• + and -Keys:
They perform the zooming in (+) and zooming out (-) operations. Make sure the zoom step should not be too drastic for me to see the displayed result well.
• The trackball rotation scheme should be available.

Submit the following materials:

1. A README file in which your effort and the logic of your scene design and your program should be presented in detail. Make sure your name and e-mail address appear in the very beginning of this file. SSN is not required.
2. e-Mail me a file Exer-6.zip that includes all files for me to regenerate your work. Please do not change the structure of the files. Just modify one of the functions in a previous sample environment would suffice. Do not change the makefiles as I will perhaps use my SGI machine for grading. I prefer a Windows version. So, please include all files and the binary executable. Some of you tar a directory in previous exercises.
3. To help you have a good start, a Windows program designed and written by Tin-Tin Yu is available in the common directory with filename subdivision.zip. After unzipping this file, you will see a Windows executable and some testing files in winged-edge data structure format.