private static ArrayList<Face> mergeAxisFaces(ArrayList<Face> faceList,int axis){
  ArrayList<Face> faceList2=new ArrayList<Face>();
  for (  Face face : faceList) {
    if (!faceList2.isEmpty()) {
      boolean merged=false;
      for (      Face face2 : faceList2) {
        merged=mergeFaces(face,face2,axis);
        if (merged)         break;
      }
      if (!merged) {
        faceList2.add(face);
      }
    }
 else {
      faceList2.add(face);
    }
  }
  return faceList2;
}

private static ArrayList < Face > mergeAxisFaces ( ArrayList < Face > faceList , int axis ) { ArrayList < Face > faceList2 = new ArrayList < Face > ( ) ; for ( Face face : faceList ) { if ( ! faceList2 . isEmpty ( ) ) { boolean merged = false ; for ( Face face2 : faceList2 ) { merged = mergeFaces ( face , face2 , axis ) ; if ( merged ) break ; } if ( ! merged ) { faceList2 . add ( face ) ; } } else { faceList2 . add ( face ) ; } } return faceList2 ; }
attempts to join all faces in faces along axis
