CS 101.3
Spring 2002
Homework 1 – Consistency checks for Mesh Simplification
This homework is intended to introduce you to Qt and the OpenMesh data structure. It is also intended to be the first half of a mesh simplification program. You will implement the consistency checks used to guarantee that an edge collapse is a legal simplification of a manifold mesh and a mesh decimation routine based on edge length. Please download the base program from: http://www.cs.caltech.edu/courses/cs101.3/cs101_files/homework/hw1/QtViewStart.tar.gz
Unzip the program and compile it with the command: acgmake (ACGMake is a makefile tool installed on ugcs, configured to work with OpenMesh – you are welcome to write a traditional Makefile, however, acgmake is configured to include all the necessary dependencies and is the recommended way of compiling code which uses OpenMesh for more information about it see the OpenMesh documentation pages off of the course resourses page). This will create a directory Linux_dbg. Execute the program meshviewer in this directory – this will open a Qt window with an OpenGL display buffer. To load a mesh, meshviewer takes a command line argument of the input mesh file (i.e. meshviewer Data/bunny.off). This will open a window with the bunny mesh opened and read into the OpenMesh data structure and displayed in the QtApp window. Use the left mouse button to rotate the model in the window. Use the right mouse button to get a drop down menu with various shading methods (the default is wireframe).
You will be using these base files to complete the first assignment. Most of your changes will go into Deci.cc (the decimator class) – look for the comment “Insert Code”. You will also need to make changes to QGLViewerWidget.cc and possibly MeshViewerWidget.cc in order to improve the user interface.
This homework consists of four sections:
1)
Improve the user interface of the application using Qt
-Add a drop down menu from the window to quit the program
-Add a text box to enter the target number of vertices to simplify the mesh and
a button or drop down menu option to begin simplification
-Finally add an option to write out your simplified mesh
(You will also need to have all of these gui events trigger the appropriate
functions in your program).
2) Write a check to make sure that a triangle is not “flipped” after an edge collapse.
3) Write a check to make sure that an edge collapse does not cause the mesh to be non-manifold.
4) Write a function to simplify the mesh based on edge length (ie collapse the shortest legal edges first, until you reach the desired mesh size) using a priority queue (sorted on edge length), only collapsing legal edges.
Each of these requirements (1-4) is worth 25 points each (100 total). Your finished program will be tested on a variety of input (which will be available for you to test your program) and results will be compared against baseline results.
We encourage you to explore the available functions provided with OpenMesh (check out the headers in /usr/ug/include/OpenMesh) and we encourage you to use the collapse function provided by the library, however, you are not allowed to use consistency check functions provided in OpenMesh (i.e. is_flip_ok, etc.). We have decided to provide this mesh library to allow you to quickly build a cool mesh simplification program, but we want you to understand and write the assigned work.
Another good introductory function to write for triangle meshes is a smoothing operator (which moves a vertex to the centroid of its 1-ring neighbors). This function is discussed in the OpenMesh tutorial and is good practice for iterating around a vertex’s 1-ring and repositioning vertices. It is also a handy function to add to your application, as it is common to smooth a mesh to improve its appearance.
To help you debug your program we strongly urge that you include visual debugging aids right from the start. Experience shows that graphics programs are very hard to debug if all you have the debugger, staring at different pointers. Experience also shows that adding visual debugging aids later, when you discover that you REALLY need them, is too much of a bear. So do it from the start (absolutely no whining allowed later on this particular point). Here is a suggestion as to what might be useful debugging aids in this assignment:
- use some input method (tapping on the space bar?) to do edge collapses one at a time. For a given edge collapse your program is about to do, render the mesh with the associated edges and triangles drawn in a different color. This will let you examine the particular topological configuration of the edge you are about to collapse just before your program core dumps...
- even better: implement picking with the mouse so that you may select a specific edge to be collapsed. This is useful to pick particular configurations to check that your checks check correctly. :)
- implementing picking is going to be super useful down the line. For example, this can be used to trigger a print event to some message window which you can then use to print all manner of diagnostics associated with some troublesome case in your program.
And the MOST important thing: start with small input files!!! What happens if you load a tetrahedron? What about an icosahedron? If worst comes to worst, you can actually step through execution for something as simple as an icosahedron step by step and check each step of your program by hand. What happens to your program if you give it an
icosahedron with one triangle removed?
The importance of starting with deliberately designed small test files cannot be overstated. Good luck and have fun (GUI embellishments, i.e. color and design are welcome).