Assignment 2 - Clipping Algorithms
CS5600 - Introduction to Computer Graphics
Due Tuesday, 21 February 2006, 23:59 hours
Overview
This lab assignment is to implement line and polygon clipping. Using line and
polygon clipping algorithms you will determine starting and ending
points of lines. For this assignment, you may use OpenGL to draw points or
lines but for no other purposes. There is a new template file provided
for you that demonstrates how to use openGL to draw points and lines, as well
as data structures (std:vectors) for storing collections of lines and points,
and functions to draw these collections. You are welcome to use the template
as is, or modify it however you see fit.
Project Requirements
The following are requirements for the project.
- Line Clipping: Specify the start and end points of a
line using the mouse or user interface. There should be an option to draw the
line clipped to a clipping rectangle, or the entire line visible on the
screen. Use the Cohen-Sutherland Line-Clipping Algorithm.
- Polygon Clippping: Construct a polygon of an arbitrary
number of vertices by clicking the mouse on the screen, or specifying via GUI,
and connecting the points into a continuous polygon. There should be an option
to draw the entire polygon, or the polygon clipped to a clipping
rectangle. Only the border of the polygon needs to be drawn. Use the
Sutherland-Hodgeman Polygon-Clipping Algorithm.
- Clipping Rectangle: Allow the user to specify a
clipping rectangle. This can be a mouse-click mode or some sort of numeric
input. There should be an option that allows the user to hide the clipping
rectangle or draw its boundary. The rectangle should be drawn in a color other
than that used for the clipped lines or polygon.
- Misc User Interface: The interface for this assignment is more
complicated than the last. Create an intuitive user interface that allows
line, polygon and clipping rectangle input and display options. This interface
should allow independent control of lines, polygons, and the clipping
rectange. In addition, the user should be provided with a way to clear the
screen and start over.
- Documentation: Briefly describe the overall structure
of the program, what difficulties you experienced while writing the
program, and known bugs. Please explain how to use the user interface. In
addition, tell us how long it took you to finish the assignment, what part of
the assignment you found most or least difficult, and any other feedback you
would like to share.
- Extra Credit:
- Make the above polygon solid. For polygon
filling, you may assume the polygon contains no slivers.
- Clip non-convex polygons correctly.
Turn in all your code and documentation using submit into the
directory called assign2Linux for Linux assignments or
assign2Windows for windows assignments (i.e. submit cs5600
assign2OS file1 file2...). Your code should be written in
C/C++, however you may choose to develop on Windows or Linux. Be sure to hand
in your MSVC project or your Makefile and that there are no problems running
your code.
Resources
There is a new Makefile and template file
that demonstrates the use of FLTK with openGL to draw lines.
NEW! MSVC
Project
FYI: Vectors
The given template file uses std:vector which is a dynamic vector used to store
lines and points. Please refer to the class webpage for a link to the C++
Standard Template Library for further explanation of vectors. The template
file has basic vector function calls that should enable you to use this data
structure effectively.