Main Page | Data Structures | Directories | File List | Data Fields | Globals

bresenham.h File Reference

A generic Bresenham line algorithm. More...

#include "project_utilities.h"

Go to the source code of this file.

Defines

#define BRESENHAM_H   1
 The standard guard against including the same header twice.

Functions

bresenham_linep_t bresenham_from_s_coord (int32_t first_col, int32_t first_row, int32_t last_col, int32_t last_row)
 Wrapper to construct a Bresenham line context from signed coordinates.
int bresenham_next_s (bresenham_linep_t bline, int32_t *col, int32_t *row)
 Iterate the Bresenham line context, generating the next coordinate pair.
bresenham_linep_t bresenham_from_coord (uint32_t first_col, uint32_t first_row, uint32_t last_col, uint32_t last_row)
 Wrapper to construct a Bresenham line context from unsigned coordinates.
int bresenham_next (bresenham_linep_t bline, uint32_t *col, uint32_t *row)
 Iterate the Bresenham line context, generating the next coordinate pair.
void demolish_bresenham (bresenham_linep_t *blinehandle)
 Destroy a Bresenham line context.

Variables

typedefBEGIN_C_DECLARATIONS
struct Bresenham_line
bresenham_linep_t
 An opaque pointer to the line tracking state.


Detailed Description

A generic Bresenham line algorithm.

We can hide the implementaion details of the Bresenham line algorithm behind an interface that only exposes some generic object construction and destruction operations, and an iterator that generates the next set of coordinates.

Author:
University of Arizona Digital Image Analysis Lab
Date:
1999, 2004
Version:
Id
bresenham.h,v 1.1 2005/03/22 20:26:18 mmunro Exp

Definition in file bresenham.h.


Function Documentation

bresenham_linep_t bresenham_from_coord uint32_t  first_col,
uint32_t  first_row,
uint32_t  last_col,
uint32_t  last_row
 

Wrapper to construct a Bresenham line context from unsigned coordinates.

The context records the state of the algorithm that will generate pairs of discrete coordinates for a series of steps approximating the line linking the first and last points.

See also:
bresenham_from_bcoord
Parameters:
[in] first_col the column-coordinate of the first point.
[in] first_row the row-coordinate of the first point.
[in] last_col the column-coordinate of the last point.
[in] last_row the row-coordinate of the last point.
Returns:
A pointer to the state of the Bresenham context at the first point.

Definition at line 279 of file bresenham.c.

bresenham_linep_t bresenham_from_s_coord int32_t  first_col,
int32_t  first_row,
int32_t  last_col,
int32_t  last_row
 

Wrapper to construct a Bresenham line context from signed coordinates.

The context records the state of the algorithm that will generate pairs of discrete coordinates for a series of steps approximating the line linking the first and last points.

See also:
bresenham_from_bcoord
Parameters:
[in] first_col the column-coordinate of the first point.
[in] first_row the row-coordinate of the first point.
[in] last_col the column-coordinate of the last point.
[in] last_row the row-coordinate of the last point.
Returns:
A pointer to the state of the Bresenham context at the first point.

Definition at line 260 of file bresenham.c.

Referenced by Sadie_Plot_ProfileCmd().

int bresenham_next bresenham_linep_t  bline,
uint32_t *  col,
uint32_t *  row
 

Iterate the Bresenham line context, generating the next coordinate pair.

As constructed, the line context will always represent at least one point (even if the first point coincides with the last point), and so we can iterate it at least once; however once we've obtained the coordinates of the last point further iterations are incorrect (think of the context as being just off the end of the line). An iteration produces the current coordinate pair in the sequence of discrete points that approximate the straight line joining the first to the last point, and modifies the internals of the context to prepare the next point. The return value is a Boolean flag that is false iff further iterations are possible.

Parameters:
[in,out] bline points to the structure recording the state to iterate.
[out] col where to deposit the current column coordinate.
[out] row where to deposit the current row coordinate.
Returns:
True if off the end of the line, false if we can iterate again.

Definition at line 303 of file bresenham.c.

References logerr_assert, LOGERR_DEBUG, and LOGERR_FUNC.

Referenced by Sadie_Plot_ProfileCmd().

int bresenham_next_s bresenham_linep_t  bline,
int32_t *  col,
int32_t *  row
 

Iterate the Bresenham line context, generating the next coordinate pair.

Just a variation for signed coordinates.

See also:
bresenham_next
Parameters:
[in,out] bline points to the structure recording the state to iterate.
[out] col where to deposit the current column coordinate.
[out] row where to deposit the current row coordinate.
Returns:
True if off the end of the line, false if we can iterate again.

Definition at line 332 of file bresenham.c.

References logerr_assert, LOGERR_DEBUG, and LOGERR_FUNC.

void demolish_bresenham bresenham_linep_t blinehandle  ) 
 

Destroy a Bresenham line context.

A simple free() would suffice to reclaim the storage allocated by the current Bresenham line context constructors, but we don't want to guarantee this for all future versions of this code.

Parameters:
[out] blinehandle points to the pointer to be freed (and set NULL).

Definition at line 359 of file bresenham.c.

References logerr_assert, LOGERR_CRIT, and LOGERR_FUNC.

Referenced by Sadie_Plot_ProfileCmd().


Generated on Fri Jul 8 14:55:01 2005 for tclSadie by  doxygen 1.4.2