#include <stdlib.h>#include <stdio.h>#include "prm.h"#include "quad.h"#include "circ.h"Include dependency graph for prm.c:

Go to the source code of this file.
Compounds | |
| struct | _prm |
| Primitive data structure: The primitives are stored in memory in a circular doubly-linked list, with a pointer to the head of the list. More... | |
Primitive data structure module | |
See definitions of public data types and public functions in hearder file "prm.h". For specification see class notes of course CIV-2801 "Fundamentos de Computacao Grafica Aplicada", period 2005.2. Revisions:
| |
| Prm * | prmCreateEmpty (void) |
| This function allocates memory for a new primitive, sets a null value for its next and previous pointers, sets an undefined primitive type, sets a null geometry data pointer, and sets a null color, selection flag, and height values. | |
| void | prmInsertFront (Prm *prm) |
| This function inserts a given primitive at the beginning of the list of primitives. | |
| void | prmInsertBack (Prm *prm) |
| This function inserts a given primitive at the end of the list of primitives. | |
| void | prmRemoveFromList (Prm *prm) |
| This function removes the given primitive from the list. | |
| Prm * | prmGetFirstSelected (void) |
| This function returns a pointer to the first primitive in the list that is selected. | |
| Prm * | prmCreateFront (PrmType type) |
| This function creates a new primitive, puts it at the beginning of the list of primitives. | |
| Prm * | prmCreateBack (PrmType type) |
| This function creates a new primitive, puts it at the end of the list of primitives. | |
| void | prmDelete (Prm *prm) |
| This function removes a primitive, which is specified by the given pointer, from the current list of primitives and releases memory that is used by it. | |
| void | prmDeleteSelected (void) |
| This function removes all the primitives in the list that are selected, i.e., that have their selection flag set. | |
| void | prmDeleteList (void) |
| This function realeases the memory that is used by the current list of primitives and resets the list. | |
| Prm * | prmFirst (void) |
| This function returns a pointer to the first primitive of the current list. | |
| Prm * | prmLast (void) |
| This function returns a pointer to the last primitive of the current list. | |
| Prm * | prmNext (Prm *prm) |
| This function returns a pointer to the next primitive in relation to the given primitive (given by its pointer). | |
| Prm * | prmPrevious (Prm *prm) |
| This function returns a pointer to the previous primitive in relation to the given primitive (given by its pointer). | |
| void | prmMoveFront (Prm *prm) |
| This function moves the given primitive (given by its pointer) to the first position in the list of primitives. | |
| void | prmMoveBack (Prm *prm) |
| This function moves the given primitive (given by its pointer) to the last position in the list of primitives. | |
| int | prmGetType (Prm *prm) |
| This function returns (as its value) a code indicating the type of the given primitive (given by its pointer). | |
| void | prmRead (Prm *prm, FILE *fd) |
| This function reads geometry data of a given primitive (given by its pointer) from a file (given by its pointer) and loads the data into the primitive attributes. | |
| void | prmWrite (Prm *prm, FILE *fd) |
| This function writes the geometry attribute data of a given primitive (given by its pointer) to a file (given by its pointer). | |
| int | prmGetNPts (Prm *prm) |
| This function returns (as its value) the number of vertices of the given primitive (given by its pointer). | |
| void | prmSetCoords (Prm *prm, int id, double x, double y) |
| This function replaces the x and y coordinates of a vertex of the given primitive (given by its pointer) by the given pair of coordinates. | |
| void | prmGetCoords (Prm *prm, int id, double *x, double *y) |
| This function returns the x and y coordinates of a vertex of the given primitive (given by its pointer). | |
| void | prmSet1stPt (Prm *prm, double x, double y) |
| This function is used during interactive construction of a primitive. | |
| void | prmSet2ndPt (Prm *prm, double x, double y) |
| This function is used during interactive construction of a primitive. | |
| void | prmSelectAll () |
| This function selects all the primitives in the current list of primitives, i.e., it sets the selection flag of all the primitives. | |
| void | prmSelect (Prm *prm) |
| This function selects the given primitive (given by its pointer), i.e., it sets the selection flag of the primitive. | |
| void | prmUnselect (Prm *prm) |
| This function unselects the given primitive (given by its pointer), i.e., it resets (sets to null) the selection flag of the primitive. | |
| void | prmUnselectAll () |
| This function unselects all the primitives in the current list of primitives, i.e., it resets (sets to null) the selection flag of all the primitives. | |
| int | prmCheckSelected (Prm *prm) |
| This function returns the selection status (false = 0; true = 1) of the given primitive (given by its pointer). | |
| void | prmSetColor (Prm *prm, long int color) |
| This function sets the color of the given primitive (given by its pointers). | |
| long int | prmGetColor (Prm *prm) |
| This function returns the color of the given primitive (given by its pointers). | |
| void | prmSetHeight (Prm *prm, double height) |
| This function sets the height of the given primitive (given by its pointers). | |
| double | prmGetHeight (Prm *prm) |
| This function returns the height of the given primitive (given by its pointers). | |
| int | prmPickArea (Prm *prm, double x, double y) |
| This function checks whether a given point is in the interior of a given primitive (given by its pointer). | |
| int | prmPickVertex (Prm *prm, double x, double y, double tol, int *id) |
| This function selects a vertex on the boundary of a given primitive based on the given point position. | |
| int | prmPickSide (Prm *prm, double x, double y, double tol, int *id) |
| This function selects a side on the boundary of a given primitive based on the given point position. | |
| void | prmTranslate (Prm *prm, double dx, double dy) |
| This function translates the given primitive (given by its pointer). | |
| void | prmTranslateVertex (Prm *prm, int id, double dx, double dy) |
| This function translates a vertex of a given primitive (given by its pointer) using the given translation factors. | |
| void | prmTranslateSide (Prm *prm, int id, double dx, double dy) |
| This function translates the two vertices of a side of a given primitive (given by its pointer) using the given translation factors. | |
| void | prmGetBox (Prm *prm, double *xmin, double *xmax, double *ymin, double *ymax) |
| This function returns the limiting rectangle that involves the given primitive (given by its pointer). | |
| int | prmGetGlobalBox (double *xmin, double *xmax, double *ymin, double *ymax) |
| This function returns the limiting rectangle that involves all the primitives in the current list. | |
| void | prmDisplayBoundary (Prm *prm) |
| This function displays the boundary of the given primitive (given by its pointer). | |
| void | prmDisplayInterior (Prm *prm) |
| This function displays the interior of the given primitive (given by its pointer). | |
| void | prmDisplaySolid (Prm *prm) |
| Function to display a solid version of a given primitive. | |
| void | prmHighltSolid (Prm *prm) |
| Function to highlight a solid version of a given primitive. | |
| void | prmDisplayZbuffer (Prm *prm) |
| Function to send a solid version of a given primitive to the zbuffer module to be projected and displayed. | |
| Prm * | prm_head = 0L |
| Head of doubly-linked list of primitives. | |
|
|
This function returns the selection status (false = 0; true = 1) of the given primitive (given by its pointer).
Definition at line 562 of file prm.c. Referenced by dspModel(). |
|
|
This function creates a new primitive, puts it at the end of the list of primitives. An empty primitive of the given type is created. The special case of a current empty list is also treated. The head pointer to the list is modified in this case.
Definition at line 266 of file prm.c. References circCreate(), _prm::geom, PRM_CIRC, PRM_QUAD, prmCreateEmpty(), prmInsertBack(), PrmType, quadCreate(), and _prm::type. Referenced by prmioInterpret(). |
|
|
This function allocates memory for a new primitive, sets a null value for its next and previous pointers, sets an undefined primitive type, sets a null geometry data pointer, and sets a null color, selection flag, and height values.
Definition at line 123 of file prm.c. References _prm::color, _prm::geom, _prm::height, _prm::next, _prm::prev, PRM_UNDEF, _prm::sel, and _prm::type. Referenced by prmCreateBack(), and prmCreateFront(). |
|
|
This function creates a new primitive, puts it at the beginning of the list of primitives. An empty primitive of the given type is created. The head pointer to the list is modified accordingly. The special case of a current empty list is also treated.
Definition at line 238 of file prm.c. References circCreate(), _prm::geom, PRM_CIRC, PRM_QUAD, prmCreateEmpty(), prmInsertFront(), PrmType, quadCreate(), and _prm::type. Referenced by prmioInterpret(). |
|
|
This function removes a primitive, which is specified by the given pointer, from the current list of primitives and releases memory that is used by it. It is assumed that the given pointer is really a valid pointer to an existing primitive. The head pointer to the list of primitives may be modified accordingly. The special case of a resulting empty list is also treated.
Definition at line 294 of file prm.c. References circDelete(), _prm::geom, PRM_CIRC, PRM_QUAD, prmRemoveFromList(), quadDelete(), and _prm::type. Referenced by prmDeleteSelected(). |
|
|
This function realeases the memory that is used by the current list of primitives and resets the list. The function sets a null value for its head pointer. Definition at line 327 of file prm.c. Referenced by prjOpenModel(), and prjQuit(). |
|
|
This function removes all the primitives in the list that are selected, i.e., that have their selection flag set. The head pointer to the list of primitives may be modified accordingly. The special case of a resulting empty list is also treated. Definition at line 316 of file prm.c. References prmDelete(), and prmGetFirstSelected(). |
|
|
This function displays the boundary of the given primitive (given by its pointer). The function only deals with the geometric attributes of the primitive. This means that other attributes such as foreground color, line style, or mark type are specified outside this function. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 742 of file prm.c. References circDisplayBoundary(), _prm::geom, PRM_CIRC, PRM_QUAD, quadDisplayBoundary(), and _prm::type. |
|
|
This function displays the interior of the given primitive (given by its pointer). The interior area is filled with the currently specified background color. The function only deals with the geometric attributes of the primitive. This means that other attributes such as background color or interior style are specified outside this function. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 759 of file prm.c. References circDisplayInterior(), _prm::geom, PRM_CIRC, PRM_QUAD, quadDisplayInterior(), and _prm::type. |
|
|
Function to display a solid version of a given primitive. The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height. This function fills the solid prism faces with the current color. It uses OpenGL display functions.
Definition at line 776 of file prm.c. References circDisplaySolid(), _prm::geom, PRM_CIRC, PRM_QUAD, prmGetHeight(), quadDisplaySolid(), and _prm::type. |
|
|
Function to send a solid version of a given primitive to the zbuffer module to be projected and displayed. The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height.
Definition at line 810 of file prm.c. References circDisplayZbuffer(), _prm::geom, PRM_CIRC, PRM_QUAD, prmGetColor(), prmGetHeight(), quadDisplayZbuffer(), and _prm::type. |
|
|
This function returns a pointer to the first primitive of the current list.
Definition at line 334 of file prm.c. Referenced by drvRedisplay(), dspModel(), prjBuildDisplayList(), prjGetHeightFac(), prjPckPrm(), prjSetHeightFac(), prjZbufferSnapShot(), and prmioWriteList(). |
|
||||||||||||||||||||||||
|
This function returns the limiting rectangle that involves the given primitive (given by its pointer). This rectangle is the primitive bounding box, which is parallel to the x and y axes, with the minimum and maximum x and y coordinates of the primitive's vertices. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 714 of file prm.c. References circGetBox(), _prm::geom, PRM_CIRC, PRM_QUAD, quadGetBox(), and _prm::type. |
|
|
This function returns the color of the given primitive (given by its pointers). The color is returned in a long integer with a coded RGB color (adopted in the CD graphics system). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 577 of file prm.c. References _prm::color. Referenced by dspPrm(), prmDisplayZbuffer(), and prmioWriteList(). |
|
||||||||||||||||||||
|
This function returns the x and y coordinates of a vertex of the given primitive (given by its pointer). The vertex is indicated by an index to the local array of vertices of the primitive. Nothing will happen if the given index is outside the range of valid indices of vertices. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 483 of file prm.c. References circGetCoords(), _prm::geom, PRM_CIRC, PRM_QUAD, quadGetCoords(), and _prm::type. |
|
|
This function returns a pointer to the first primitive in the list that is selected.
Definition at line 224 of file prm.c. Referenced by prmDeleteSelected(). |
|
||||||||||||||||||||
|
This function returns the limiting rectangle that involves all the primitives in the current list. This rectangle is the bounding box of the current set of primitives, which is parallel to the x and y axes, with the minimum and maximum x and y coordinates of all primitive's vertices.
Definition at line 732 of file prm.c. Referenced by prjOpenModel(). |
|
|
This function returns the height of the given primitive (given by its pointers). The height is used only in 3D applications. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 591 of file prm.c. References _prm::height. Referenced by prjGetHeightFac(), prmDisplaySolid(), prmDisplayZbuffer(), prmHighltSolid(), and prmioWriteList(). |
|
|
This function returns (as its value) the number of vertices of the given primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 445 of file prm.c. References circGetNPts(), _prm::geom, PRM_CIRC, PRM_QUAD, quadGetNPts(), and _prm::type. |
|
|
This function returns (as its value) a code indicating the type of the given primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 404 of file prm.c. References _prm::type. Referenced by prmioWriteList(). |
|
|
Function to highlight a solid version of a given primitive. The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height. This function displays the edges of the prism and draws marks at its vertices, all with the current color. It uses OpenGL display functions.
Definition at line 793 of file prm.c. References circHighltSolid(), _prm::geom, PRM_CIRC, PRM_QUAD, prmGetHeight(), quadHighltSolid(), and _prm::type. |
|
|
This function inserts a given primitive at the end of the list of primitives. It handles the case of an empty list (this is indicated by a null head pointer). In this case, it sets the previous and next pointers of the given primitive pointing to itself and initializes the list head pointer to point to the given primitive. Otherwise, it sets the next pointer of the given primitive to point to the current first primitive, sets the previous pointer of the given primitive to point to the current last primitive, sets the previous pointer of the current first primitive to point to the given primitive, and sets the next pointer of the current last primitive to point to the given primitive. If the list is not empty, the list head pointer is not changed.
Definition at line 188 of file prm.c. Referenced by prmCreateBack(), and prmMoveBack(). |
|
|
This function inserts a given primitive at the beginning of the list of primitives. It handles the case of an empty list (this is indicated by a null head pointer). In this case, it sets the previous and next pointers of the given primitive pointing to itself. Otherwise, it sets the next pointer of the given primitive to point to the current first primitive, sets the previous pointer of the given primitive to point to the current last primitive, sets the previous pointer of the current first primitive to point to the given primitive, and sets the next pointer of the current last primitive to point to the given primitive. In any case, the list head pointer will point to the given primitive.
Definition at line 164 of file prm.c. Referenced by prmCreateFront(), and prmMoveFront(). |
|
|
This function returns a pointer to the last primitive of the current list.
|
|
|
This function moves the given primitive (given by its pointer) to the last position in the list of primitives. It is assumed that the given pointer is really a valid pointer to an existing primitive. Nothing will happen if the given primitive is already the last of the list.
Definition at line 383 of file prm.c. References _prm::prev, prmInsertBack(), and prmRemoveFromList(). Referenced by prmioInterpret(). |
|
|
This function moves the given primitive (given by its pointer) to the first position in the list of primitives. It is assumed that the given pointer is really a valid pointer to an existing primitive. The head pointer to the list is modified accordingly. Nothing will happen if the given primitive is already the first of the list.
Definition at line 362 of file prm.c. References prmInsertFront(), and prmRemoveFromList(). Referenced by prmioInterpret(). |
|
|
This function returns a pointer to the next primitive in relation to the given primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 348 of file prm.c. Referenced by dspModel(), prjPckPrm(), and prmioWriteList(). |
|
||||||||||||||||
|
This function checks whether a given point is in the interior of a given primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 598 of file prm.c. References circPickArea(), _prm::geom, PRM_CIRC, PRM_QUAD, quadPickArea(), and _prm::type. Referenced by prjPckPrm(). |
|
||||||||||||||||||||||||
|
This function selects a side on the boundary of a given primitive based on the given point position.
Definition at line 641 of file prm.c. References circPickSide(), _prm::geom, PRM_CIRC, PRM_QUAD, quadPickSide(), and _prm::type. |
|
||||||||||||||||||||||||
|
This function selects a vertex on the boundary of a given primitive based on the given point position.
Definition at line 619 of file prm.c. References circPickVertex(), _prm::geom, PRM_CIRC, PRM_QUAD, quadPickVertex(), and _prm::type. |
|
|
This function returns a pointer to the previous primitive in relation to the given primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
|
|
||||||||||||
|
This function reads geometry data of a given primitive (given by its pointer) from a file (given by its pointer) and loads the data into the primitive attributes. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 411 of file prm.c. References circRead(), _prm::geom, PRM_CIRC, PRM_QUAD, quadRead(), and _prm::type. Referenced by prmioInterpret(). |
|
|
This function removes the given primitive from the list. The primitive removal from list modifies the next pointer of the previous primitive in the list and modifies the previous pointer of the next primitive in the list. This function also treates the situation of a single primitive list, in which case the list head pointer is reset to a null value. Otherwise, the list head pointer will be affected only in the case in which the primitive being removed is at the beginning of the list: the new list head pointer will point to the primitive next to the primitive being removed.
Definition at line 209 of file prm.c. Referenced by prmDelete(), prmMoveBack(), and prmMoveFront(). |
|
|
This function selects the given primitive (given by its pointer), i.e., it sets the selection flag of the primitive. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 541 of file prm.c. Referenced by prjSelectPrm(). |
|
|
This function selects all the primitives in the current list of primitives, i.e., it sets the selection flag of all the primitives.
|
|
||||||||||||||||
|
This function is used during interactive construction of a primitive. It sets the x and y coordinates of the first construction point of the given primitive (given by its pointer) by the given pair of coordinates. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 500 of file prm.c. References circSet1stPt(), _prm::geom, PRM_CIRC, PRM_QUAD, quadSet1stPt(), and _prm::type. |
|
||||||||||||||||
|
This function is used during interactive construction of a primitive. It sets the x and y coordinates of the second construction point of the given primitive (given by its pointer) by the given pair of coordinates. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 517 of file prm.c. References circSet2ndPt(), _prm::geom, PRM_CIRC, PRM_QUAD, quadSet2ndPt(), and _prm::type. |
|
||||||||||||
|
This function sets the color of the given primitive (given by its pointers). The color is given by a long integer with a coded RGB color (adopted in the CD graphics system). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 570 of file prm.c. References _prm::color. Referenced by prmioInterpret(). |
|
||||||||||||||||||||
|
This function replaces the x and y coordinates of a vertex of the given primitive (given by its pointer) by the given pair of coordinates. The vertex is indicated by an index to the local array of vertices of the primitive. Nothing will happen if the given index is outside the range of valid indices of vertices. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 466 of file prm.c. References circSetCoords(), _prm::geom, PRM_CIRC, PRM_QUAD, quadSetCoords(), and _prm::type. |
|
||||||||||||
|
This function sets the height of the given primitive (given by its pointers). The height is used only in 3D applications. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 584 of file prm.c. References _prm::height. Referenced by prjSetHeightFac(), and prmioInterpret(). |
|
||||||||||||||||
|
This function translates the given primitive (given by its pointer). All the vertices of the primitive are translated by the given translation factors. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 663 of file prm.c. References circTranslate(), _prm::geom, PRM_CIRC, PRM_QUAD, quadTranslate(), and _prm::type. Referenced by prmioInterpret(). |
|
||||||||||||||||||||
|
This function translates the two vertices of a side of a given primitive (given by its pointer) using the given translation factors. The target side is indicated by an index, which should have a value between 0 and the number of primitive vertices minus one. Nothing will happen if the given index is outside this range. The index of a side corresponds to the index of its first vertex. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 697 of file prm.c. References circTranslateSide(), _prm::geom, PRM_CIRC, PRM_QUAD, quadTranslateSide(), and _prm::type. Referenced by prmioInterpret(). |
|
||||||||||||||||||||
|
This function translates a vertex of a given primitive (given by its pointer) using the given translation factors. The target vertex is indicated by its index to the primitive coordinate vector, which should have a value between 0 and the number of vertices minus one. Nothing will happen if the given index is outside this range. It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 680 of file prm.c. References circTranslateVertex(), _prm::geom, PRM_CIRC, PRM_QUAD, quadTranslateVertex(), and _prm::type. Referenced by prmioInterpret(). |
|
|
This function unselects the given primitive (given by its pointer), i.e., it resets (sets to null) the selection flag of the primitive. It is assumed that the given pointer is really a valid pointer to an existing primitive.
|
|
|
This function unselects all the primitives in the current list of primitives, i.e., it resets (sets to null) the selection flag of all the primitives.
Definition at line 555 of file prm.c. Referenced by prjSelectPrm(). |
|
||||||||||||
|
This function writes the geometry attribute data of a given primitive (given by its pointer) to a file (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing primitive.
Definition at line 428 of file prm.c. References circWrite(), _prm::geom, PRM_CIRC, PRM_QUAD, quadWrite(), and _prm::type. Referenced by prmioWriteList(). |
|
|
Head of doubly-linked list of primitives.
|
1.2.18