#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "prm.h"
#include "circ.h"
#include "cd.h"
#include "wd.h"
#include "dsp.h"
Include dependency graph for circ.c:
Go to the source code of this file.
Compounds | |
struct | _circ |
Circle primitive structure:. More... | |
Circle primitive module | |
See definitions of public data types and public functions in hearder file "circ.h". For specification see class notes of course CIV-2801 "Fundamentos de Computacao Grafica Aplicada", period 2005.2. Revisions:
| |
#define | CIRC_SEGS 32 |
#define | M_PI 3.141592654 |
void | circGetLateralNormal (Circ *circ, Coord *p, Coord *normal) |
Circ * | circCreate (void) |
This function creates a new circle primitive. | |
void | circDelete (Circ *circ) |
This function releases memory that is used by a circle primitive. | |
void | circRead (Circ *circ, FILE *fd) |
This function reads geometry data of a given circle primitive (given by its pointer) from a file (given by its pointer) and loads the data into the primitive attributes. | |
void | circWrite (Circ *circ, FILE *fd) |
This function writes the geometry attribute data of a given circle primitive (given by its pointer) to a file (given by its pointer). | |
int | circGetNPts (Circ *circ) |
This function returns (as its value) the number of vertices of the given circle primitive (given by its pointer). | |
void | circSetCoords (Circ *circ, int id, double x, double y) |
This function recomputes the radius of the given circle primitive (given by its pointer) based on the given point location and on the circle center point. | |
void | circGetCoords (Circ *circ, int id, double *x, double *y) |
This function returns the x and y coordinates of a point of the given circle primitive (given by its pointer). | |
void | circSet1stPt (Circ *circ, double x, double y) |
This function is used during interactive construction of a circle primitive. | |
void | circSet2ndPt (Circ *circ, double x, double y) |
This function is used during interactive construction of a circle primitive. | |
int | circPickArea (Circ *circ, double x, double y) |
This function checks whether a given point is inside a given circle primitive (given by its pointer). | |
int | circPickVertex (Circ *circ, double x, double y, double tol, int *id) |
This function selects a vertex on the boundary of a given circle primitive based on the given point position. | |
int | circPickSide (Circ *circ, double x, double y, double tol, int *id) |
This is a dummy function that does not do anything. | |
void | circTranslate (Circ *circ, double dx, double dy) |
This function translates the given circle primitive (given by its pointer). | |
void | circTranslateVertex (Circ *circ, int id, double dx, double dy) |
This function translates a vertex on the boundary of a given circle primitive (given by its pointer) using the given translation factors. | |
void | circTranslateSide (Circ *circ, int id, double dx, double dy) |
This is a dummy function that does not do anything. | |
void | circGetBox (Circ *circ, double *xmin, double *xmax, double *ymin, double *ymax) |
This function returns the limiting rectangle that involves the given circle primitive (given by its pointer). | |
void | circDisplayBoundary (Circ *circ) |
This function displays the boundary of the given circle primitive (given by its pointer). | |
void | circDisplayInterior (Circ *circ) |
This function displays the interior of the given circle primitive (given by its pointer). | |
void | circDisplaySolid (Circ *circ, double height) |
Function to display a solid version of a circle primitive. | |
void | circHighltSolid (Circ *circ, double height) |
Function to highlight a solid version of a circle primitive. | |
void | circDisplayZbuffer (Circ *circ, double height, long int color) |
Function to send a solid version of a circle primitive to the zbuffer module to be projected and displayed. |
|
Definition at line 62 of file circ.c. Referenced by circDisplayZbuffer(). |
|
Definition at line 65 of file circ.c. Referenced by circDisplayZbuffer(). |
|
This function creates a new circle primitive. It only allocates memory for a circle primitive, sets its default center coordinates - (0.0,0.0) - and radius (1.0), and returns a pointer to the allocated circle primitive.
Definition at line 105 of file circ.c. References _circ::c, _circ::r, _Coord::x, and _Coord::y. Referenced by prmCreateBack(), and prmCreateFront(). |
|
This function releases memory that is used by a circle primitive. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 126 of file circ.c. Referenced by prmDelete(). |
|
This function displays the boundary of the given circle primitive (given by its pointer). Marks are used to display the four vertices of the circle as indicated below: (id = 1) . + . . . . . (id = 2) + + (id = 0) . . . . . . + (id = 3) The Canvas Draw (CD) graphics library is used to display the boundary of the primitive. Please refer to CD documentation for additional information. The function only deals with the geometric attributes of the primitive. This means that other attributes such as foreground color, line style are specified outside this function. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 237 of file circ.c. Referenced by prmDisplayBoundary(). |
|
This function displays the interior of the given circle primitive (given by its pointer). The interior area is filled with the currently specified background color. The Canvas Draw (CD) graphics library is used to display the boundary of the primitive. Please refer to CD documentation for additional information. 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 circle primitive.
Definition at line 244 of file circ.c. Referenced by prmDisplayInterior(). |
|
Function to display a solid version of a circle primitive. The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height. This function creates a facet prism that approximates the resulting cylinder and fills the facets of the solid prism faces with the current color. It uses OpenGL display functions.
Definition at line 251 of file circ.c. Referenced by prmDisplaySolid(). |
|
Function to send a solid version of a circle 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 268 of file circ.c. References _circ::c, CIRC_SEGS, circGetLateralNormal(), dspZbfBeginPoly(), dspZbfEndPoly(), dspZbfVertex(), M_PI, _circ::r, _Coord::x, and _Coord::y. Referenced by prmDisplayZbuffer(). |
|
This function returns the limiting rectangle that involves the given circle 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 circle primitive.
Definition at line 229 of file circ.c. Referenced by prmGetBox(). |
|
This function returns the x and y coordinates of a point of the given circle primitive (given by its pointer). The returned point coordinates correspond to a point on the circle boundary, with x coordinate equal to the x coordinate of the center plus the radius value and with y coordinate equals to the y coordinate of the center. The given index (id) is not used. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 161 of file circ.c. Referenced by prmGetCoords(). |
|
Definition at line 88 of file circ.c. References _circ::c, _Coord::x, and _Coord::y. Referenced by circDisplayZbuffer(). |
|
This function returns (as its value) the number of vertices of the given circle primitive (given by its pointer). In this program it is assumed that a circle has four vertices: the four limiting points on its boundary. It is assumed that the given pointer is really a valid pointer to an existing circle primitive. The circle vertices are ordered in counter-clockwise order as shown below: (id = 1) . + . . . . . (id = 2) + + (id = 0) . . . . . . + (id = 3)
Definition at line 147 of file circ.c. Referenced by prmGetNPts(). |
|
Function to highlight a solid version of a circle primitive. The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height. This function creates a facet prism that approximates the resulting cylinder, 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 260 of file circ.c. Referenced by prmHighltSolid(). |
|
This function checks whether a given point is inside a given circle primitive (given by its pointer). It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 182 of file circ.c. Referenced by prmPickArea(). |
|
This is a dummy function that does not do anything. It exists just for compatibility with other primitive types.
Definition at line 201 of file circ.c. Referenced by prmPickSide(). |
|
This function selects a vertex on the boundary of a given circle primitive based on the given point position. The circle vertices are ordered in counter-clockwise order as shown below: (id = 1) . + . . . . . (id = 2) + + (id = 0) . . . . . . + (id = 3)
Definition at line 191 of file circ.c. Referenced by prmPickVertex(). |
|
This function reads geometry data of a given circle 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 circle primitive.
Definition at line 133 of file circ.c. Referenced by prmRead(). |
|
This function is used during interactive construction of a circle primitive. It sets the x and y coordinates of the first construction point of the given circle primitive (given by its pointer) by the given pair of coordinates. The first construction point corresponds to the center point of the circle primitive. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 168 of file circ.c. Referenced by prmSet1stPt(). |
|
This function is used during interactive construction of a circle primitive. It sets the x and y coordinates of the second construction point of the given circle primitive (given by its pointer) by the given pair of coordinates. The second construction point corresponds to any point on the boundary of the circle primitive. The given point coordinates are used to compute the new circle radius based on the current center point. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 175 of file circ.c. Referenced by prmSet2ndPt(). |
|
This function recomputes the radius of the given circle primitive (given by its pointer) based on the given point location and on the circle center point. The given index (id) is not used. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 154 of file circ.c. Referenced by prmSetCoords(). |
|
This function translates the given circle primitive (given by its pointer). The center point of the circle is translated by the given translation factors. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 209 of file circ.c. Referenced by prmTranslate(). |
|
This is a dummy function that does not do anything. It exists just for compatibility with other primitive types. Definition at line 223 of file circ.c. Referenced by prmTranslateSide(). |
|
This function translates a vertex on the boundary of a given circle primitive (given by its pointer) using the given translation factors. The given translation factors are used to compute the new coordinates of the target vertex of the circle. The circle vertices are ordered in counter-clockwise order as shown below: (id = 1) . + . . . . . (id = 2) + + (id = 0) . . . . . . + (id = 3) For vertices with id = 0 or id = 2, only the horizontal translation parameter (dx) is considered to compute the new position of the vertex. For vertices with id = 1 or id = 3, only the vertical translation parameter (dy) is considered to compute the new position of the vertex. The circle radius is recomputed based on the translated vertex coordinates and on the current center point. It is assumed that the given pointer is really a valid pointer to an existing circle primitive.
Definition at line 216 of file circ.c. Referenced by prmTranslateVertex(). |
|
This function writes the geometry attribute data of a given circle 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 circle primitive.
Definition at line 140 of file circ.c. Referenced by prmWrite(). |