📄 map.c
字号:
return (map->map);}/* return map interption */Vec MapInterp(Map map){ if( !map ){ return (0); } return (map->interp);}/* return size of map */int MapSize(Map map){ if( !map ){ return (0); } return (map->size);}/* return map window size */int MapWindow(Map map){ if( !map ){ return (0); } if( map->last > map->first ){ return (map->last - map->first + 1); }else{ return (map->first - map->last + 1); }}/* return zoom window size */int MapZoom(Map map){ if( !map ){ return (0); } if( map->last > map->first ){ return ((int) ((map->last - map->first + 1) * AxisZoom(map->axis))); }else{ return ((int) ((map->first - map->last + 1) * AxisZoom(map->axis))); }}/* return first element of map */int MapFirst(Map map){ if( !map ){ return (0); } return (map->first);}/* return last element of map */int MapLast(Map map){ if( !map ){ return (0); } return (map->last);}/* return lowest element of map */int MapLow(Map map){ if( !map ){ return (0); } return (map->first < map->last ? map->first : map->last);}/* return highest element of map */int MapHigh(Map map){ if( !map ){ return (0); } return (map->first > map->last ? map->first : map->last);}/* return frame of map */int MapFrame(Map map){ if( !map ){ return (0); } return (map->frame);}/* return map position */int MapFrame1(Map map){ if( !map ){ return (0); } return (map->imap);}/* number of frames */int MapNFrame(Map map){ if( !map ){ return (0); } return (map->frame2 > map->frame1 ? (map->frame2 - map->frame1 + 1) : (map->frame1 - map->frame2 + 1));}/* return previous frame of map */int MapPrev(Map map){ if( !map ){ return (0); } return (map->prev);}/* return saved frame of map */int MapSave(Map map){ if( !map ){ return (0); } return (map->save);}/* return first tic of map */float MapTic0(Map map){ if( !map ){ return (0.0); } return (map->tic0);}/* return last tic of map */float MapTic2(Map map){ if( !map ){ return (0.0); } return (map->tic2);}/* return number of tics of map */int MapNtic(Map map){ if( !map ){ return (0); } return (map->ntic);}/* return tic spacing of map */float MapDtic(Map map){ if( !map ){ return (0.0); } return (map->dtic);}/* return start frame */int MapMovie1(Map map){ if( !map ){ return (0); } return (map->frame1);}/* return end frame */int MapMovie2(Map map){ if( !map ){ return (0); } return (map->frame2);}/* return frame increment */int MapDmovie(Map map){ if( !map ){ return (0); } return (map->dframe);}/* return tic spacing of map */char *MapFormat(Map map){ if( !map ){ return (0); } return (map->format);}/* set frame of map inclusive of bounds */ void MapSetFrame(Map map, int frame){ if( !map || frame < 0 ){ return; } map->prev = MapBound(map->frame, map->frame1, map->frame2); map->frame = MapBound(frame, map->frame1, map->frame2);}/* set frame bounds */ void MapSetFrameBounds(Map map, int frame1, int frame2){ if( !map ){ return; } MapSet(map, map->axis, map->size, map->first, map->last, frame1, frame2, map->dframe); MovieSetDir(frame2 - frame1);} void MapSetDmovie(Map map, int dframe){ if( !map ){ return; } map->dframe = dframe;}/* set map position */void MapSetFrame1(Map map, int frame){ if( !map ){ return; } map->imap = MapBound(frame, 0, map->size - 1);}/* compute next frame depending upon animation direction and bounds */void MapNextFrame(Map map){ map->prev = map->frame; if( map->frame1 < map->frame2 ){ if( MovieDir() == MOVIE_FORWARD ){ map->frame = map->frame <= map->frame2 - map->dframe ? map->frame + map->dframe : map->frame1; }else{ map->frame = map->frame >= map->frame1 + map->dframe ? map->frame - map->dframe : map->frame2; } }else{ if( MovieDir() == MOVIE_FORWARD ){ map->frame = map->frame >= map->frame2 + map->dframe ? map->frame - map->dframe : map->frame1; }else{ map->frame = map->frame <= map->frame1 - map->dframe ? map->frame + map->dframe : map->frame2; } }}/* return data axis value given map index */float MapValue(Map map, int index){ index = index > 0 ? index : 0; index = index < map->size ? index : map->size - 1; /* unscale map by stride */ return (AxisValue(map->axis, map->map[index] / AxisStride(map->axis)));}/* return map index given axis value */int MapIndex(Map map, float value){ float first, last; int index; first = MapValue(map, 0); last = MapValue(map, map->size - 1); index = (map->size - 1) * (value - first) / (last - first); index = index <= map->size ? index : NO_INDEX; return (index);}/* return map value given index */int MapMap(Map map, int index){ if( !map || index < 0 || index >= map->size ){ return (NO_INDEX); } return (map->map[index] / map->axis->stride);}/* return inverse index */int MapInverse(Map map, int index){ if( !map || index < 0 || index >= AxisSize(map->axis) || !map->inv ){ return (NO_INDEX); } return (map->inv[index]);}/* print map information */void MapInfo(Map map){ Message message; if( !map ){ return; } sprintf(message, "Map %s: %s: %%=%g size=%d first=%d last=%d frame1=%d frame2=%d dframe=%d dtic=%g tic0=%g tic2=%g format=%s", map->name, AxisLabel(map->axis), (float) map->size / (float) AxisSize(map->axis), map->size, map->first, map->last, map->frame1, map->frame2, map->dframe, map->dtic, map->tic0, map->tic2, map->format); UIMessage(message);}/* save map parameters */void MapSavePar(Map map){ Message message; int imap; if( !map ){ return; } if( !strcmp(map->name, "DOWN") ){ imap = 1; }else if( !strcmp(map->name, "ACROSS") ){ imap = 2; }else if( !strcmp(map->name, "DEEP")){ imap = 3; }else if( !strcmp(map->name, "4D")){ imap = 3; }else if( !strcmp(map->name, "5D")){ imap = 3; }/*--------------------------------------------------------------------*\ FIXME This string is malformed, but there I don't know what Rick intended. sprintf(message, "Map%d: %s: axis%d=%d size%d=%d first%d=%d last%d=%d frame%d=%d prev%d=%d frame1=%d frame2=%d dframe=%d", imap, map->name, imap, AxisDir(map->axis), imap, map->size, imap, map->first, imap, map->last, imap, map->frame, imap, map->prev, imap, map->frame1, imap, map->frame2, imap, map->dframe); UISaveMessage(message);\*--------------------------------------------------------------------*/}/* write map vectors to files for debugging */void MapDump(Map map){ string filename; int fd; sprintf(filename, "map.%s.map.%dx32", map->name, map->size); fd = creat(filename, 0664); write(fd, map->map, sizeof(map->map[0]) * map->size); close(fd); sprintf(filename, "map.%s.inv.%dx32", map->name, map->size); fd = creat(filename, 0664); write(fd, map->inv, sizeof(map->inv[0]) * map->size); close(fd); sprintf(filename, "map.%s.interp.%dx32", map->name, map->size); fd = creat(filename, 0664); write(fd, map->interp, sizeof(map->interp[0]) * map->size); close(fd); UIMessage("map dumped to file");}/* remember map frame */void MapSaveFrame(Map map){ map->save = map->frame;}/* recall map frame */void MapRestoreFrame(Map map){ map->frame = map->save;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -