Program: 70902
Project: 70902
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;
  ArrayList<float[]> colors=null;
  int[] colorIndices=null;
  int[] indexOffs=null;
  if (useVertexColors && size() > 0) {
    MeshBase mesh=get(0).myMesh;
    colors=mesh.getColors();
    colorIndices=mesh.getColorIndices();
    indexOffs=mesh.getFeatureIndexOffsets();
  }
  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);
int k=0;
HalfEdge he=face.firstHalfEdge();
int faceOff=indexOffs[i];
do {
Vertex3d vtx=he.head;
Point3d pnt=vtx.myRenderPnt;
if (useVertexColors) {
int cidx=colorIndices[faceOff + k];
if (cidx != -1) {
  float[] color=colors.get(cidx);
  gl.glColor4f(color[0],color[1],color[2],color[3]);
}
}
gl.glVertex3d(pnt.x,pnt.y,pnt.z);
he=he.getNext();
k++;
}
 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;
  ArrayList<float[]> colors=null;
  int[] colorIndices=null;
  int[] indexOffs=null;
  if (useVertexColors && size() > 0) {
    MeshBase mesh=get(0).myMesh;
    colors=mesh.getColors();
    colorIndices=mesh.getColorIndices();
    indexOffs=mesh.getFeatureIndexOffsets();
  }
  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);
int k=0;
HalfEdge he=face.firstHalfEdge();
do {
Vertex3d vtx=he.head;
Point3d pnt=vtx.myRenderPnt;
if (useVertexColors) {
int faceOff=indexOffs[i];
int cidx=colorIndices[faceOff + k];
if (cidx != -1) {
  float[] color=colors.get(cidx);
  gl.glColor4f(color[0],color[1],color[2],color[3]);
}
}
gl.glVertex3d(pnt.x,pnt.y,pnt.z);
he=he.getNext();
k++;
}
 while (he != face.firstHalfEdge());
if (renderer.isSelecting()) {
gl.glEnd();
renderer.endSelectionQuery();
lastType=-1;
}
 else {
lastType=type;
}
}
++i;
}
if (lastType != -1) {
gl.glEnd();
}
}