#include <stdio.h>
#include <string.h>
#include "prmio.h"
#include "prm.h"
Include dependency graph for prmio.c:
Go to the source code of this file.
Primitive input/output module | |
See definitions of public functions in hearder file "prmio.h". For specification see class notes of course CIV-2801 "Fundamentos de Computacao Grafica Aplicada", period 2005.2. Revisions:
| |
int | prmioNextLabel (FILE *fd, char *label) |
This function finds the next "%" character in the input file and reads the label next to it. | |
long int | prmioGetColorCode (char *color_label) |
This function returns the RGB coded color that corresponds to a given color label. | |
void | prmioGetColorLabel (long int color, char *color_label) |
This function returns, in the given string variable, a color label that corresponds to a given RGB coded color. | |
int | prmioInterpret (FILE *fd) |
This function interprets the commands in the given file (given by a pointer to its descriptor structure) and creates in memory a list of primitives resulting from this interpretation. | |
void | prmioWriteList (FILE *fd) |
This function writes current primitive list in memory to the specified file. |
|
This function returns the RGB coded color that corresponds to a given color label.
Definition at line 92 of file prmio.c. References PRM_BLACK, PRM_BLUE, PRM_CYAN, PRM_DARK_BLUE, PRM_DARK_CYAN, PRM_DARK_GRAY, PRM_DARK_GREEN, PRM_DARK_MAGENTA, PRM_DARK_RED, PRM_DARK_YELLOW, PRM_GRAY, PRM_GREEN, PRM_MAGENTA, PRM_RED, PRM_WHITE, and PRM_YELLOW. Referenced by prmioInterpret(). |
|
This function returns, in the given string variable, a color label that corresponds to a given RGB coded color.
Definition at line 140 of file prmio.c. References PRM_BLACK, PRM_BLUE, PRM_CYAN, PRM_DARK_BLUE, PRM_DARK_CYAN, PRM_DARK_GRAY, PRM_DARK_GREEN, PRM_DARK_MAGENTA, PRM_DARK_RED, PRM_DARK_YELLOW, PRM_GRAY, PRM_GREEN, PRM_MAGENTA, PRM_RED, PRM_WHITE, and PRM_YELLOW. Referenced by prmioWriteList(). |
|
This function interprets the commands in the given file (given by a pointer to its descriptor structure) and creates in memory a list of primitives resulting from this interpretation. The following commands are currently treated (please, see documentation in header file "prm.h" concerning the functions used to create a list of primitives): CREATE.FRONT type Creates a new primitive with an empty geometry and puts it at the beginning of the list of primitives. The primitive type is indicated by an integer code: 1 for quadrilateral primitives 2 for circle primitives CREATE.BACK type Creates a new primitive with an empty geometry and puts it at the end of the list of primitives. The primitive type is indicated by an integer code: 1 for quadrilateral primitives 2 for circle primitives MOVE.FRONT Moves current primitive to the beginning of list of primitives. MOVE.BACK Moves current primitive to the end of list of primitives. SET.GEOM Replaces the geometry data of current primitive by the specified data: For quadrilateral primitives, its vertex coordinates: x0 y0 x1 y1 x2 y2 x3 y3 For circle primitives, its center coordinates and radius: xc yc r SET.COLOR color Specifies the color of current primitive. The color is indicated by one of the strings (sequence of characters) below: WHITE GRAY DARK_GRAY BLACK RED DARK_RED GREEN DARK_GREEN BLUE DARK_BLUE YELLOW DARK_YELLOW MAGENTA DARK_MAGENTA CYAN DARK_CYAN SET.HEIGHT height Specifies the height of current primitive. TRANSLATE dx dy Translates current primitive using specified translation factors (floating point numbers dx and dy). TRANSLATE.VERTEX id dx dy Translates one of the vertices of current primitive using specified translation factors (floating point numbers dx and dy). The target vertex is indicated by an integer number (id) between 0 and the number of primivite vertices minus one. TRANSLATE.SIDE id dx dy Translates one of the sides of current primitive using specified translation factors (floating point numbers dx and dy). The target side is indicated by an integer number (id) between 0 and the number of primivite vertices minus one. END Indicates the end of primitive file interpretation.
Definition at line 203 of file prmio.c. References prmCreateBack(), prmCreateFront(), prmioGetColorCode(), prmioNextLabel(), prmMoveBack(), prmMoveFront(), prmRead(), prmSetColor(), prmSetHeight(), prmTranslate(), prmTranslateSide(), prmTranslateVertex(), and PrmType. Referenced by prjOpenModel(). |
|
This function finds the next "%" character in the input file and reads the label next to it.
Definition at line 67 of file prmio.c. Referenced by prmioInterpret(). |
|
This function writes current primitive list in memory to the specified file. The format used to write the primitive list is the same used to interpret it (see function prmioInterpret above). The primitives are written in the same order that are positioned in the list and are indicated by their set of vertex coordinates. Therefore, the following commands are used to write primitive data to a file: CREATE.BACK type Specifies a new primitive with an empty geometry to be placed at the of the list of primitives. The primitive type is indicated by an integer code: 1 for quadrilateral primitives 2 for circle primitives SET.GEOM Specifies the geometry data of current primitive the following data: For quadrilateral primitives, its vertex coordinates: x0 y0 x1 y1 x2 y2 x3 y3 For circle primitives, its center coordinates and radius: xc yc r SET.COLOR color Specifies the color of current primitive. The color is indicated by one of the string (sequence of characteres) below: WHITE GRAY DARK_GRAY BLACK RED DARK_RED GREEN DARK_GREEN BLUE DARK_BLUE YELLOW DARK_YELLOW MAGENTA DARK_MAGENTA CYAN DARK_CYAN SET.HEIGHT height Specifies the height of current primitive. END Indicates the end of primitive specification.
Definition at line 298 of file prmio.c. References prmFirst(), prmGetColor(), prmGetHeight(), prmGetType(), prmioGetColorLabel(), prmNext(), and prmWrite(). |