Program: 43065
Project: 43065
Buggy source:
/** 
 * Initialize the spatial grid for accelerating ray / voxel intersections
 * @param grid
 * @param geom
 * @param voxelSize
 * @return
 */
private GridTrianglePartition initSpatial(Grid grid,GeometryData geom,double voxelSize){
  int w=2 * grid.getWidth();
  int h=2 * grid.getHeight();
  int d=2 * grid.getDepth();
  numVoxels=(int)Math.max(Math.max(w,h),d);
  int num_tris=0;
  origin[0]=numVoxels / 2;
  origin[1]=numVoxels / 2;
  origin[2]=numVoxels / 2;
  System.out.println("String_Node_Str" + grid.getWidth() + "String_Node_Str"+ grid.getHeight()+ "String_Node_Str"+ grid.getDepth());
  if (geom.geometryType == GeometryData.TRIANGLES) {
    num_tris=geom.coordinates.length / 3;
  }
 else {
    num_tris=geom.indexes.length / 3;
  }
  System.out.println("String_Node_Str" + numVoxels + "String_Node_Str"+ num_tris);
  GridTrianglePartition ret_val=new GridTrianglePartition(voxelSize,numVoxels,num_tris);
  float[] tri=new float[9];
  int t=0;
  if (geom.geometryType == GeometryData.TRIANGLES) {
    for (int i=0; i < num_tris / 3; i++) {
      tri[0]=geom.coordinates[t * 3];
      tri[1]=geom.coordinates[t * 3 + 1];
      tri[2]=geom.coordinates[t * 3 + 2];
      t++;
      tri[3]=geom.coordinates[t * 3];
      tri[4]=geom.coordinates[t * 3 + 1];
      tri[5]=geom.coordinates[t * 3 + 2];
      t++;
      tri[6]=geom.coordinates[t * 3];
      tri[7]=geom.coordinates[t * 3 + 1];
      tri[8]=geom.coordinates[t * 3 + 2];
      t++;
      Triangle poly=new Triangle(tri,i);
      ret_val.insert(poly,false);
    }
  }
 else {
    for (int i=0; i < num_tris; i++) {
      tri[0]=geom.coordinates[geom.indexes[t] * 3];
      tri[1]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[2]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      tri[3]=geom.coordinates[geom.indexes[t] * 3];
      tri[4]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[5]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      tri[6]=geom.coordinates[geom.indexes[t] * 3];
      tri[7]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[8]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      Triangle poly=new Triangle(tri,i);
      ret_val.insert(poly,false);
    }
  }
  System.gc();
  return ret_val;
}

Fixed version (ground truth):
/** 
 * Initialize the spatial grid for accelerating ray / voxel intersections
 * @param grid
 * @param geom
 * @param voxelSize
 * @return
 */
private GridTrianglePartition initSpatial(Grid grid,GeometryData geom,double voxelSize){
  int w=2 * grid.getWidth();
  int h=2 * grid.getHeight();
  int d=2 * grid.getDepth();
  numVoxels=(int)Math.max(Math.max(w,h),d);
  int num_tris=0;
  System.out.println("String_Node_Str" + grid.getWidth() + "String_Node_Str"+ grid.getHeight()+ "String_Node_Str"+ grid.getDepth());
  if (geom.geometryType == GeometryData.TRIANGLES) {
    num_tris=geom.coordinates.length / 3;
  }
 else {
    num_tris=geom.indexes.length / 3;
  }
  System.out.println("String_Node_Str" + numVoxels + "String_Node_Str"+ num_tris);
  GridTrianglePartition ret_val=new GridTrianglePartition(voxelSize,numVoxels,num_tris);
  float[] tri=new float[9];
  int t=0;
  if (geom.geometryType == GeometryData.TRIANGLES) {
    for (int i=0; i < num_tris / 3; i++) {
      tri[0]=geom.coordinates[t * 3];
      tri[1]=geom.coordinates[t * 3 + 1];
      tri[2]=geom.coordinates[t * 3 + 2];
      t++;
      tri[3]=geom.coordinates[t * 3];
      tri[4]=geom.coordinates[t * 3 + 1];
      tri[5]=geom.coordinates[t * 3 + 2];
      t++;
      tri[6]=geom.coordinates[t * 3];
      tri[7]=geom.coordinates[t * 3 + 1];
      tri[8]=geom.coordinates[t * 3 + 2];
      t++;
      Triangle poly=new Triangle(tri,i);
      ret_val.insert(poly,false);
    }
  }
 else {
    for (int i=0; i < num_tris; i++) {
      tri[0]=geom.coordinates[geom.indexes[t] * 3];
      tri[1]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[2]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      tri[3]=geom.coordinates[geom.indexes[t] * 3];
      tri[4]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[5]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      tri[6]=geom.coordinates[geom.indexes[t] * 3];
      tri[7]=geom.coordinates[geom.indexes[t] * 3 + 1];
      tri[8]=geom.coordinates[geom.indexes[t++] * 3 + 2];
      Triangle poly=new Triangle(tri,i);
      ret_val.insert(poly,false);
    }
  }
  System.gc();
  return ret_val;
}