Example #1
0
void keyfun(unsigned char c, int x, int y)
{
	/*
	 * A little game, try to flip an edge when user presses any key.
	 * Not all edges can be flipped. Boundary edges cannot. Edges also
	 * cannot be flipped if it will render the mesh invalid.
	 */

	if(boundary(m, *flipper)) // If this is a boundary edge just drop the idea.
		cout << "boundary edge" << endl;
	else if(precond_flip_edge(m, *flipper))
  {
    m.flip_edge(*flipper);
		cout << "flipped" << endl;
  }
	else
  	cout << "could not flip" << endl;

	do
		{
			++flipper; // Get the next halfedge
			// If we have passed the last halfedge, go to the first.
			if(flipper==m.halfedges_end())
				{
					flipper = m.halfedges_begin();
					break;
				}
		}
	while(touched[*flipper] == 0); // Only visit halfedges marked '1'


	// Function call below informs glut that display should be called to
	// show the window again.
	glutPostRedisplay();
}