In this assignment, you will implement a data structure to represent a triangle mesh, and use it to perform some basic mesh processing tasks. We have provided starter code at https://git.iitd.ac.in/col781-2302/a2 to interactively visualize the mesh in 3D, given its vertex data and triangle indices. Your responsibility is to work with the mesh data structure itself to create and modify meshes.
Define a mesh data structure to store the connectivity and geometry of a triangle mesh.
Further implementation choices beyond this are up to you, e.g. whether to use triangle neighbours (with or without edges) or a half-edge data structure, whether to use indices or pointers, etc.
Implement functions to create the following simple meshes, including vertex normals and all the connectivity information:
In the meshes
directory of the starter code, we have
provided a few example meshes in the OBJ file
format, a fairly self-explanatory text-based format for polygon
meshes. Write a parser that loads a mesh from such a file. You may
assume that all the polygons are triangles. Be careful about a few
things:
Implement functionality to recompute vertex normals for a given mesh. For each vertex, we can estimate the surface normal as a weighted average of the normals of adjacent triangles. You may use equal weights, or weights proportional to triangle area, though the best choice is probably the scheme derived by Nelson Max (1999) (see eq. 2) which gives exactly correct normals for vertices lying on a sphere.
The simplest way to smooth out a mesh is using the so-called “umbrella operator” \(\Delta\mathbf v_i=\frac1{|N(i)|}\sum_{j\in N(i)}(\mathbf v_j-\mathbf v_i)\), which for each vertex gives the vector from its position to the average position of its neighbours. Moving each vertex by some fraction in this direction, \(\mathbf v_i\gets\mathbf v_i+\lambda\Delta\mathbf v_i\) causes a small amount of smoothing over the mesh; repeating it multiple times leads to more and more smoothing.
Implement the three basic mesh editing operations: edge flipping, edge splitting, and edge collapse.
Also write a testing function that verifies that all the mesh connectivity information is valid. For example, check that all of a triangle’s neighbouring faces do share two vertices with it, or that a half-edge’s next edge does share the same face, etc. Try to be as comprehensive as possible, and list all the invariants you thought of and tested in your PDF report. This will help you in debugging as well!
Test all three editing operations on the diagonal of the middle square of a 3×3 grid mesh, and verify that the mesh remains valid.
If you are working in pairs, implement any one of the following high-level operations. If you are working individually, this requirement is optional but can give up to 10% extra marks.
Loop subdivision (Loop 1987) of a triangle mesh, as discussed in class.
Isotropic remeshing (Botsch and Kobbelt 2004, Sec. 4). Here you will need to apply all three remeshing operations repeatedly as discussed in class:
Carry out this cycle multiple times (about 5) to get a mesh with edge lengths close to the target.
Mesh simplification (Garland and Heckbert 1997). Here are some more details about the quadric error metric used in this paper. Briefly, for any plane \(\mathbf n^T\mathbf p-c=0\), we can define a \(4\times4\) matrix \(\mathbf K=\begin{bmatrix}\mathbf n\mathbf n^T&-c\mathbf n\\-c\mathbf n^T&c^2\end{bmatrix}\) such that the squared distance between any point and the plane is simply \((\mathbf n^T\mathbf p-c)^2=\begin{bmatrix}\mathbf p\\1\end{bmatrix}^T\mathbf K\begin{bmatrix}\mathbf p\\1\end{bmatrix}\). At each vertex, we store a matrix \(\mathbf Q\) which is the sum of the \(\mathbf K\) matrices of its adjacent faces. Then the algorithm is simple:
Submit your assignment on Moodle before midnight on the due date. Your submission should be a zip file that contains your entire source code for the assignment, not including any binary object files or executables. The zip file should also contain a PDF report that includes the screenshots of the following:
If there are any components of the assignment you could not fully implement, in the PDF you should also explain which ones they are and what problems you faced in doing them.
Separately, each of you will individually submit a short response in a separate form regarding how much you and your groupmate(s) contributed to the work in this assignment.