Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Circ Class Reference

#include <circ.h>

List of all members.
Date:
21-Jun-2010
Author:
Luiz F. Martha
Version:
1.1
This file contains the implementation of the circle primitive of current project. This class is derived from primitive base class (see header file "prm.h").

See class definition in hearder file "circ.h".

For specification see class notes of course CIV-2802 "Sistemas Graficos para Engenharia", period 2010.1.

Revisions:

  • Version 1.0 by L.F. Martha on 02-Jun-2010: Initial version. Stolen from Trab2 of CIV2801-2005.2 and modified.
  • Version 1.1 by L.F. Martha on 21-Jun-2010: Added object functions DisplaySolid, HighltSolid, and DisplayZbuffer.


 Circ ()
 This function creates a new circle primitive.
 Circ (int back)
 This function creates a new circle primitive.
virtual ~Circ ()
 This function removes a circle primitive from the current list of primitives and releases memory that is used by it.
void Read (FILE *fd)
 This function reads geometry data of current circle primitive from a file (given by its pointer) and loads the data into the primitive attributes.
void Write (FILE *fd)
 This function writes the geometry attribute data of current circle primitive to a file (given by its pointer).
int GetNPts (void)
 This function returns (as its value) the number of vertices of the current circle primitive.
void SetCoords (int id, double x, double y)
 This function recomputes the radius of the current circle primitive based on the given point location and on the circle center point.
void GetCoords (int id, double *x, double *y)
 This function returns the x and y coordinates of a point of the current circle primitive.
void Set1stPt (double x, double y)
 This function is used during interactive construction of a circle primitive.
void Set2ndPt (double x, double y)
 This function is used during interactive construction of a circle primitive.
int PickArea (double x, double y)
 This function checks whether a given point is inside the current circle primitive.
int PickVertex (double x, double y, double tol, int *id)
 This function selects a vertex on the boundary of the current circle primitive based on the given point position.
int PickSide (double x, double y, double tol, int *id)
 This is a dummy function that does not do anything.
void Translate (double dx, double dy)
 This function translates the current circle primitive.
void TranslateVertex (int id, double dx, double dy)
 This function translates a vertex on the boundary of the current circle primitive using the given translation factors.
void TranslateSide (int id, double dx, double dy)
 This is a dummy function that does not do anything.
void GetBox (double *xmin, double *xmax, double *ymin, double *ymax)
 This function returns the limiting rectangle that involves the current circle primitive.
void DisplayBoundary (void)
 This function displays the boundary of the current circle primitive.
void DisplayInterior (void)
 This function displays the interior of the current circle primitive.
void DisplaySolid (void)
 Function to display a solid version of a circle primitive.
void HighltSolid (void)
 Function to highlight a solid version of a circle primitive.
void DisplayZbuffer (void)
 Function to send a solid version of a circle primitive to the zbuffer module to be projected and displayed.
void GetLateralNormal (Coord *p, Coord *normal)
 This functions computes the normal vector at a point on the current circle object.
static const int CIRC_SEGS = 32
 Number of segments to discretize circle.
static const double M_PI = 3.141592654
 The number PI.

Protected Attributes

Coord c
 Circle center.
double r
 Circle radius.


Constructor & Destructor Documentation

Circ::Circ  ) 
 

This function creates a new circle primitive.

It sets its default center coordinates - (0.0,0.0) - and radius (1.0) -, and puts it at the beginning of the list of primitives. The head pointer to the list is modified accordingly. The special case of a current empty list is also treated.

Definition at line 72 of file circ.cpp.

References c, Prm::PRM_CIRC, r, and Prm::type.

Circ::Circ int  back  ) 
 

This function creates a new circle primitive.

It sets its default center coordinates - (0.0,0.0) - and radius (1.0) -, and puts it at the end of the list of primitives if the "back" argument is true (1). If the "back" is false (0), the primitive is put at the beginning of the list of primitives. The head pointer to the list is modified accordingly. The special case of a current empty list is also treated.

Parameters:
back - back status (1 => end, 0 => beginning) (in)

Definition at line 87 of file circ.cpp.

References c, Prm::PRM_CIRC, r, and Prm::type.

Circ::~Circ  )  [virtual]
 

This function removes a circle primitive from the current list of primitives and releases memory that is used by it.

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 102 of file circ.cpp.


Member Function Documentation

void Circ::DisplayBoundary void   )  [virtual]
 

This function displays the boundary of the current circle primitive.

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.

Implements Prm.

Definition at line 305 of file circ.cpp.

References c, and r.

void Circ::DisplayInterior void   )  [virtual]
 

This function displays the interior of the current circle primitive.

The interior area is filled with the currently specified foreground color. The Canvas Draw (CD) graphics library is used to display the interior 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.

Implements Prm.

Definition at line 318 of file circ.cpp.

References c, and r.

void Circ::DisplaySolid void   )  [virtual]
 

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.

Parameters:
circ - pointer to target circle primitive (in)
height - primitive height (in)

Implements Prm.

Definition at line 327 of file circ.cpp.

References c, CIRC_SEGS, GetLateralNormal(), Prm::height, M_PI, and r.

void Circ::DisplayZbuffer void   )  [virtual]
 

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.

Parameters:
circ - pointer to target circle primitive (in)
height - primitive height (in)
color - primitive coded color (in)

Implements Prm.

Definition at line 460 of file circ.cpp.

References c, CIRC_SEGS, Prm::color, GetLateralNormal(), Prm::height, M_PI, r, Dsp::ZbfBeginPoly(), Dsp::ZbfEndPoly(), and Dsp::ZbfVertex().

void Circ::GetBox double *  xmin,
double *  xmax,
double *  ymin,
double *  ymax
[virtual]
 

This function returns the limiting rectangle that involves the current circle primitive.

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.

Parameters:
xmin,xmax - limiting x coordinates of primitive (out)
ymin,ymax - limiting y coordinates of primitive (out)

Implements Prm.

Definition at line 295 of file circ.cpp.

References c, and r.

void Circ::GetCoords int  id,
double *  x,
double *  y
[virtual]
 

This function returns the x and y coordinates of a point of the current circle primitive.

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.

Parameters:
id - index of target point (not used) (in)
x - point x coordinate (out)
y - point y coordinate (out)

Implements Prm.

Definition at line 159 of file circ.cpp.

References c, and r.

void Circ::GetLateralNormal Coord *  p,
Coord *  normal
[protected]
 

This functions computes the normal vector at a point on the current circle object.

Definition at line 113 of file circ.cpp.

References c.

Referenced by DisplaySolid(), and DisplayZbuffer().

int Circ::GetNPts void   )  [virtual]
 

This function returns (as its value) the number of vertices of the current circle primitive.

In this program it is assumed that a circle has four vertices: the four limiting points on its boundary.

The circle vertices are ordered in counter-clockwise order as shown below:

                      (id = 1)
                           +
                        *      *
                   *                *
                *                     *
   (id = 2) +                      + (id = 0)
                *                     *
                   *               *
                        *  +  *
                      (id = 3)

Returns:
The number 4.

Implements Prm.

Definition at line 145 of file circ.cpp.

void Circ::HighltSolid void   )  [virtual]
 

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.

Parameters:
circ - pointer to target circle primitive (in)
height - primitive height (in)

Implements Prm.

Definition at line 391 of file circ.cpp.

References c, CIRC_SEGS, Prm::height, M_PI, and r.

int Circ::PickArea double  x,
double  y
[virtual]
 

This function checks whether a given point is inside the current circle primitive.

Parameters:
x - x coordinate of given point (in)
y - y coordinate of given point (in)
Returns:
In case the given point is inside the given primitive, a true (1) status is returned. Otherwise, a false (0) status is returned.

Implements Prm.

Definition at line 182 of file circ.cpp.

References c, and r.

int Circ::PickSide double  x,
double  y,
double  tol,
int *  id
[virtual]
 

This is a dummy function that does not do anything.

It exists just for compatibility with other primitive types.

Returns:
The function returns a false (0) status.

Implements Prm.

Definition at line 231 of file circ.cpp.

int Circ::PickVertex double  x,
double  y,
double  tol,
int *  id
[virtual]
 

This function selects a vertex on the boundary of the current 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)

Parameters:
x - x coordinate of given point (in)
y - y coordinate of given point (in)
tol - tolerance value to check proximity (in)
id - returned vertex index (out)
Returns:
In case the given point is close one of the vertices on the boundary of the circle, the function returns a true (1) status and index (id) of the found vertex. Otherwise, the function returns a false (0) status.

Implements Prm.

Definition at line 199 of file circ.cpp.

References Prm::ABS(), c, and r.

void Circ::Read FILE *  fd  )  [virtual]
 

This function reads geometry data of current circle primitive from a file (given by its pointer) and loads the data into the primitive attributes.

Parameters:
fd - ponter to file descriptor (in)

Implements Prm.

Definition at line 131 of file circ.cpp.

References c, and r.

void Circ::Set1stPt double  x,
double  y
[virtual]
 

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 current circle primitive by the given pair of coordinates. The first construction point corresponds to the center point of the circle primitive.

Parameters:
x - first point x coordinate (in)
y - first point y coordinate (in)

Implements Prm.

Definition at line 167 of file circ.cpp.

References c.

void Circ::Set2ndPt double  x,
double  y
[virtual]
 

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 current circle primitive 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.

Parameters:
x - second point x coordinate (in)
y - second point y coordinate (in)

Implements Prm.

Definition at line 175 of file circ.cpp.

References c, and r.

void Circ::SetCoords int  id,
double  x,
double  y
[virtual]
 

This function recomputes the radius of the current circle primitive based on the given point location and on the circle center point.

The given index (id) is not used.

Parameters:
id - index of target point (not used) (in)
x - new point x coordinate (in)
y - new point y coordinate (in)

Implements Prm.

Definition at line 152 of file circ.cpp.

References c, and r.

void Circ::Translate double  dx,
double  dy
[virtual]
 

This function translates the current circle primitive.

The center point of the circle is translated by the given translation factors.

Parameters:
dx,dy - translation factors in x & y directions (in)

Implements Prm.

Definition at line 238 of file circ.cpp.

References c.

void Circ::TranslateSide int  id,
double  dx,
double  dy
[virtual]
 

This is a dummy function that does not do anything.

It exists just for compatibility with other primitive types.

Implements Prm.

Definition at line 289 of file circ.cpp.

void Circ::TranslateVertex int  id,
double  dx,
double  dy
[virtual]
 

This function translates a vertex on the boundary of the current circle primitive 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.

Parameters:
id - index of point to translate (1) (in)
dx,dy - translation factors in x & y directions (in)

Implements Prm.

Definition at line 246 of file circ.cpp.

References c, Prm::COORD_TOL, and r.

void Circ::Write FILE *  fd  )  [virtual]
 

This function writes the geometry attribute data of current circle primitive to a file (given by its pointer).

Parameters:
fd - ponter to file descriptor (in)

Implements Prm.

Definition at line 138 of file circ.cpp.

References c, and r.


Member Data Documentation

Coord Circ::c [protected]
 

Circle center.

Definition at line 67 of file circ.h.

Referenced by Circ(), DisplayBoundary(), DisplayInterior(), DisplaySolid(), DisplayZbuffer(), GetBox(), GetCoords(), GetLateralNormal(), HighltSolid(), PickArea(), PickVertex(), Read(), Set1stPt(), Set2ndPt(), SetCoords(), Translate(), TranslateVertex(), and Write().

const int Circ::CIRC_SEGS = 32 [static, protected]
 

Number of segments to discretize circle.

Definition at line 59 of file circ.cpp.

Referenced by DisplaySolid(), DisplayZbuffer(), and HighltSolid().

const double Circ::M_PI = 3.141592654 [static, protected]
 

The number PI.

Definition at line 63 of file circ.cpp.

Referenced by DisplaySolid(), DisplayZbuffer(), and HighltSolid().

double Circ::r [protected]
 

Circle radius.

Definition at line 71 of file circ.h.

Referenced by Circ(), DisplayBoundary(), DisplayInterior(), DisplaySolid(), DisplayZbuffer(), GetBox(), GetCoords(), HighltSolid(), PickArea(), PickVertex(), Read(), Set2ndPt(), SetCoords(), TranslateVertex(), and Write().


The documentation for this class was generated from the following files:
Generated on Mon Jun 21 12:45:19 2010 for Trab4 by  doxygen 1.4.2-20050421