void xpm_mat(const char *outf, int nmat, t_matrix *mat, t_matrix *mat2, gmx_bool bDiag, gmx_bool bFirstDiag) { FILE *out; char buf[100]; int i, j, k, x, y, col; int nmap; t_mapping *map = NULL; out = ffopen(outf, "w"); for (i = 0; i < nmat; i++) { if (!mat2 || !diff_maps(mat[i].nmap, mat[i].map, mat2[i].nmap, mat2[i].map)) { write_xpm_m(out, mat[0]); } else { nmap = add_maps(&map, mat[i].nmap, mat[i].map, mat2[i].nmap, mat2[i].map); for (x = 0; (x < mat[i].nx); x++) { for (y = 0; (y < mat[i].nx); y++) { if ((x < y) || ((x == y) && bFirstDiag)) /* upper left -> map1 */ { col = mat[i].matrix[x][y]; } else /* lower right -> map2 */ { col = mat[i].nmap+mat[i].matrix[x][y]; } if ((bDiag) || (x != y)) { mat[i].matrix[x][y] = col; } else { mat[i].matrix[x][y] = 0; } } } sfree(mat[i].map); mat[i].nmap = nmap; mat[i].map = map; if (mat2 && (strcmp(mat[i].title, mat2[i].title) != 0)) { sprintf(mat[i].title+strlen(mat[i].title), " / %s", mat2[i].title); } if (mat2 && (strcmp(mat[i].legend, mat2[i].legend) != 0)) { sprintf(mat[i].legend+strlen(mat[i].legend), " / %s", mat2[i].legend); } write_xpm_m(out, mat[i]); } } ffclose(out); }
/* Create segments, then save state to buffer */ static int d_map_region(struct inode *inode, block_t start, unsigned count, struct block_segment *seg, unsigned seg_max, enum map_mode mode) { int segs; /* this should be called with "mode != MAP_READ" */ assert(mode != MAP_READ); segs = map_region(inode, start, count, seg, seg_max, mode); if (segs > 0) add_maps(inode, start, seg, segs); return segs; }