public static MeshPattern reducedPattern(MeshPattern mp, int[] indices) {
        MeshPattern result = new MeshPattern(mp.p.patternAt(indices));
        int[] values = new int[indices.length];
        for (int i = 0; i < values.length; i++) {
            values[i] = mp.p.elements[indices[i]];
        }
        Arrays.sort(values);
        for (int i = 0; i < result.mesh.length; i++) {
            int lowIndex = (i > 0) ? indices[i - 1] + 1 : 0;
            int highIndex = (i < indices.length) ? indices[i] : mp.p.length();
            for (int j = 0; j < result.mesh.length; j++) {
                int lowValue = (j > 0) ? values[j - 1] + 1 : 0;
                int highValue = (j < indices.length) ? values[j] : mp.p.length();
                for (int c = lowIndex; c <= highIndex; c++) {
                    for (int r = lowValue; r <= highValue; r++) {
                        result.mesh[i][j] |= mp.mesh[c][r];
                    }
                }
            }
        }

        return result;
    }