CS 242 Fall 2010 : Assignment 3.1
CS 242 Fall 2010 : Assignment 3.1
This page last changed on Oct 20, 2010 by cemeyer2.
You will be given a file of data. This file is a formatted set of data and data graphics transformation operations. This data file would be interpreted by a real-time system meant to display the items in the display list.
You are welcome to use whichever C development environment you prefer.
For the Mac, we recommend that you use either Apple’s Xcode, which is free if you register
For Windows, we recommend you use either Visual Studio 2010 or Dev-C++. VS is free from the web store for engineers (http://webstore.illinois.edu click on the departments tab once you login).
For Linux, we recommend using Eclipse with CDT, installed using the same method mentioned above for Mac. Before you install the CDT or download the C/C++ version of eclipse, make sure you have all the necessary build tools installed on your machine first, since it will allow eclipse to autoconfigure itself rather than you doing it manually after the fact. To install the necesary files on popular distributions:
The data file will be composed of a header region followed by a data region The header region is contains two header blocks, and the data region contains a number of data blocks. Each data block represents either data coordinates, and transformations to be applied to data coordinates.
You must authenticate the file and successively trace through each data block.
The header region contains an authentication block followed by an offset table block.
The offsets contained in the table in the header are used to locate the start of the data blocks within the data region. Each offset represents the number of bytes after the end of the authentication block to the start the offset data block. The data blocks may or may not occur in memory in the order that their offsets occur.
A sequence of data blocks referenced from an offset is completed when you encounter a data return block.
Following the header block is the data region containing the data blocks.
Below are the byte formats of the possible data blocks. Each block begins with a one byte record id which determines its type:
A centroid sets the context for subsequent coordinates; i.e. coordinates are are offset relative to the current centroid stack. When you output coordinates, you should always output their absolute coordinates. If the same set of coordinated are “called” after a different centroid, you will output a different set of absolute coordinates. Whenever you encounter a new centroid it replaced the previous one.
If there were 4 successive calls to a set of coordinates you would output those coordinates 4 separate times.
Each list of 3D coordinates represent the raw data. Each coordinate is always relative to the current centroid.
When you encounter a scaling factor, you scale relative coordinates by shifting them left by the indicated number of bits. For example, a scaling factor of 5 will result in all x, y, and z coordinates to be shifted left 5 bits. Beware of shifting a coordinate value and causing an unintended overflow.
This operation jumps the trace to the data block at the specified offset. When a data return occurs, you must be able to return to the following data block.
As with the previous operation, this operation jumps to the data block at the specified offset. However, it also causes a rotational transformation on the subsequent coordinates. When a data return occurs, it undoes the current rotational transformation, and returns like the previous operation. New rotation calls build upon previous rotation calls, so you must be able to handle the stacked rotational contexts.
The data return pops your trace back to the position in the data block immediately following the previous call.
If there are no other return addresses on the data return stack, the trace returns to next offset in the offset table block.
Ultimately, you will need to output a human readable version of the data as if you traced an entire “frame” of a simulation. Some of the interpreted instructions will branch to other locations within the data and return to continue where they had left off.
You will need to output coordinates and indications of state changes. Coordinate values must be output in hexadecimal.
You must authenticate the binary data file and successively trace through each data block in the order in which its offset appears in the table. As you trace through the file you will output the encountered centroids, graphic transformations, and the values of absolute coordinates in a human readable form.
When a call occurs, you must:
Addendum to Assignment 3
This data represents a hypothetical interpreted drawing language based on an actual drawing language. The sizes of the data elements are intentionally unrealistic to force dealing with unusual data types.
What kind of human-readable output would be useful for data of this type? There are two straightforward types of textual output that could be useful. One could output a “disassembly” form of text or one could output a trace. My intention is that you write a trace. That is, follow the path for each data block as if it were a set of instructions to draw a picture.
A disassembly style of output could be useful for YOU if you were working with this data and needed to “see” what was actually created as opposed to what was intended by the creator of the data.
You encounter the following data just after your verification string:
02 02 0e 00 94 00 a1 00 ae 00 1c 00 1e 00
This says there is a 2 x 2 table of 16-bit offsets (little endian) that follow. This means that there are a total of four blocks of data at offsets: 000e, 0094, 00a1, 00ae. These offsets are from the start of the table where the dimensions of the table are.
At the beginning of one of these data block you encounter:
01 00 00 00 0f 00 00 00 00 00 00 00 0e 00 0b 00 01 f0 00 0f
The 01 represents a “locus” with scaling factor of 0 and x,y,z = (0xf0000, 0, 0xe0000), followed by 0x0b which is a call to an offset of 0x100 (offset relative to the 0x0b) with a rotation angle of 0xf0 (which is measured clockwise from north on a range from 0 – 65536) followed by 0x0f (return from the data block).
What kind of output would be useful?
Locus sf, x,y,z (using actually values)
When you encounter coordinate definitions, it could be useful to output their raw coordinates followed by their transformed coordinates. The transformed coordinates are coordinates AFTER scaling, after rotating and after the locus. You must at least output their transformed coordinates.
Write specifications for a library of C functions that you will use to complete this assignment. You will give those specifications to your contractor in the form of comments describing the functionality you want and function “stubs”. A stub is the first line of the function declaration indicating the arguments and their order as well as the return type. In C these stubs are known as function prototypes. Your comments must be Doxygen compliant. Your commented prototype functions should be composed into a single valid .h header file.
You will receive specifications from another student (your customer), and act as their contractor. Your customer and contractor should not be the same person.
In discussion section, as the customer, you will present your specification, and then pass it to your contractor. Acting as a contractor, be prepared to review your customer’s specification. During Assignment 3.2, you will act as a contractor to implement your customer’s specification. The second week you will present the code of your contractor.
Remember, one of the core goals of this course is to learn the power of small, focused and well-named functions and methods. You should specify functions that would be both necessary and useful to process the data file, such as:
You must write complete unit tests for this part of the assignment. This is analogous to what we asked you to do for assignment 1.1. You are free to use any unit test framework you wish, or just use assert statements in your code. Assignment 3.2 will require your contractor to implement your specification such that your unit tests all pass. It is profoundly in your best interest to write complete and thorough unit tests so that the amount of work you will have to do for assignment 3.3 will be minimized.
|Document generated by Confluence on Feb 22, 2012 18:13|