22C:030/115 Programming Techniques and Data Structures

Fall 1999/00

Program 3: Polylines and Bags of Polylines

DUE DATES:


This program requires you to design, implement and test two classes: Polyline and Bag of Polylines. The Polyline class represents a connected sequence of three-dimensional line segments. The Bag of Polylines will be used to store a collection of Polylines that define a scene consisting of line drawn objects. You are to write a program demonstrating your classes that generates a set of polylines approximating several mathematically defined shapes including spiral curves, sine waves, and Kock snowflakes. The assignment will give you experience in developing a clear specification from a problem statement, experience in the use of linked lists, and additional experience in software coding and testing.



 
 
 
What to submit:
You should submit a directory that includes:
  1. README: A file giving a overview of the contents of the directory including:
  2. polyline.h: The header file for the new Polyline class.
  3. polyline.template: The implementation file for the new Polyline class.
  4. bag.h: The header file for the bag of Polylines class.
  5. bag.template: The implementation file for the bag of Polylines class.
  6. polylinetest.cxx: An program that tests the Polyline class.
  7. polylinedemo.cxx: An demonstration program.
  8. polyline.dat: The output of your demonstration program including polylines approximating spirals, sine curves, a Koch snowflake.
  9. A printed copy of the files README, polyline.h, polyline.template, bag.h, bag.template, polylinetest.cxx, and, polylinedemo.cxx to be submitted in lecture on the due date.

The Polyline Class

You are to design, implement, and test a new templated class called Polyline that represents a sequence of n three-dimensional line segments connecting a series of n+1 three dimensional points. For example, the Polyline
p = ((1.0,1.0,0.0), (-1.0,1.0,0.0), (-1.0,-1.0,0.0),
                                (1.0,-1.0,0.0), (1.0,1.0,0.0)
defines four line segments that form a square in the z=0 plane centered on the origin as pictured below.

In addition to its shape, a Polyline should have a color attribute expressed by three values giving red, green, and blue components of the color. You should use the Point3D class from the first project to represent the points in a line segment.

A Polyline must be represented as a linked list of points.  You may choose to use either a singly or doubly linked list. The node structure for a singly linked list is pictured below.
 


 

Your class should include the following functions and operations: