Addr: Terrain Scene Gr Paged Ob Navigati Nav

Addr: Terrain Scene Gr Paged Ob Navigati Nav

<p>Project 1: MSVS 2005, C++, Pointers, Memory Allocation</p><p>ITCS x120 Computer Graphics Fall 2008 Revision 1.4 Professor Zachary Wartell</p><p>Last Modified: 1/19/2018 12:56:59 PM</p><p>Copyright August 2006, Zachary Wartell @ University of North Carolina at Charlotte All Rights Reserved.</p><p>Due Date: Part I: Wednesday September 24, 2008 11:59PM. Part II: Wednesday October 1, 2008 11:59PM.</p><p>1. Overview </p><p>Project 1 involves:  Working through a tutorial on SVN  Working through a tutorial on Microsoft Visual Studio 2005 (MSVS 2005)  Working through a tutorial on one of two memory leak detection tools  Writing a C++ program</p><p>The overall purpose is for students to familiarize themselves with MSVS 2005 as much as possible and to acquaint themselves with C++ and programming with pointers (including function pointers), dynamic memory allocation, etc. </p><p>Review the class syllabus regarding the basic requirements for getting full and partial credit for your programming assignments [1].</p><p>2. Part I: “Hello World”</p><p>From the class website [1] get the file:</p><p>SVN for ITCS 4120-5120.doc and read the listed chapters in the SVN manual and the tutorial. There is no deliverables for this tutorial.</p><p>From the class website [1] get the file:</p><p>“ C++ and MSVS 2005--A Tutorial and Guide to further Reading.doc” The above document has multiple deliverables in addition to reading. By and large these deliverables are about making modifications to C++ code and turning those modifications and turning answers to various questions.</p><p>3. Part II: Simple File Parser</p><p>For Part II you will write a (non-graphical) program in C++. Skeleton code for this project is provided in your SVN repository directory under:</p><p>‘Project 1/ITCS 4120 – Tree’</p><p>Use this skeleton code. Also you must link with the VLD library discussed in the tutorial above. The distributed compilation scripts already do this for you.</p><p>For Part II you will write a (non-graphical) program that reads in a text file describing a tree data structure and then prints out the tree using a pre-order traversal of the tree and performs some computational operation as each node in the tree is visited. (If necessary, brush up on tree traversal [3] from your data structures and/or algorithms course. Recall, ‘pre-order’ means you visit/operate on the current node before visiting/operating on its children). The program will construct, traverse, and destruct the tree using recursive function calls. The program will dynamically allocate and deallocate nodes in the tree using C++ new and delete. Each node in the tree can have a different number of child nodes.</p><p>Your program should include the following classes and functions:</p><p>/** \brief 'Tree' is a simple Tree class */ class Tree { public: /** NodeVisitFunction is a function pointer type */ typedef void (*NodeVisitFunction) (Tree*);</p><p> public: Tree(); ~Tree();</p><p> void traversePreOrder (NodeVisitFunction nvf); void load(std::fstream& file);</p><p>/** a text name for this node */ std::string name;</p><p>… further details removed, see Tree.h … };</p><p>/** \brief prints the message "Hello <NAME>", where <NAME> is the name of the Tree node 't' */ void SayHello(Tree*t);</p><p>/** \brief prints the message "Goodbye <NAME>", where <NAME> is the name of the Tree node 't' */ void SayGoodbye(Tree*t); Your program should assume the text file that describes the tree(s) is called “Tree.txt”. “Tree.txt” may describe one or more trees. Your program should allocate, create, print and then deallocate each of the trees described in the Tree.txt file. If Tree.txt contains multiple trees each tree should be processed separately and the Tree data structure should be completely deallocated after each tree is processed. The contents of each tree should be printed twice by the pre-order traversal of the tree nodes. The first traversal should print the message “Hello <NAME>” on a separate line for each node in the tree, where <NAME> is the name of the tree node. The second traversal should print the message “Goodbye <NAME>” on a separate line for each node in the tree. These traversals and printouts should be implemented using the ‘traversePreOrder’ member function which takes a pointer to the ‘SayHello’ or ‘SayGoodbye’ function. These latter two functions just print the appropriate message for a single node. The purpose here is to implement and use a simple function pointer callback mechanism.</p><p>The input file format grammar is as follows. In this grammar, a | separates different options; * denotes 0 or more repetitions of a terminal or non-terminal symbol.</p><p>FILE := TREE* TREE := { STRING_NAME TREE* } STRING_NAME := this is a string made of only letters, numbers or the _ character</p><p>For example the following is a valid file (The SVN checkout includes other examples as well). Note, all whitespace (space, tabs, newlines) are treated the same in the grammer as in any normal programming language. </p><p>The example below contains 4 trees:</p><p>{ ROOT } { ROOT { FRED } } { ROOT { FRED { FRED_JUNIOR1 } { FRED_JUNIOR2} } } { ROOT { FRED { FRED_JUNIOR1} { FRED_JUNIOR2} } { BARNEY { BARNEY_JUNIOR1} { BARNEY_JUNIOR2} } }</p><p>Hints:  Useful C++ functions for parsing: isspace, isalnum, etc., fstream.get(),fstream.peek()  The simplest way to parse this file’s grammar is using a recursive descent parser. Hopefully stuff you’ve seen in programming languages, or compilers or automata theory courses or see [4] (Note, the example in [4] is 10 times more complicated than what you need here).</p><p>4. Citations</p><p>[1] http://www.cs.uncc.edu/~zwartell/ITCS 4120-5120/current/web page/ITCS 4120 - Wartell.html . ITCS 4120/5120, Zachary Wartell. [2] Zachary Wartell, “C++ and MSVS 2005--A Tutorial and Guide to further Reading.doc” [3] Tree Traversal http://en.wikipedia.org/wiki/Tree_traversal [4] Recursive descent parser. http://en.wikipedia.org/wiki/Recursive_descent_parser </p><p>5. Appendix I: Grading Instructions</p><p>As always, see syllabus regarding partial credit.</p><p>Total is out of 100 pts.</p><p>Part I: Sub-total is 25% (.25) of Project Grade Each subpart is 0.50 of the Part 1’s subgrade</p><p>Part II: Sub-total is 75% (0.75) of Project 1 Grade.</p><p>Then further break down is as follows [.xx] means the associate portion of the assignment is worth xx percent of the total sub-grade.</p><p>1) [.15] File Parsing – program reads the specified input file format 2) [.42] Tree Data Structure a. [.42*.33] tree structure uses pointers for parent & child nodes and supports varying number of child nodes per node b. [.42*.33] tree structure is dynamically allocated when built from input file c. [.42*.34] tree structure is deallocated after print out and before reading next tree. 3) [.43] Print out a. [.43*.20] tree is printed out appropriately b. [.43*.40] callbacks i. traversal uses 2 different callback functions ii. traversal function executes callback function as it visits each node c. [.43*.40] traversal is done recursively</p><p>6. Appendix II: History</p><p>Revision 1.1 – -Fixed typo in ‘Tree** children’ data member (Tree* children made no sense). -clarified that each node in the tree can have a different number of child nodes. -removed pile of junk accidentally pasted into this document Revision 1.4 - too tedious to maintain this… see SVN log</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us