nus-yam/ex-repair huggingface dataset:
Program: 70713
Project: 70713
Buggy source:
/** 
 * Zoom in or out by a specified scale factor. A factor larger than one zooms out, while a factor less than one zooms in. In orthographic projection, zoom is accomplished changing the frustum size. In perspective projection, it is accomplished by moving the eye position along the z axis of the eye frame.
 * @param s scale factor
 */
public void zoom(double s){
  if (myFrustum.orthographic) {
    myFrustum.fieldHeight*=s;
    myFrustum.top*=s;
    myFrustum.bottom*=s;
    myFrustum.left*=s;
    myFrustum.right*=s;
    computeProjectionMatrix();
  }
 else {
    Vector3d reye=new Vector3d();
    Point3d eye=getEye();
synchronized (viewMatrix) {
      reye.sub(eye,myViewState.myCenter);
      reye.transform(viewMatrix);
      reye.x=reye.y=0;
      reye.inverseTransform(viewMatrix);
    }
    eye.scaledAdd(s - 1,reye);
    setEye(eye);
  }
  repaint();
}

Fixed version (ground truth):
/** 
 * Zoom in or out by a specified scale factor. A factor larger than one zooms out, while a factor less than one zooms in. In orthographic projection, zoom is accomplished changing the frustum size. In perspective projection, it is accomplished by moving the eye position along the z axis of the eye frame.
 * @param s scale factor
 */
public void zoom(double s){
  if (myFrustum.orthographic) {
    myFrustum.fieldHeight*=s;
    myFrustum.top*=s;
    myFrustum.bottom*=s;
    myFrustum.left*=s;
    myFrustum.right*=s;
    computeProjectionMatrix();
  }
 else {
    Vector3d reye=new Vector3d();
    Point3d eye=getEye();
synchronized (viewMatrix) {
      reye.sub(eye,myViewState.myCenter);
      reye.transform(viewMatrix);
      reye.x=reye.y=0;
      reye.inverseTransform(viewMatrix);
    }
    eye.scaledAdd(s - 1,reye);
    setEyeToWorld(eye,myViewState.myCenter,getActualUpVector());
  }
  repaint();
}
Program: 70714
Project: 70714
Buggy source:
public void activateFBO(GL2GL3 gl){
  fbo.activate(gl);
}

Fixed version (ground truth):
public void activateFBO(GL2GL3 gl){
  fbo.activate(gl);
  gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
}
Program: 70715
Project: 70715
Buggy source:
public void run(){
  BufferedImage image=null;
  if (format.equalsIgnoreCase("String_Node_Str") || format.equalsIgnoreCase("String_Node_Str")) {
    image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  }
 else {
    image=new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
  }
  image.setRGB(0,0,width,height,pixelsARGB,0,width);
  try {
    ImageIO.write(image,format,file);
  }
 catch (  IOException io_e) {
    io_e.printStackTrace();
  }
}

Fixed version (ground truth):
public void run(){
  BufferedImage image=null;
  if (format.equalsIgnoreCase("String_Node_Str") || format.equalsIgnoreCase("String_Node_Str")) {
    image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  }
 else {
    image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
  }
  image.setRGB(0,0,width,height,pixelsARGB,0,width);
  try {
    ImageIO.write(image,format,file);
  }
 catch (  IOException io_e) {
    io_e.printStackTrace();
  }
}
Program: 70716
Project: 70716
Buggy source:
private void flushQueries(GL gl){
  if (myQueryCount == 0) {
    return;
  }
  gl.glFlush();
  ByteBuffer pixels=fbo.getPixels(myGl,GL.GL_RGBA);
  int w=fbo.getWidth();
  int h=fbo.getHeight();
  boolean badIdWarningIssued=false;
  int idx=0;
  for (int i=0; i < w; i++) {
    for (int j=0; j < h; j++) {
      int r=0xff & pixels.get();
      int g=0xff & pixels.get();
      int b=0xff & pixels.get();
      int a=0xff & pixels.get();
      int lcolorId=a;
      lcolorId<<=8;
      lcolorId+=b;
      lcolorId<<=8;
      lcolorId+=g;
      lcolorId<<=8;
      lcolorId+=r;
      int colorId=(int)(lcolorId & (0xFFFFFFFF));
      if (colorId != 0) {
        int id=colorId / ID_STEP - ID_OFFSET + myQueryBase;
        if (id < 0 || id >= myTotalMaxQ) {
          if (!badIdWarningIssued) {
            System.out.printf("String_Node_Str" + "String_Node_Str",id);
            badIdWarningIssued=true;
          }
        }
 else {
          myQueryBuffer[idx]=id;
        }
      }
      ++idx;
    }
  }
  BufferUtilities.freeDirectBuffer(pixels);
  gl.glClear(GL.GL_COLOR_BUFFER_BIT);
  myQueryBase+=myQueryCount;
  myQueryTotal+=myQueryCount;
  myQueryCount=0;
}

Fixed version (ground truth):
private void flushQueries(GL gl){
  if (myQueryCount == 0) {
    return;
  }
  gl.glFlush();
  ByteBuffer pixels=fbo.getPixels(myGl,GL.GL_RGBA);
  int w=fbo.getWidth();
  int h=fbo.getHeight();
  boolean badIdWarningIssued=false;
  int idx=0;
  for (int i=0; i < w; i++) {
    for (int j=0; j < h; j++) {
      int r=0xff & pixels.get();
      int g=0xff & pixels.get();
      int b=0xff & pixels.get();
      int a=0xff & pixels.get();
      int lcolorId=a;
      lcolorId<<=8;
      lcolorId+=b;
      lcolorId<<=8;
      lcolorId+=g;
      lcolorId<<=8;
      lcolorId+=r;
      int colorId=(int)(lcolorId & (0xFFFFFFFF));
      if (colorId != 0) {
        int id=colorId / ID_STEP - ID_OFFSET + myQueryBase;
        if (id < 0 || id > myTotalMaxQ) {
          if (!badIdWarningIssued) {
            System.out.printf("String_Node_Str" + "String_Node_Str",id);
            badIdWarningIssued=true;
          }
        }
 else {
          myQueryBuffer[idx]=id;
        }
      }
      ++idx;
    }
  }
  BufferUtilities.freeDirectBuffer(pixels);
  gl.glClear(GL.GL_COLOR_BUFFER_BIT);
  myQueryBase+=myQueryCount;
  myQueryTotal+=myQueryCount;
  myQueryCount=0;
}
Program: 70717
Project: 70717
Buggy source:
public ForceTargetTerm(TrackingController trackingController){
  super();
  myMech=trackingController.getMech();
  myController=trackingController;
  myForceTargets=new ArrayList<ForceTarget>();
  myTargetForceWeights=new ArrayList<Double>();
  initTargetRenderProps();
  initSourceRenderProps();
}

Fixed version (ground truth):
public ForceTargetTerm(TrackingController trackingController){
  super();
  myMech=trackingController.getMech();
  myController=trackingController;
  myForceTargets=new ArrayList<ForceTarget>();
  myTargetForceWeights=new ArrayList<Double>();
}
Program: 70718
Project: 70718
Buggy source:
/** 
 * Fills <code>H</code> and <code>b</code> with this motion term
 * @param H LHS matrix to fill
 * @param b RHS vector to fill
 * @param rowoff row offset to start filling term
 * @param t0 starting time of time step
 * @param t1 ending time of time step
 * @return next row offset
 */
public int getTerm(MatrixNd H,VectorNd b,int rowoff,double t0,double t1){
  double h=TimeBase.round(t1 - t0);
  updateTarget(t0,t1);
  updateModelVelocity();
  VectorNd cbar=new VectorNd(myTargetForSize);
  cbar.sub(myTargetFor,myController.getData().getC0());
  MatrixNd Hc=new MatrixNd(myTargetForSize,myController.numExcitations());
  Hc.set(myController.getData().getHc());
  if (myController.getData().normalizeH) {
    double fn=1.0 / Hc.frobeniusNorm();
    Hc.scale(fn);
    cbar.scale(fn);
  }
  if (myController.getData().useTimestepScaling) {
    Hc.scale(1 / h);
    cbar.scale(1 / h);
  }
  if (myForTargetWgts != null) {
    MotionForceInverseData.diagMul(myForTargetWgts,Hc,Hc);
    MotionForceInverseData.pointMul(myForTargetWgts,cbar,cbar);
  }
  if (myWeight >= 0) {
    Hc.scale(myWeight);
    cbar.scale(myWeight);
  }
  H.setSubMatrix(rowoff,0,Hc);
  b.setSubVector(rowoff,cbar);
  if (myController.isDebugTimestep(t0,t1)) {
    System.out.println("String_Node_Str" + myTargetFor);
    System.out.println("String_Node_Str" + getForceJacobian());
    System.out.println("String_Node_Str" + Hc);
    System.out.println("String_Node_Str" + cbar);
  }
  return rowoff + Hc.rowSize();
}

Fixed version (ground truth):
/** 
 * Fills <code>H</code> and <code>b</code> with this motion term
 * @param H LHS matrix to fill
 * @param b RHS vector to fill
 * @param rowoff row offset to start filling term
 * @param t0 starting time of time step
 * @param t1 ending time of time step
 * @return next row offset
 */
public int getTerm(MatrixNd H,VectorNd b,int rowoff,double t0,double t1){
  double h=TimeBase.round(t1 - t0);
  updateTargetForce(t0,t1);
  VectorNd cbar=new VectorNd(myTargetForSize);
  cbar.sub(myTargetFor,myController.getData().getC0());
  MatrixNd Hc=new MatrixNd(myTargetForSize,myController.numExcitations());
  Hc.set(myController.getData().getHc());
  if (myController.getData().normalizeH) {
    double fn=1.0 / Hc.frobeniusNorm();
    Hc.scale(fn);
    cbar.scale(fn);
  }
  if (myController.getData().useTimestepScaling) {
    Hc.scale(1 / h);
    cbar.scale(1 / h);
  }
  if (myForTargetWgts != null) {
    MotionForceInverseData.diagMul(myForTargetWgts,Hc,Hc);
    MotionForceInverseData.pointMul(myForTargetWgts,cbar,cbar);
  }
  if (myWeight >= 0) {
    Hc.scale(myWeight);
    cbar.scale(myWeight);
  }
  H.setSubMatrix(rowoff,0,Hc);
  b.setSubVector(rowoff,cbar);
  if (myController.isDebugTimestep(t0,t1)) {
    System.out.println("String_Node_Str" + myTargetFor);
    System.out.println("String_Node_Str" + getForceJacobian());
    System.out.println("String_Node_Str" + Hc);
    System.out.println("String_Node_Str" + cbar);
  }
  return rowoff + Hc.rowSize();
}
Program: 70719
Project: 70719
Buggy source:
public void updateTargetForce(){
  if (myTargetFor == null || myTargetFor.size() != myTargetForSize)   myTargetFor=new VectorNd(myTargetForSize);
  double[] buf=myTargetFor.getBuffer();
  int idx=0;
  for (int i=0; i < myForceTargets.size(); i++) {
    ForceTarget target=myForceTargets.get(i);
    VectorNd lambda=target.getTargetLambda();
    buf[i]=lambda.get(0);
  }
}

Fixed version (ground truth):
public void updateTargetForce(double t0,double t1){
  if (myTargetFor == null || myTargetFor.size() != myTargetForSize)   myTargetFor=new VectorNd(myTargetForSize);
  double[] buf=myTargetFor.getBuffer();
  int idx=0;
  for (int i=0; i < myForceTargets.size(); i++) {
    ForceTarget target=myForceTargets.get(i);
    VectorNd lambda=target.getTargetLambda();
    lambda.get(buf,idx);
  }
}
Program: 70720
Project: 70720
Buggy source:
public void display(GLAutoDrawable drawable,int flags){
  this.drawable=drawable;
  this.gl=drawable.getGL().getGL2();
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  maybeUpdateState(gl);
  if (selectTrigger) {
    mySelector.setupSelection(gl);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  if (myProfiling) {
    myTimer.start();
    myGLColorCount=0;
  }
  doDisplay(drawable,flags);
  if (myProfiling) {
    myTimer.stop();
    System.out.printf("String_Node_Str",myTimer.getTimeUsec() / 1000.0,isSelecting() ? "String_Node_Str" : "String_Node_Str");
    System.out.println("String_Node_Str" + myGLColorCount);
  }
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(gl);
  }
 else {
    fireRerenderListeners();
  }
  if (frameCapture != null) {
synchronized (frameCapture) {
      if (grab) {
        offscreenCapture(flags);
        grab=false;
      }
      if (grabWaitComplete) {
        frameCapture.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        frameCapture.waitForCompletion();
        frameCapture.dispose(gl);
        frameCapture=null;
      }
    }
  }
  garbage(gl);
  this.drawable=null;
  this.gl=null;
}

Fixed version (ground truth):
public void display(GLAutoDrawable drawable,int flags){
  this.drawable=drawable;
  this.gl=drawable.getGL().getGL2();
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  maybeUpdateState(gl);
  if (selectTrigger) {
    mySelector.setupSelection(gl);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  if (myProfiling) {
    myTimer.start();
    myGLColorCount=0;
  }
  doDisplay(drawable,flags);
  if (myProfiling) {
    myTimer.stop();
    System.out.printf("String_Node_Str",myTimer.getTimeUsec() / 1000.0,isSelecting() ? "String_Node_Str" : "String_Node_Str");
    System.out.println("String_Node_Str" + myGLColorCount);
  }
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(gl);
  }
 else {
    fireRerenderListeners();
  }
  GLFrameCapture fc=frameCapture;
  if (fc != null) {
synchronized (fc) {
      if (grab) {
        offscreenCapture(fc,flags);
        grab=false;
      }
      if (grabWaitComplete) {
        fc.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        fc.waitForCompletion();
        fc.dispose(gl);
        frameCapture=null;
      }
    }
  }
  garbage(gl);
  this.drawable=null;
  this.gl=null;
}
Program: 70721
Project: 70721
Buggy source:
private void offscreenCapture(int flags){
  gl.setSwapInterval(1);
  frameCapture.activateFBO(gl);
  gl.glPushMatrix();
  boolean autoResize=setAutoResizeEnabled(false);
  boolean autoViewport=setAutoViewportEnabled(false);
  doDisplay(drawable,flags);
  setAutoResizeEnabled(autoResize);
  setAutoViewportEnabled(autoViewport);
  fireRerenderListeners();
  gl.glPopMatrix();
  frameCapture.deactivateFBO(gl);
  frameCapture.capture(gl);
}

Fixed version (ground truth):
private void offscreenCapture(GLFrameCapture fc,int flags){
  gl.setSwapInterval(1);
  fc.activateFBO(gl);
  gl.glPushMatrix();
  boolean autoResize=setAutoResizeEnabled(false);
  boolean autoViewport=setAutoViewportEnabled(false);
  doDisplay(drawable,flags);
  setAutoResizeEnabled(autoResize);
  setAutoViewportEnabled(autoViewport);
  fireRerenderListeners();
  gl.glPopMatrix();
  fc.deactivateFBO(gl);
  fc.capture(gl);
}
Program: 70722
Project: 70722
Buggy source:
@Override public void display(GLAutoDrawable drawable,int flags){
  this.drawable=drawable;
  this.gl=drawable.getGL().getGL3();
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  if (selectTrigger) {
    mySelector.setupSelection(gl);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  if (myProfiling) {
    myTimer.start();
  }
  doDisplay(drawable,flags);
  if (myProfiling) {
    myTimer.stop();
    System.out.printf("String_Node_Str",myTimer.getTimeUsec() / 1000.0,isSelecting() ? "String_Node_Str" : "String_Node_Str");
  }
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(gl);
  }
 else {
    fireRerenderListeners();
  }
  if (frameCapture != null) {
synchronized (frameCapture) {
      if (grab) {
        offscreenCapture(flags);
        grab=false;
      }
      if (grabWaitComplete) {
        frameCapture.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        frameCapture.waitForCompletion();
        frameCapture.dispose(gl);
        frameCapture=null;
      }
    }
  }
  long time=System.currentTimeMillis();
  if (time - lastGarbageTime > myGLResources.getGarbageCollectionInterval()) {
    garbage(gl);
  }
  myGLResources.maybeRunGarbageCollection(gl);
  this.drawable=null;
  this.gl=null;
}

Fixed version (ground truth):
@Override public void display(GLAutoDrawable drawable,int flags){
  this.drawable=drawable;
  this.gl=drawable.getGL().getGL3();
  if (!myInternalRenderListValid) {
    buildInternalRenderList();
  }
  if (selectTrigger) {
    mySelector.setupSelection(gl);
    selectEnabled=true;
    selectTrigger=false;
  }
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  if (myProfiling) {
    myTimer.start();
  }
  doDisplay(drawable,flags);
  if (myProfiling) {
    myTimer.stop();
    System.out.printf("String_Node_Str",myTimer.getTimeUsec() / 1000.0,isSelecting() ? "String_Node_Str" : "String_Node_Str");
  }
  if (selectEnabled) {
    selectEnabled=false;
    mySelector.processSelection(gl);
  }
 else {
    fireRerenderListeners();
  }
  GLFrameCapture fc=frameCapture;
  if (fc != null) {
synchronized (fc) {
      if (grab) {
        offscreenCapture(fc,flags);
        grab=false;
      }
      if (grabWaitComplete) {
        fc.waitForCompletion();
        grabWaitComplete=false;
      }
      if (grabClose) {
        fc.waitForCompletion();
        fc.dispose(gl);
        frameCapture=null;
      }
    }
  }
  long time=System.currentTimeMillis();
  if (time - lastGarbageTime > myGLResources.getGarbageCollectionInterval()) {
    garbage(gl);
  }
  myGLResources.maybeRunGarbageCollection(gl);
  this.drawable=null;
  this.gl=null;
}
Program: 70723
Project: 70723
Buggy source:
private void offscreenCapture(int flags){
  boolean savedSelecting=selectEnabled;
  selectEnabled=false;
  gl.setSwapInterval(1);
  frameCapture.activateFBO(gl);
  boolean autoResize=setAutoResizeEnabled(false);
  boolean autoViewport=setAutoViewportEnabled(false);
  doDisplay(drawable,flags);
  setAutoResizeEnabled(autoResize);
  setAutoViewportEnabled(autoViewport);
  fireRerenderListeners();
  frameCapture.deactivateFBO(gl);
  frameCapture.capture(gl);
  selectEnabled=savedSelecting;
}

Fixed version (ground truth):
private void offscreenCapture(GLFrameCapture fc,int flags){
  boolean savedSelecting=selectEnabled;
  selectEnabled=false;
  gl.setSwapInterval(1);
  fc.activateFBO(gl);
  boolean autoResize=setAutoResizeEnabled(false);
  boolean autoViewport=setAutoViewportEnabled(false);
  doDisplay(drawable,flags);
  setAutoResizeEnabled(autoResize);
  setAutoViewportEnabled(autoViewport);
  fireRerenderListeners();
  fc.deactivateFBO(gl);
  fc.capture(gl);
  selectEnabled=savedSelecting;
}
Program: 70725
Project: 70725
Buggy source:
public void setupSelection(GLAutoDrawable drawable){
  if (!(myViewer instanceof GLViewer)) {
    return;
  }
  GLViewer viewer=(GLViewer)myViewer;
  GL2GL3 gl=(GL2GL3)drawable.getGL();
  myGl=gl;
  myTotalMaxQ=myViewer.numSelectionQueriesNeeded();
  if (myTotalMaxQ == 0) {
    return;
  }
  myCurrentMaxQ=myTotalMaxQ;
  myCurrentIdx=-1;
  myIdxBase=0;
  myMaxQStack.clear();
  myIdxBaseStack.clear();
  myQuerySamples=new int[myTotalMaxQ];
  int maxGLQueries=Math.min(myTotalMaxQ,MAX_OCCLUSION_QUERIES);
  myGLQueries=new int[maxGLQueries];
  myGLQueryIds=new int[maxGLQueries];
  myGLQueryCount=0;
  myGLQueryTotal=0;
  gl.glGenQueries(myTotalMaxQ,myGLQueries,0);
  mySavedViewport=viewer.getViewport(gl);
  if (changeViewport) {
    viewer.setPickMatrix((float)myRectX,(float)(mySavedViewport[3] - myRectY),(float)myRectW,(float)myRectH,mySavedViewport);
    viewer.setViewport(gl,0,0,(int)Math.ceil(myRectW),(int)Math.ceil(myRectH));
  }
 else {
    viewer.setPickMatrix((float)myRectX,(float)(mySavedViewport[3] - myRectY),(float)myRectW,(float)myRectH,mySavedViewport);
  }
  Vector2d zRange=new Vector2d();
  myViewer.getZRange(zRange);
  myViewer.setViewVolume(zRange.x,zRange.y);
  viewer.setLightingEnabled(false);
  viewer.setColorEnabled(false);
  viewer.setDepthEnabled(false);
  savedMultisampled=myViewer.isMultiSampleEnabled();
  if (savedMultisampled) {
    myViewer.setMultiSampleEnabled(false);
  }
}

Fixed version (ground truth):
public void setupSelection(GLAutoDrawable drawable){
  if (!(myViewer instanceof GLViewer)) {
    return;
  }
  GLViewer viewer=(GLViewer)myViewer;
  GL2GL3 gl=(GL2GL3)drawable.getGL();
  myGl=gl;
  myTotalMaxQ=myViewer.numSelectionQueriesNeeded();
  if (myTotalMaxQ == 0) {
    return;
  }
  myCurrentMaxQ=myTotalMaxQ;
  myCurrentIdx=-1;
  myIdxBase=0;
  myMaxQStack.clear();
  myIdxBaseStack.clear();
  myQuerySamples=new int[myTotalMaxQ];
  int maxGLQueries=Math.min(myTotalMaxQ,MAX_OCCLUSION_QUERIES);
  myGLQueries=new int[maxGLQueries];
  myGLQueryIds=new int[maxGLQueries];
  myGLQueryCount=0;
  myGLQueryTotal=0;
  gl.glGenQueries(myGLQueries.length,myGLQueries,0);
  mySavedViewport=viewer.getViewport(gl);
  if (changeViewport) {
    viewer.setPickMatrix((float)myRectX,(float)(mySavedViewport[3] - myRectY),(float)myRectW,(float)myRectH,mySavedViewport);
    viewer.setViewport(gl,0,0,(int)Math.ceil(myRectW),(int)Math.ceil(myRectH));
  }
 else {
    viewer.setPickMatrix((float)myRectX,(float)(mySavedViewport[3] - myRectY),(float)myRectW,(float)myRectH,mySavedViewport);
  }
  Vector2d zRange=new Vector2d();
  myViewer.getZRange(zRange);
  myViewer.setViewVolume(zRange.x,zRange.y);
  viewer.setLightingEnabled(false);
  viewer.setColorEnabled(false);
  viewer.setDepthEnabled(false);
  savedMultisampled=myViewer.isMultiSampleEnabled();
  if (savedMultisampled) {
    myViewer.setMultiSampleEnabled(false);
  }
}
Program: 70726
Project: 70726
Buggy source:
public void addRenderables(SphericalJointForceBound bounds,Point3d p0){
  Iterator<Vector3d> viter;
  Iterator<Point3d> piter;
  Vector3d prev, first;
  Point3d prevPt, firstPt;
  Vector3d tmp=new Vector3d();
  ArrayList<Point3d> polyPts=new ArrayList<Point3d>();
  viter=bounds.getBoundNormals().iterator();
  prev=viter.next();
  while (viter.hasNext()) {
    Vector3d cur=viter.next();
    tmp.cross(prev,cur);
    tmp.normalize();
    polyPts.add(new Point3d(tmp));
    lines.add(new LineInfo(p0,tmp,Color.ORANGE));
    prev=cur;
  }
  piter=polyPts.iterator();
  firstPt=piter.next();
  prevPt=firstPt;
  while (piter.hasNext()) {
    Point3d curPt=piter.next();
    planes.add(new TriInfo(p0,prevPt,curPt,Color.MAGENTA));
    prevPt=curPt;
  }
  planes.add(new TriInfo(p0,prevPt,firstPt,Color.MAGENTA));
}

Fixed version (ground truth):
public void addRenderables(SphericalJointForceBound bounds,Point3d p0){
  Iterator<Vector3d> viter;
  Iterator<Point3d> piter;
  Vector3d prev, first;
  Point3d prevPt, firstPt;
  Vector3d tmp=new Vector3d();
  ArrayList<Point3d> polyPts=new ArrayList<Point3d>();
  viter=bounds.getBoundNormals().iterator();
  prev=bounds.getBoundNormals().get(bounds.getBoundNormals().size() - 1);
  while (viter.hasNext()) {
    Vector3d cur=viter.next();
    tmp.cross(prev,cur);
    tmp.normalize();
    polyPts.add(new Point3d(tmp));
    lines.add(new LineInfo(p0,tmp,Color.ORANGE));
    prev=cur;
  }
  piter=polyPts.iterator();
  firstPt=piter.next();
  prevPt=firstPt;
  while (piter.hasNext()) {
    Point3d curPt=piter.next();
    planes.add(new TriInfo(p0,prevPt,curPt,Color.LIGHT_GRAY));
    lines.add(new LineInfo(p0,tmp,Color.RED));
    prevPt=curPt;
  }
  planes.add(new TriInfo(p0,prevPt,firstPt,Color.LIGHT_GRAY));
}
Program: 70728
Project: 70728
Buggy source:
private void configureTargetForceProbe(NumericProbeBase probe,ArrayList<ForceTarget> targets,String filename){
  System.out.println("String_Node_Str");
  ArrayList<Property> props=new ArrayList<Property>();
  for (  ForceTarget target : targets) {
    props.add(target.getProperty("String_Node_Str"));
  }
  probe.setAttachedFileName(filename);
  if (probe instanceof NumericInputProbe) {
    ((NumericInputProbe)probe).setInputProperties(props.toArray(new Property[props.size()]));
  }
 else   if (probe instanceof NumericOutputProbe) {
    ((NumericOutputProbe)probe).setOutputProperties(props.toArray(new Property[props.size()]));
  }
  if (probe instanceof NumericInputProbe) {
    File file=probe.getAttachedFile();
    if (file == null || !file.exists()) {
      ((NumericInputProbe)probe).loadEmpty();
      probe.setActive(false);
    }
 else {
      try {
        probe.load();
        probe.setActive(true);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
private void configureTargetForceProbe(NumericProbeBase probe,ArrayList<ForceTarget> targets,String filename){
  ArrayList<Property> props=new ArrayList<Property>();
  for (  ForceTarget target : targets) {
    props.add(target.getProperty("String_Node_Str"));
  }
  probe.setAttachedFileName(filename);
  if (probe instanceof NumericInputProbe) {
    ((NumericInputProbe)probe).setInputProperties(props.toArray(new Property[props.size()]));
  }
 else   if (probe instanceof NumericOutputProbe) {
    ((NumericOutputProbe)probe).setOutputProperties(props.toArray(new Property[props.size()]));
  }
  if (probe instanceof NumericInputProbe) {
    File file=probe.getAttachedFile();
    if (file == null || !file.exists()) {
      ((NumericInputProbe)probe).loadEmpty();
      probe.setActive(false);
    }
 else {
      try {
        probe.load();
        probe.setActive(true);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 70729
Project: 70729
Buggy source:
private void configureTargetMotionProbe(NumericProbeBase probe,ArrayList<MotionTargetComponent> targets,String filename){
  System.out.println("String_Node_Str");
  ArrayList<Property> props=new ArrayList<Property>();
  for (  ModelComponent target : targets) {
    if (target instanceof Point) {
      props.add(target.getProperty("String_Node_Str"));
    }
 else     if (target instanceof Frame) {
      props.add(target.getProperty("String_Node_Str"));
      props.add(target.getProperty("String_Node_Str"));
    }
 else {
      System.err.println("String_Node_Str" + target.getClass().toString());
    }
  }
  probe.setAttachedFileName(filename);
  if (probe instanceof NumericInputProbe) {
    ((NumericInputProbe)probe).setInputProperties(props.toArray(new Property[props.size()]));
  }
 else   if (probe instanceof NumericOutputProbe) {
    ((NumericOutputProbe)probe).setOutputProperties(props.toArray(new Property[props.size()]));
  }
  if (probe instanceof NumericInputProbe) {
    File file=probe.getAttachedFile();
    if (file == null || !file.exists()) {
      ((NumericInputProbe)probe).loadEmpty();
      probe.setActive(false);
    }
 else {
      try {
        probe.load();
        probe.setActive(true);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
private void configureTargetMotionProbe(NumericProbeBase probe,ArrayList<MotionTargetComponent> targets,String filename){
  ArrayList<Property> props=new ArrayList<Property>();
  for (  ModelComponent target : targets) {
    if (target instanceof Point) {
      props.add(target.getProperty("String_Node_Str"));
    }
 else     if (target instanceof Frame) {
      props.add(target.getProperty("String_Node_Str"));
      props.add(target.getProperty("String_Node_Str"));
    }
 else {
      System.err.println("String_Node_Str" + target.getClass().toString());
    }
  }
  probe.setAttachedFileName(filename);
  if (probe instanceof NumericInputProbe) {
    ((NumericInputProbe)probe).setInputProperties(props.toArray(new Property[props.size()]));
  }
 else   if (probe instanceof NumericOutputProbe) {
    ((NumericOutputProbe)probe).setOutputProperties(props.toArray(new Property[props.size()]));
  }
  if (probe instanceof NumericInputProbe) {
    File file=probe.getAttachedFile();
    if (file == null || !file.exists()) {
      ((NumericInputProbe)probe).loadEmpty();
      probe.setActive(false);
    }
 else {
      try {
        probe.load();
        probe.setActive(true);
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 70730
Project: 70730
Buggy source:
/** 
 * Adds a target to the term for trajectory error
 * @param source
 * @param weight
 * @return the created target body or point
 */
private MotionTargetComponent doAddTarget(MotionTargetComponent source,double weight){
  mySources.add(source);
  source.setTargetActivity(TargetActivity.None);
  MotionTargetComponent target=null;
  if (source instanceof Point) {
    myTargetVelSize+=POINT_ENTRY_SIZE;
    myTargetPosSize+=POINT_ENTRY_SIZE;
    target=addTargetPoint((Point)source);
  }
 else   if (source instanceof Frame) {
    myTargetVelSize+=FRAME_POS_SIZE;
    myTargetPosSize+=FRAME_VEL_SIZE;
    target=addTargetFrame((RigidBody)source);
  }
  myTargetWeights.add(weight);
  updateWeightsVector();
  myVelJacobian=null;
  return target;
}

Fixed version (ground truth):
/** 
 * Adds a target to the term for trajectory error
 * @param source
 * @param weight
 * @return the created target body or point
 */
private MotionTargetComponent doAddTarget(MotionTargetComponent source,double weight){
  mySources.add(source);
  source.setTargetActivity(TargetActivity.None);
  MotionTargetComponent target=null;
  if (source instanceof Point) {
    myTargetVelSize+=POINT_VEL_SIZE;
    myTargetPosSize+=POINT_POS_SIZE;
    target=addTargetPoint((Point)source);
  }
 else   if (source instanceof Frame) {
    myTargetVelSize+=FRAME_VEL_SIZE;
    myTargetPosSize+=FRAME_POS_SIZE;
    target=addTargetFrame((RigidBody)source);
  }
  myTargetWeights.add(weight);
  updateWeightsVector();
  myVelJacobian=null;
  return target;
}
Program: 70731
Project: 70731
Buggy source:
/** 
 * Creates and adds a target frame, returning the created frame to track
 * @param source to drive toward target 
 * @return the created target frame
 */
private TargetFrame addTargetFrame(RigidBody source){
  TargetFrame tframe=new TargetFrame();
  tframe.setName((source.getName() != null ? source.getName() : String.format("String_Node_Str",source.getNumber())) + "String_Node_Str");
  tframe.setState(source);
  tframe.setTargetActivity(TargetActivity.PositionVelocity);
  tframe.setAxisLength(1.0);
  myTargets.add(tframe);
  myController.targetFrames.add(tframe);
  return tframe;
}

Fixed version (ground truth):
/** 
 * Creates and adds a target frame, returning the created frame to track
 * @param source to drive toward target 
 * @return the created target frame
 */
private TargetFrame addTargetFrame(RigidBody source){
  TargetFrame tframe=new TargetFrame();
  tframe.setPose(source.getPose());
  tframe.setName((source.getName() != null ? source.getName() : String.format("String_Node_Str",source.getNumber())) + "String_Node_Str");
  tframe.setState(source);
  tframe.setTargetActivity(TargetActivity.PositionVelocity);
  tframe.setAxisLength(1.0);
  myTargets.add(tframe);
  if (source.getMesh() != null) {
    tframe.setMesh(new PolygonalMesh(source.getMesh()),source.getMeshFileName());
    tframe.setRenderProps(source.getRenderProps());
    RenderProps.setDrawEdges(tframe,true);
    RenderProps.setFaceStyle(tframe,Faces.NONE);
  }
  myController.targetFrames.add(tframe);
  return tframe;
}
Program: 70732
Project: 70732
Buggy source:
private void updateWeightsVector(){
  myTargetWgts=new VectorNd(myTargetVelSize);
  int idx=0;
  for (int t=0; t < mySources.size(); t++) {
    MotionTargetComponent target=mySources.get(t);
    double w=myTargetWeights.get(t);
    if (target instanceof Point) {
      for (int i=0; i < POINT_ENTRY_SIZE; i++) {
        myTargetWgts.set(idx++,w);
      }
    }
 else     if (target instanceof Frame) {
      for (int i=0; i < FRAME_VEL_SIZE; i++) {
        myTargetWgts.set(idx++,w);
      }
    }
  }
}

Fixed version (ground truth):
private void updateWeightsVector(){
  myTargetWgts=new VectorNd(myTargetVelSize);
  int idx=0;
  for (int t=0; t < mySources.size(); t++) {
    MotionTargetComponent target=mySources.get(t);
    double w=myTargetWeights.get(t);
    if (target instanceof Point) {
      for (int i=0; i < POINT_VEL_SIZE; i++) {
        myTargetWgts.set(idx++,w);
      }
    }
 else     if (target instanceof Frame) {
      for (int i=0; i < FRAME_VEL_SIZE; i++) {
        myTargetWgts.set(idx++,w);
      }
    }
  }
}
Program: 70733
Project: 70733
Buggy source:
/** 
 * Removes a target to the term for trajectory error
 * @param source
 */
protected void removeTarget(MotionTargetComponent source){
  int idx=mySources.indexOf(source);
  if (idx == -1) {
    return;
  }
  if (source instanceof Point) {
    myTargetVelSize-=POINT_ENTRY_SIZE;
    myTargetPosSize-=POINT_ENTRY_SIZE;
    removeTargetPoint((Point)myTargets.get(idx));
  }
 else   if (source instanceof Frame) {
    myTargetVelSize-=FRAME_POS_SIZE;
    myTargetPosSize-=FRAME_VEL_SIZE;
    removeTargetFrame((Frame)myTargets.get(idx));
  }
  myTargetWeights.remove(idx);
  mySources.remove(idx);
  myTargets.remove(idx);
  updateWeightsVector();
  myVelJacobian=null;
}

Fixed version (ground truth):
/** 
 * Removes a target to the term for trajectory error
 * @param source
 */
protected void removeTarget(MotionTargetComponent source){
  int idx=mySources.indexOf(source);
  if (idx == -1) {
    return;
  }
  if (source instanceof Point) {
    myTargetVelSize-=POINT_VEL_SIZE;
    myTargetPosSize-=POINT_POS_SIZE;
    removeTargetPoint((Point)myTargets.get(idx));
  }
 else   if (source instanceof Frame) {
    myTargetVelSize-=FRAME_VEL_SIZE;
    myTargetPosSize-=FRAME_POS_SIZE;
    removeTargetFrame((Frame)myTargets.get(idx));
  }
  myTargetWeights.remove(idx);
  mySources.remove(idx);
  myTargets.remove(idx);
  updateWeightsVector();
  myVelJacobian=null;
}
Program: 70734
Project: 70734
Buggy source:
public TargetFrame(RigidTransform3d X){
  super(X);
}

Fixed version (ground truth):
public TargetFrame(RigidTransform3d X){
  super();
  setPose(X);
}
Program: 70735
Project: 70735
Buggy source:
/** 
 * Prepare framebuffer for use. Width and height should be set to rational values before calling this function. Creates framebuffer with depth buffer and one texture.
 */
public void setupFBO(){
  setup=true;
  IntBuffer handle=allocInts(1);
  gl.glGenFramebuffers(1,handle);
  FBOhandle=handle.get(0);
  if (samples > 1) {
    gl.glGenFramebuffers(1,handle);
    FBNhandle=handle.get(0);
  }
  addDepthBuffer();
  addRgbBuffer();
  checkStatus();
}

Fixed version (ground truth):
/** 
 * Prepare framebuffer for use. Width and height should be set to rational values before calling this function. Creates framebuffer with depth buffer and one texture.
 */
public void setupFBO(){
  IntBuffer handle=allocInts(1);
  gl.glGenFramebuffers(1,handle);
  FBOhandle=handle.get(0);
  if (samples > 1) {
    gl.glGenFramebuffers(1,handle);
    FBNhandle=handle.get(0);
  }
  addDepthBuffer();
  addRgbBuffer();
  checkStatus();
  setup=true;
}
Program: 70736
Project: 70736
Buggy source:
/** 
 * Create a framebuffer with the given dimensions
 */
public FrameBufferObject(int x,int y,int w,int h,File file,String format,GL2 gl){
  width=w;
  height=h;
  this.x=x;
  this.y=y;
  this.gl=gl;
  this.file=file;
  this.format=format;
}

Fixed version (ground truth):
/** 
 * Create a framebuffer with the given dimensions
 */
public FrameBufferObject(int x,int y,int w,int h,int nsamples,File file,String format,GL2 gl){
  width=w;
  height=h;
  this.x=x;
  this.y=y;
  this.gl=gl;
  this.file=file;
  this.format=format;
  this.samples=nsamples;
  this.setup=false;
}
Program: 70737
Project: 70737
Buggy source:
/** 
 * Create a renderBuffer configured as an RGB buffer and attach it to the FBO
 */
private void addRgbBuffer(){
  System.out.println("String_Node_Str");
  IntBuffer rboId=allocInts(1);
  gl.glGenRenderbuffers(1,rboId);
  CBhandle=rboId.get(0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,CBhandle);
  if (samples > 1) {
    gl.glGenRenderbuffers(1,rboId);
    CBNhandle=rboId.get(0);
    gl.glRenderbufferStorageMultisample(GL2.GL_RENDERBUFFER,samples,GL2.GL_RGBA8,width,height);
  }
 else {
    gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,GL2.GL_RGBA8,width,height);
  }
  gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,GL2.GL_COLOR_ATTACHMENT0,GL2.GL_RENDERBUFFER,CBhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
}

Fixed version (ground truth):
/** 
 * Create a renderBuffer configured as an RGB buffer and attach it to the FBO
 */
private void addRgbBuffer(){
  IntBuffer rboId=allocInts(1);
  gl.glGenRenderbuffers(1,rboId);
  CBhandle=rboId.get(0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,CBhandle);
  if (samples > 1) {
    gl.glGenRenderbuffers(1,rboId);
    CBNhandle=rboId.get(0);
    gl.glRenderbufferStorageMultisample(GL2.GL_RENDERBUFFER,samples,GL2.GL_RGBA8,width,height);
  }
 else {
    gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,GL2.GL_RGBA8,width,height);
  }
  gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,GL2.GL_COLOR_ATTACHMENT0,GL2.GL_RENDERBUFFER,CBhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
}
Program: 70738
Project: 70738
Buggy source:
/** 
 * Return the error code from the FBO
 */
public int checkStatus(){
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  status=gl.glCheckFramebufferStatus(GL2.GL_FRAMEBUFFER);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
  System.out.println("String_Node_Str" + status + "String_Node_Str"+ framebuffer_status_string(status));
  return status;
}

Fixed version (ground truth):
/** 
 * Return the error code from the FBO
 */
public int checkStatus(){
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  status=gl.glCheckFramebufferStatus(GL2.GL_FRAMEBUFFER);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
  if (status != GL2.GL_FRAMEBUFFER_COMPLETE) {
    System.err.println("String_Node_Str" + status + "String_Node_Str"+ framebuffer_status_string(status));
  }
  return status;
}
Program: 70739
Project: 70739
Buggy source:
/** 
 * Create a renderBuffer configured as a depth buffer and attach it to the FBO
 */
private void addDepthBuffer(){
  System.out.println("String_Node_Str");
  IntBuffer rboId=allocInts(1);
  gl.glGenRenderbuffers(1,rboId);
  DBhandle=rboId.get(0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,DBhandle);
  if (samples > 1) {
    gl.glRenderbufferStorageMultisample(GL2.GL_RENDERBUFFER,samples,GL2.GL_DEPTH_COMPONENT,width,height);
  }
 else {
    gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,GL2.GL_DEPTH_COMPONENT,width,height);
  }
  gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,GL2.GL_DEPTH_ATTACHMENT,GL2.GL_RENDERBUFFER,DBhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
}

Fixed version (ground truth):
/** 
 * Create a renderBuffer configured as a depth buffer and attach it to the FBO
 */
private void addDepthBuffer(){
  IntBuffer rboId=allocInts(1);
  gl.glGenRenderbuffers(1,rboId);
  DBhandle=rboId.get(0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,FBOhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,DBhandle);
  if (samples > 1) {
    gl.glRenderbufferStorageMultisample(GL2.GL_RENDERBUFFER,samples,GL2.GL_DEPTH_COMPONENT,width,height);
  }
 else {
    gl.glRenderbufferStorage(GL2.GL_RENDERBUFFER,GL2.GL_DEPTH_COMPONENT,width,height);
  }
  gl.glFramebufferRenderbuffer(GL2.GL_FRAMEBUFFER,GL2.GL_DEPTH_ATTACHMENT,GL2.GL_RENDERBUFFER,DBhandle);
  gl.glBindRenderbuffer(GL2.GL_RENDERBUFFER,0);
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,ActiveFBO);
}
Program: 70742
Project: 70742
Buggy source:
private synchronized void display(GLAutoDrawable drawable,int flags){
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  gl.glPushMatrix();
  if (selectEnabled) {
    mySelector.setupSelection(drawable);
  }
  doDisplay(drawable,flags);
  if (selectEnabled) {
    mySelector.processSelection(drawable);
    selectEnabled=false;
  }
 else {
    fireRerenderListeners();
  }
  gl.glPopMatrix();
  if (FBO != null && grab) {
    offscreenCapture(flags);
    grab=false;
  }
}

Fixed version (ground truth):
private synchronized void display(GLAutoDrawable drawable,int flags){
  drawable.setAutoSwapBufferMode(selectEnabled ? false : true);
  boolean ms=gl.glIsEnabled(GL.GL_MULTISAMPLE);
  if (!ms) {
    System.out.println("String_Node_Str");
    gl.glEnable(GL.GL_MULTISAMPLE);
    myMultiSampleEnabled=true;
  }
  gl.glPushMatrix();
  if (selectEnabled) {
    mySelector.setupSelection(drawable);
  }
  doDisplay(drawable,flags);
  if (selectEnabled) {
    mySelector.processSelection(drawable);
    selectEnabled=false;
  }
 else {
    fireRerenderListeners();
  }
  gl.glPopMatrix();
  if (FBO != null && grab) {
    offscreenCapture(flags);
    grab=false;
  }
}
Program: 70744
Project: 70744
Buggy source:
public void setupSelection(GLAutoDrawable drawable){
  GL2GL3 gl=(GL2GL3)(drawable.getGL());
  myGl=gl;
  myTotalMaxQ=myViewer.numSelectionQueriesNeeded();
  myCurrentMaxQ=myTotalMaxQ;
  myCurrentIdx=-1;
  myIdxBase=0;
  myMaxQStack.clear();
  myIdxBaseStack.clear();
  savedViewport=myViewer.getViewport(gl);
  myViewW=(int)Math.ceil(myRectW);
  myViewH=(int)Math.ceil(myRectH);
  myViewer.setPickMatrix((float)(myRectX),(float)(savedViewport[3] - myRectY),(float)myRectW,(float)myRectH,savedViewport);
  myViewer.setViewport(gl,0,0,myViewW,myViewH);
  myViewer.setLightingEnabled(false);
  myViewer.getBackgroundColor(savedBackgroundColor);
  myViewer.setBackgroundColor(0,0,0,0);
  savedBlend=gl.glIsEnabled(GL.GL_BLEND);
  if (savedBlend) {
    gl.glDisable(GL.GL_BLEND);
  }
  savedMulti=gl.glIsEnabled(GL.GL_MULTISAMPLE);
  if (savedMulti) {
    gl.glDisable(GL.GL_MULTISAMPLE);
  }
  myViewer.setColor(0,0,0,0);
  fbo=new FrameBufferObject(myViewW,myViewH,1);
  fbo.activate(gl);
}

Fixed version (ground truth):
public void setupSelection(GLAutoDrawable drawable){
  GL2GL3 gl=(GL2GL3)(drawable.getGL());
  myGl=gl;
  myTotalMaxQ=myViewer.numSelectionQueriesNeeded();
  myCurrentMaxQ=myTotalMaxQ;
  myCurrentIdx=-1;
  myIdxBase=0;
  myMaxQStack.clear();
  myIdxBaseStack.clear();
  savedViewport=myViewer.getViewport(gl);
  myViewW=(int)Math.ceil(myRectW);
  myViewH=(int)Math.ceil(myRectH);
  myViewer.setPickMatrix((float)(myRectX),(float)(savedViewport[3] - myRectY),(float)myRectW,(float)myRectH,savedViewport);
  myViewer.setViewport(gl,0,0,myViewW,myViewH);
  myViewer.setLightingEnabled(false);
  myViewer.getBackgroundColor(savedBackgroundColor);
  myViewer.setBackgroundColor(0,0,0,0);
  savedBlend=gl.glIsEnabled(GL.GL_BLEND);
  if (savedBlend) {
    gl.glDisable(GL.GL_BLEND);
  }
  savedMulti=gl.glIsEnabled(GL.GL_MULTISAMPLE);
  if (savedMulti) {
    gl.glDisable(GL.GL_MULTISAMPLE);
  }
  myViewer.getFrontColor(savedColor);
  myViewer.setColor(0,0,0,0);
  fbo=new FrameBufferObject(myViewW,myViewH,1);
  fbo.activate(gl);
}
Program: 70746
Project: 70746
Buggy source:
public boolean updateFaceLines(int[] faceIdxs,int offset,int len,FeatureIndexArray features){
  int nFaces=len;
  int nFeatures=features.numFeatures();
  PolygonalMesh mesh=getMesh();
  boolean modified=false;
  if (nFeatures > 0) {
    for (int i=0; i < nFaces; ++i) {
      if (i >= nFeatures) {
        break;
      }
      if (faceIdxs[i + offset] != features.getFeature(i)) {
        features.chop(0,i);
        nFeatures=i;
        modified=true;
        break;
      }
    }
  }
  if (nFaces < nFeatures) {
    features.chop(0,nFaces);
    nFeatures=nFaces;
    modified=true;
  }
  int[] offsets=mesh.getFeatureIndexOffsets();
  for (int i=nFeatures; i < nFaces; ++i) {
    int faceIdx=faceIdxs[i + offset];
    int v0=offsets[faceIdx];
    int nv=offsets[faceIdx + 1] - offsets[faceIdx];
    features.beginFeature(faceIdx);
    for (int j=1; j < nv; ++j) {
      int v1=v0 + j;
      features.addVertex(v0);
      features.addVertex(v1);
      v0=v1;
    }
    features.addVertex(v0);
    features.addVertex(offsets[faceIdx]);
    features.endFeature();
    modified=true;
  }
  return modified;
}

Fixed version (ground truth):
public boolean updateFaceLines(int[] faceIdxs,int offset,int len,FeatureIndexArray features){
  int nFaces=len;
  int nFeatures=features.numFeatures();
  PolygonalMesh mesh=getMesh();
  boolean modified=false;
  if (nFeatures > 0) {
    for (int i=0; i < nFaces; ++i) {
      if (i >= nFeatures) {
        break;
      }
      if (faceIdxs[i + offset] != features.getFeature(i)) {
        features.chop(0,i);
        nFeatures=i;
        modified=true;
        break;
      }
    }
  }
  if (nFaces < nFeatures) {
    features.chop(0,nFaces);
    nFeatures=nFaces;
    modified=true;
  }
  int[] offsets=mesh.getFeatureIndexOffsets();
  for (int i=nFeatures; i < nFaces; ++i) {
    int faceIdx=faceIdxs[i + offset];
    int v0=offsets[faceIdx];
    int nv=offsets[faceIdx + 1] - offsets[faceIdx];
    features.beginFeature(faceIdx);
    for (int j=1; j < nv; ++j) {
      int v1=v0 + 1;
      features.addVertex(v0);
      features.addVertex(v1);
      v0=v1;
    }
    features.addVertex(v0);
    features.addVertex(offsets[faceIdx]);
    features.endFeature();
    modified=true;
  }
  return modified;
}
Program: 70747
Project: 70747
Buggy source:
@Override public void setVerticalAlignment(VerticalAlignment vAlignment){
  if (!isFullScreen) {
    setVerticalAlignment(vAlignment);
  }
 else {
    lastVAlignment=vAlignment;
  }
}

Fixed version (ground truth):
@Override public void setVerticalAlignment(VerticalAlignment vAlignment){
  if (!isFullScreen) {
    super.setVerticalAlignment(vAlignment);
  }
 else {
    lastVAlignment=vAlignment;
  }
}
Program: 70748
Project: 70748
Buggy source:
public GLPipelineRendererBase(){
  normalsEnabled=false;
  colorsEnabled=false;
  texcoordsEnabled=false;
  color=new byte[4];
  normal=new float[3];
  texcoord=new float[2];
  maxverts=0;
  mode=0;
  drawing=false;
  nverts=0;
  vbuff=null;
}

Fixed version (ground truth):
public GLPipelineRendererBase(){
  normalsEnabled=false;
  colorsEnabled=false;
  texcoordsEnabled=false;
  color=new byte[4];
  normal=new float[3];
  texcoord=new float[2];
  maxverts=0;
  mode=0;
  drawing=false;
  nverts=0;
  vbuff=null;
  loopBuff=null;
}
Program: 70749
Project: 70749
Buggy source:
@Override public void vertex(float x,float y,float z){
  if (normalsEnabled) {
    vbuff.putFloat(normal[0]);
    vbuff.putFloat(normal[1]);
    vbuff.putFloat(normal[2]);
  }
  if (colorsEnabled) {
    vbuff.putFloat(color[0]);
    vbuff.putFloat(color[1]);
    vbuff.putFloat(color[2]);
    vbuff.putFloat(color[3]);
  }
  if (texcoordsEnabled) {
    vbuff.putFloat(texcoord[0]);
    vbuff.putFloat(texcoord[1]);
  }
  vbuff.putFloat(x);
  vbuff.putFloat(y);
  vbuff.putFloat(z);
  ++nverts;
  if (vbuff.position() == vbuff.capacity()) {
    flush();
  }
}

Fixed version (ground truth):
@Override public void vertex(float x,float y,float z){
  if (normalsEnabled) {
    vbuff.putFloat(normal[0]);
    vbuff.putFloat(normal[1]);
    vbuff.putFloat(normal[2]);
  }
  if (colorsEnabled) {
    vbuff.putFloat(color[0]);
    vbuff.putFloat(color[1]);
    vbuff.putFloat(color[2]);
    vbuff.putFloat(color[3]);
  }
  if (texcoordsEnabled) {
    vbuff.putFloat(texcoord[0]);
    vbuff.putFloat(texcoord[1]);
  }
  vbuff.putFloat(x);
  vbuff.putFloat(y);
  vbuff.putFloat(z);
  if (mode == GL.GL_LINE_LOOP && loopBuff == null) {
    loopBuff=new byte[vertexStride];
    int pos=vbuff.position();
    vbuff.position(pos - vertexStride);
    vbuff.get(loopBuff,0,vertexStride);
    vbuff.position(pos);
  }
  ++nverts;
  if (vbuff.position() == vbuff.capacity()) {
    flush();
  }
}
Program: 70750
Project: 70750
Buggy source:
@Override public void flush(){
  vbuff.flip();
  draw(gl,mode,vbuff,nverts);
  vbuff.clear();
  nverts=0;
}

Fixed version (ground truth):
@Override public void flush(){
  vbuff.flip();
  int glMode=mode;
  if (mode == GL.GL_LINE_LOOP) {
    glMode=GL.GL_LINE_STRIP;
  }
  int nv=nverts;
switch (glMode) {
case GL.GL_LINE_STRIP:
case GL.GL_LINE_LOOP:
    if (nverts < 2) {
      nv=0;
    }
case GL.GL_TRIANGLE_STRIP:
case GL.GL_TRIANGLE_FAN:
  if (nverts < 3) {
    nv=0;
  }
case GL.GL_LINES:
if ((nverts % 2) == 1) {
  nv=nverts - 1;
}
case GL.GL_TRIANGLES:
{
int off=nverts % 3;
nv=nverts - off;
}
}
draw(gl,glMode,vbuff,nv);
byte[] front=null;
int nfront=0;
switch (glMode) {
case GL.GL_LINE_STRIP:
case GL.GL_LINE_LOOP:
{
if (nverts < 2) {
front=new byte[vertexStride * nverts];
vbuff.rewind();
vbuff.get(front);
nfront=nverts;
}
 else {
nfront=nverts - nv + 1;
front=new byte[vertexStride * nfront];
vbuff.position((nv - 1) * vertexStride);
vbuff.get(front);
}
break;
}
case GL.GL_TRIANGLE_STRIP:
{
if (nverts < 3) {
front=new byte[vertexStride * nverts];
vbuff.rewind();
vbuff.get(front);
nfront=nverts;
}
 else {
int nt=nv - 2;
nfront=nverts - nv + 2;
if ((nt % 2) == 1) {
++nfront;
vbuff.position((nv - 2) * vertexStride);
front=new byte[vertexStride * nfront];
vbuff.get(front,0,vertexStride);
vbuff.position((nv - 2) * vertexStride);
vbuff.get(front,vertexStride,(nfront - 1) * vertexStride);
}
 else {
vbuff.position((nv - 2) * vertexStride);
front=new byte[vertexStride * nfront];
vbuff.get(front);
}
}
break;
}
case GL.GL_TRIANGLE_FAN:
{
if (nverts < 3) {
front=new byte[vertexStride * nverts];
vbuff.rewind();
vbuff.get(front);
nfront=nverts;
}
 else {
int nrem=nverts - nv;
front=new byte[vertexStride * (2 + nrem)];
vbuff.rewind();
vbuff.get(front,0,vertexStride);
vbuff.position((nv - 1) * vertexStride);
vbuff.get(front,vertexStride,(nrem + 1) * vertexStride);
nfront=2 + nrem;
}
break;
}
case GL.GL_LINES:
{
if ((nverts % 2) == 1) {
nfront=1;
front=new byte[vertexStride];
vbuff.position(nv * vertexStride);
vbuff.get(front);
}
break;
}
case GL.GL_TRIANGLES:
{
int off=nverts - nv;
if (off > 0) {
nfront=off;
front=new byte[nfront * vertexStride];
vbuff.position(nv * vertexStride);
vbuff.get(front);
}
break;
}
}
vbuff.clear();
nverts=0;
if (nfront > 0) {
vbuff.put(front);
nverts=nfront;
}
}