Program: 29981
Project: 29981
Buggy source:
@Override protected HE_Mesh createBase(){
  final double oW=-0.5 * W;
  final double oH=-0.5 * H;
  final double oD=-0.5 * D;
  final double dW=(W * 1.0) / L;
  final double dH=(H * 1.0) / M;
  final double dD=(D * 1.0) / N;
  final double di=1.0 / L;
  final double dj=1.0 / M;
  final double dk=1.0 / N;
  final double[][] vertices=new double[(2 * (L + 1) * (M + 1)) + (2 * (L + 1) * (N + 1)) + (2 * (M + 1) * (N + 1))][3];
  final double[][] uvws=new double[(2 * (L + 1) * (M + 1)) + (2 * (L + 1) * (N + 1)) + (2 * (M + 1) * (N + 1))][3];
  final int[][] faces=new int[(2 * M * L) + (2 * L * N) + (2 * M * N)][4];
  final int[] faceTextureIds=new int[(2 * M * L) + (2 * L * N) + (2 * M * N)];
  int idv=0;
  int idf=0;
  final int LMv=(L + 1) * (M + 1);
  final int LMf=L * M;
  final int LNv=(L + 1) * (N + 1);
  final int LNf=L * N;
  final int MNv=(M + 1) * (N + 1);
  final int MNf=M * N;
  for (int v=0; v < (M + 1); v++) {
    for (int u=0; u < (L + 1); u++) {
      vertices[idv][0]=vertices[idv + LMv][0]=oW + (u * dW);
      vertices[idv][1]=vertices[idv + LMv][1]=oH + (v * dH);
      vertices[idv][2]=oD;
      vertices[idv + LMv][2]=-oD;
      uvws[idv][0]=di * u;
      uvws[idv + LMv][1]=uvws[idv][1]=dj * v;
      uvws[idv + LMv][0]=1 - uvws[idv][0];
      uvws[idv][2]=uvws[idv + LMv][2]=0;
      idv++;
    }
  }
  for (int j=0; j < M; j++) {
    for (int i=0; i < L; i++) {
      faces[idf][3]=i + (j * (L + 1));
      faces[idf][2]=i + 1 + (j * (L + 1));
      faces[idf][1]=i + 1 + ((j + 1) * (L + 1));
      faces[idf][0]=i + ((j + 1) * (L + 1));
      faces[idf + LMf][0]=i + (j * (L + 1)) + LMv;
      faces[idf + LMf][1]=i + 1 + (j * (L + 1))+ LMv;
      faces[idf + LMf][2]=i + 1 + ((j + 1) * (L + 1))+ LMv;
      faces[idf + LMf][3]=i + ((j + 1) * (L + 1)) + LMv;
      faceTextureIds[idf]=0;
      faceTextureIds[idf + LMf]=1;
      idf++;
    }
  }
  int offset=2 * LMv;
  idv=offset;
  for (int v=0; v < (N + 1); v++) {
    for (int u=0; u < (L + 1); u++) {
      vertices[idv][0]=vertices[idv + LNv][0]=oW + (u * dW);
      vertices[idv][2]=vertices[idv + LNv][2]=oD + (v * dD);
      vertices[idv][1]=oH;
      vertices[idv + LNv][1]=-oH;
      uvws[idv][0]=uvws[idv + LMv][0]=di * u;
      uvws[idv + LMv][1]=dk * v;
      uvws[idv][1]=1 - uvws[idv + LMv][1];
      uvws[idv][2]=uvws[idv + LMv][2]=0;
      idv++;
    }
  }
  idf=2 * LMf;
  for (int j=0; j < N; j++) {
    for (int i=0; i < L; i++) {
      faces[idf][0]=i + (j * (L + 1)) + offset;
      faces[idf][1]=i + 1 + (j * (L + 1))+ offset;
      faces[idf][2]=i + 1 + ((j + 1) * (L + 1))+ offset;
      faces[idf][3]=i + ((j + 1) * (L + 1)) + offset;
      faces[idf + LNf][3]=i + (j * (L + 1)) + LNv+ offset;
      faces[idf + LNf][2]=i + 1 + (j * (L + 1))+ LNv+ offset;
      faces[idf + LNf][1]=i + 1 + ((j + 1) * (L + 1))+ LNv+ offset;
      faces[idf + LNf][0]=i + ((j + 1) * (L + 1)) + LNv+ offset;
      faceTextureIds[idf]=2;
      faceTextureIds[idf + LNf]=3;
      idf++;
    }
  }
  offset=(2 * LMv) + (2 * LNv);
  idv=offset;
  for (int u=0; u < (N + 1); u++) {
    for (int v=0; v < (M + 1); v++) {
      vertices[idv][1]=vertices[idv + MNv][1]=oH + (v * dH);
      vertices[idv][2]=vertices[idv + MNv][2]=oD + (u * dD);
      vertices[idv][0]=oW;
      vertices[idv + MNv][0]=-oW;
      uvws[idv + LMv][0]=dk * u;
      uvws[idv][0]=1 - uvws[idv + LMv][0];
      uvws[idv + LMv][1]=uvws[idv][1]=v * dj;
      uvws[idv + LMv][2]=uvws[idv][2]=0;
      idv++;
    }
  }
  idf=(2 * LMf) + (2 * LNf);
  for (int j=0; j < N; j++) {
    for (int i=0; i < M; i++) {
      faces[idf][3]=i + (j * (M + 1)) + offset;
      faces[idf][2]=i + 1 + (j * (M + 1))+ offset;
      faces[idf][1]=i + 1 + ((j + 1) * (M + 1))+ offset;
      faces[idf][0]=i + ((j + 1) * (M + 1)) + offset;
      faces[idf + MNf][0]=i + (j * (M + 1)) + MNv+ offset;
      faces[idf + MNf][1]=i + 1 + (j * (M + 1))+ MNv+ offset;
      faces[idf + MNf][2]=i + 1 + ((j + 1) * (M + 1))+ MNv+ offset;
      faces[idf + MNf][3]=i + ((j + 1) * (M + 1)) + MNv+ offset;
      faceTextureIds[idf]=4;
      faceTextureIds[idf + MNf]=5;
      idf++;
    }
  }
  final HEC_FromFacelist fl=new HEC_FromFacelist();
  fl.setVertices(vertices).setFaces(faces).setDuplicate(true).setUVW(uvws).setFaceTextureIds(faceTextureIds);
  return fl.createBase();
}

Fixed version (ground truth):
@Override protected HE_Mesh createBase(){
  final double oW=-0.5 * W;
  final double oH=-0.5 * H;
  final double oD=-0.5 * D;
  final double dW=(W * 1.0) / L;
  final double dH=(H * 1.0) / M;
  final double dD=(D * 1.0) / N;
  final double di=1.0 / L;
  final double dj=1.0 / M;
  final double dk=1.0 / N;
  final double[][] vertices=new double[(2 * (L + 1) * (M + 1)) + (2 * (L + 1) * (N + 1)) + (2 * (M + 1) * (N + 1))][3];
  final double[][] uvws=new double[(2 * (L + 1) * (M + 1)) + (2 * (L + 1) * (N + 1)) + (2 * (M + 1) * (N + 1))][3];
  final int[][] faces=new int[(2 * M * L) + (2 * L * N) + (2 * M * N)][4];
  final int[] faceTextureIds=new int[(2 * M * L) + (2 * L * N) + (2 * M * N)];
  int idv=0;
  int idf=0;
  final int LMv=(L + 1) * (M + 1);
  final int LMf=L * M;
  final int LNv=(L + 1) * (N + 1);
  final int LNf=L * N;
  final int MNv=(M + 1) * (N + 1);
  final int MNf=M * N;
  for (int v=0; v < (M + 1); v++) {
    for (int u=0; u < (L + 1); u++) {
      vertices[idv][0]=vertices[idv + LMv][0]=oW + (u * dW);
      vertices[idv][1]=vertices[idv + LMv][1]=oH + (v * dH);
      vertices[idv][2]=oD;
      vertices[idv + LMv][2]=-oD;
      uvws[idv][0]=di * u;
      uvws[idv + LMv][1]=uvws[idv][1]=dj * v;
      uvws[idv + LMv][0]=1 - uvws[idv][0];
      uvws[idv][2]=uvws[idv + LMv][2]=0;
      idv++;
    }
  }
  for (int j=0; j < M; j++) {
    for (int i=0; i < L; i++) {
      faces[idf][3]=i + (j * (L + 1));
      faces[idf][2]=i + 1 + (j * (L + 1));
      faces[idf][1]=i + 1 + ((j + 1) * (L + 1));
      faces[idf][0]=i + ((j + 1) * (L + 1));
      faces[idf + LMf][0]=i + (j * (L + 1)) + LMv;
      faces[idf + LMf][1]=i + 1 + (j * (L + 1))+ LMv;
      faces[idf + LMf][2]=i + 1 + ((j + 1) * (L + 1))+ LMv;
      faces[idf + LMf][3]=i + ((j + 1) * (L + 1)) + LMv;
      faceTextureIds[idf]=0;
      faceTextureIds[idf + LMf]=1;
      idf++;
    }
  }
  int offset=2 * LMv;
  idv=offset;
  for (int v=0; v < (N + 1); v++) {
    for (int u=0; u < (L + 1); u++) {
      vertices[idv][0]=vertices[idv + LNv][0]=oW + (u * dW);
      vertices[idv][2]=vertices[idv + LNv][2]=oD + (v * dD);
      vertices[idv][1]=oH;
      vertices[idv + LNv][1]=-oH;
      uvws[idv][0]=uvws[idv + LNv][0]=di * u;
      uvws[idv + LNv][1]=dk * v;
      uvws[idv][1]=1 - uvws[idv + LNv][1];
      uvws[idv][2]=uvws[idv + LNv][2]=0;
      idv++;
    }
  }
  idf=2 * LMf;
  for (int j=0; j < N; j++) {
    for (int i=0; i < L; i++) {
      faces[idf][0]=i + (j * (L + 1)) + offset;
      faces[idf][1]=i + 1 + (j * (L + 1))+ offset;
      faces[idf][2]=i + 1 + ((j + 1) * (L + 1))+ offset;
      faces[idf][3]=i + ((j + 1) * (L + 1)) + offset;
      faces[idf + LNf][3]=i + (j * (L + 1)) + LNv+ offset;
      faces[idf + LNf][2]=i + 1 + (j * (L + 1))+ LNv+ offset;
      faces[idf + LNf][1]=i + 1 + ((j + 1) * (L + 1))+ LNv+ offset;
      faces[idf + LNf][0]=i + ((j + 1) * (L + 1)) + LNv+ offset;
      faceTextureIds[idf]=2;
      faceTextureIds[idf + LNf]=3;
      idf++;
    }
  }
  offset=(2 * LMv) + (2 * LNv);
  idv=offset;
  for (int u=0; u < (N + 1); u++) {
    for (int v=0; v < (M + 1); v++) {
      vertices[idv][1]=vertices[idv + MNv][1]=oH + (v * dH);
      vertices[idv][2]=vertices[idv + MNv][2]=oD + (u * dD);
      vertices[idv][0]=oW;
      vertices[idv + MNv][0]=-oW;
      uvws[idv + MNv][0]=dk * u;
      uvws[idv][0]=1 - uvws[idv + MNv][0];
      uvws[idv + MNv][1]=uvws[idv][1]=v * dj;
      uvws[idv + MNv][2]=uvws[idv][2]=0;
      idv++;
    }
  }
  idf=(2 * LMf) + (2 * LNf);
  for (int j=0; j < N; j++) {
    for (int i=0; i < M; i++) {
      faces[idf][3]=i + (j * (M + 1)) + offset;
      faces[idf][2]=i + 1 + (j * (M + 1))+ offset;
      faces[idf][1]=i + 1 + ((j + 1) * (M + 1))+ offset;
      faces[idf][0]=i + ((j + 1) * (M + 1)) + offset;
      faces[idf + MNf][0]=i + (j * (M + 1)) + MNv+ offset;
      faces[idf + MNf][1]=i + 1 + (j * (M + 1))+ MNv+ offset;
      faces[idf + MNf][2]=i + 1 + ((j + 1) * (M + 1))+ MNv+ offset;
      faces[idf + MNf][3]=i + ((j + 1) * (M + 1)) + MNv+ offset;
      faceTextureIds[idf]=4;
      faceTextureIds[idf + MNf]=5;
      idf++;
    }
  }
  final HEC_FromFacelist fl=new HEC_FromFacelist();
  fl.setVertices(vertices).setFaces(faces).setDuplicate(true).setUVW(uvws).setFaceTextureIds(faceTextureIds);
  return fl.createBase();
}