Program: 70884
Project: 70884
Buggy source:
void drawFacesRaw(GLRenderer renderer,GL2 gl,RenderProps props,Material faceMaterial){
  boolean useVertexColors=useVertexColouring;
  if (renderer.isSelecting()) {
    useVertexColors=false;
  }
  int type=-1;
  int lastType=-1;
  boolean lastSelected=false;
  int i=0;
  for (  FaceComponent fc : this) {
    if (fc.getRenderProps() == null) {
      Face face=fc.getFace();
      if (face.isTriangle()) {
        type=0;
      }
 else       if (face.numEdges() == 4) {
        type=1;
      }
 else {
        type=2;
      }
      if (renderer.isSelecting()) {
        renderer.beginSelectionQuery(i);
      }
 else {
        if (fc.isSelected() && !lastSelected) {
          renderer.updateMaterial(props,renderer.getSelectionMaterial(),true);
          lastSelected=true;
        }
 else         if (!fc.isSelected() && lastSelected) {
          renderer.updateMaterial(props,faceMaterial,false);
          lastSelected=false;
        }
      }
      if (lastType == -1) {
switch (type) {
case 0:
          gl.glBegin(GL2.GL_TRIANGLES);
        break;
case 1:
      gl.glBegin(GL2.GL_QUADS);
    break;
default :
  gl.glBegin(GL2.GL_POLYGON);
}
}
 else if (type == 0 && lastType != 0) {
gl.glEnd();
gl.glBegin(GL2.GL_TRIANGLES);
}
 else if (type == 1 && lastType != 1) {
gl.glEnd();
gl.glBegin(GL2.GL_QUADS);
}
 else if (type == 2 && lastType != 2) {
gl.glEnd();
gl.glBegin(GL2.GL_POLYGON);
}
Vector3d faceNrm=face.getNormal();
gl.glNormal3d(faceNrm.x,faceNrm.y,faceNrm.z);
HalfEdge he=face.firstHalfEdge();
do {
Vertex3d vtx=he.head;
Point3d pnt=vtx.myRenderPnt;
if (useVertexColors) {
float[] color=he.head.getColorArray();
gl.glColor4f(color[0],color[1],color[2],color[3]);
}
gl.glVertex3d(pnt.x,pnt.y,pnt.z);
he=he.getNext();
}
 while (he != face.firstHalfEdge());
if (renderer.isSelecting()) {
gl.glEnd();
renderer.endSelectionQuery();
lastType=-1;
}
 else {
lastType=type;
}
}
i++;
}
if (lastType != -1) {
gl.glEnd();
}
}

Fixed version (ground truth):
void drawFacesRaw(GLRenderer renderer,GL2 gl,RenderProps props,Material faceMaterial){
  boolean useVertexColors=useVertexColouring;
  if (renderer.isSelecting()) {
    useVertexColors=false;
  }
  int type=-1;
  int lastType=-1;
  boolean lastSelected=false;
  int i=0;
  for (  FaceComponent fc : this) {
    if (fc.getRenderProps() == null) {
      Face face=fc.getFace();
      if (face.isTriangle()) {
        type=0;
      }
 else       if (face.numEdges() == 4) {
        type=1;
      }
 else {
        type=2;
      }
      if (renderer.isSelecting()) {
        renderer.beginSelectionQuery(i);
      }
 else {
        if (fc.isSelected() && !lastSelected) {
          renderer.updateMaterial(props,renderer.getSelectionMaterial(),true);
          lastSelected=true;
        }
 else         if (!fc.isSelected() && lastSelected) {
          renderer.updateMaterial(props,faceMaterial,false);
          lastSelected=false;
        }
      }
      if (lastType == -1) {
switch (type) {
case 0:
          gl.glBegin(GL2.GL_TRIANGLES);
        break;
case 1:
      gl.glBegin(GL2.GL_QUADS);
    break;
default :
  gl.glBegin(GL2.GL_POLYGON);
}
}
 else if (type == 0 && lastType != 0) {
gl.glEnd();
gl.glBegin(GL2.GL_TRIANGLES);
}
 else if (type == 1 && lastType != 1) {
gl.glEnd();
gl.glBegin(GL2.GL_QUADS);
}
 else if (type == 2 && lastType != 2) {
gl.glEnd();
gl.glBegin(GL2.GL_POLYGON);
}
Vector3d faceNrm=face.getNormal();
gl.glNormal3d(faceNrm.x,faceNrm.y,faceNrm.z);
HalfEdge he=face.firstHalfEdge();
do {
Vertex3d vtx=he.head;
Point3d pnt=vtx.myRenderPnt;
if (useVertexColors) {
float[] color=he.head.getColorArray();
gl.glColor4f(color[0],color[1],color[2],color[3]);
}
gl.glVertex3d(pnt.x,pnt.y,pnt.z);
he=he.getNext();
}
 while (he != face.firstHalfEdge());
if (renderer.isSelecting()) {
gl.glEnd();
renderer.endSelectionQuery();
lastType=-1;
}
 else {
lastType=type;
}
}
++i;
}
if (lastType != -1) {
gl.glEnd();
}
}