Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Protected Attributes
icl::core::LineSampler Class Reference

Utility class for line sampling. More...

#include <LineSampler.h>

List of all members.

Classes

struct  Result
 result type providing a Point-pointer and number of sample points More...

Public Member Functions

 LineSampler (int maxLen=0)
 create linesampler with given maximum number of points
 LineSampler (const utils::Rect &br)
 createe line sampler with given bounding rect
void setBoundingRect (const utils::Rect &bb)
 sets a bounding rect for line sampling
void removeBoundingBox (int bufferSize)
 removes the bouding rect and sets the internal buffer size
Result sample (const utils::Point &a, const utils::Point &b)
 samples a line between a and b
void sample (const utils::Point &a, const utils::Point &b, std::vector< utils::Point > &dst)
 samples the line into the given destination vector

Protected Attributes

std::vector< utils::Pointm_buf
 internal buffer
std::vector< int > m_br
 optionally given bounding rect

Detailed Description

Utility class for line sampling.

The LineSampler class provides a generic framework for efficient line renderig into images. It uses the Bresenham line sampling algorithm, that manages to render arbitray lines between two images points without any floating point operations. The LineSampler provides an internal bounding box check for save line rendering into images

Former Class Layout

The LineSampler replaces the former LineSampler class and the SampledLine class

Optimizations

The class uses several optimizations to speed up linesampling.

Performance

The LineSampler works faster than the core::Line class, be cause it does not have to allocate memory for the result. A test, conducted on a 2.4 GHz Core-2-Duo with an optimized build (-04 -march=native) demonstrated the speed of the line sampler. Rendering all possible lines staring at any pixel and pointing to the center of a VGA image (640x480 lines), takes about 650 ms. This leads to an approximate time of 0.002ms per line or in other words, 500 lines per millisecond;


Constructor & Destructor Documentation

create linesampler with given maximum number of points

As long a no bounding rect is given, bound-checks are suppressed

createe line sampler with given bounding rect


Member Function Documentation

removes the bouding rect and sets the internal buffer size

samples a line between a and b

void icl::core::LineSampler::sample ( const utils::Point a,
const utils::Point b,
std::vector< utils::Point > &  dst 
)

samples the line into the given destination vector

sets a bounding rect for line sampling

The result will only contain pixels that are within this rectangle


Member Data Documentation

std::vector<int> icl::core::LineSampler::m_br [protected]

optionally given bounding rect

std::vector<utils::Point> icl::core::LineSampler::m_buf [protected]

internal buffer


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines