May 02 Assignment 3 has been postponed to Friday, May 2.

CAP 6701 - Advanced Computer Graphics


Always check here to see if your question has already been answered before sending an e-mail to the TA or the professor.

Problem: Important!!!

I did some operation on my PolygonMesh object that modified the connectivity (i.e. added/removed vertices/edges/faces). Then, using my already existing handle/iterator/circulator gave me a segfault, core dump, or some other pointer exception. What's going on?


Why this happens: PolygonMesh internally tracks a vertex/edge/face list that can be stored as a linked list, an array, or any other container. The handle/iterator/circulator classes encapsulate (and behave like) a pointer into these data structures. The problem occurs, for example, if the default container data structure is an array. If you add a new vertex to the end of an array and the array doesn't have enough space, then it has to be reallocated and copied. Unfortunately, reallocation invalidates any existing pointers into the array.

How to avoid this problem: The key to solving this problem is to reserve() enough space in the PolygonMesh before creating any handles/iterators/circulators that may need to be used after adding new vertices/halfedges/facets. In this way, you know that the underlying data structure will not need to be reallocated while you are adding stuff to it. The function that does this is PolygonMesh::reserve(numVertices, numHalfedges, numFaces) and is documented in the CGAL class reference for Polyhedron_3.


I tried to add a member to PolygonMesh_vertex:
class PolygonMesh_vertex : public CGAL::HalfedgeDS_vertex_base< Refs, CGAL::Tag_true, P> {
        int x;
But vi->x = 3 resulted in an error stating that x is in a read-only structure.


vi may be a Vertex_const_handle or Vertex_const_iterator. Instead, it should be a Vertex_handle or Vertex_iterator.