Image Component Library (ICL)
Classes | Public Member Functions | Protected Attributes | List of all members
icl::core::LineSampler Class Reference

Utility class for line sampling. More...

#include <LineSampler.h>

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 More...
 
 LineSampler (const utils::Rect &br)
 createe line sampler with given bounding rect More...
 
void setBoundingRect (const utils::Rect &bb)
 sets a bounding rect for line sampling More...
 
void removeBoundingBox (int bufferSize)
 removes the bouding rect and sets the internal buffer size More...
 
Result sample (const utils::Point &a, const utils::Point &b)
 samples a line between a and b More...
 
void sample (const utils::Point &a, const utils::Point &b, std::vector< utils::Point > &dst)
 samples the line into the given destination vector More...
 

Protected Attributes

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

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

◆ LineSampler() [1/2]

icl::core::LineSampler::LineSampler ( int  maxLen = 0)

create linesampler with given maximum number of points

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

◆ LineSampler() [2/2]

icl::core::LineSampler::LineSampler ( const utils::Rect br)

createe line sampler with given bounding rect

Member Function Documentation

◆ removeBoundingBox()

void icl::core::LineSampler::removeBoundingBox ( int  bufferSize)

removes the bouding rect and sets the internal buffer size

◆ sample() [1/2]

Result icl::core::LineSampler::sample ( const utils::Point a,
const utils::Point b 
)

samples a line between a and b

◆ sample() [2/2]

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

◆ setBoundingRect()

void icl::core::LineSampler::setBoundingRect ( const utils::Rect bb)

sets a bounding rect for line sampling

The result will only contain pixels that are within this rectangle

Member Data Documentation

◆ m_br

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

optionally given bounding rect

◆ m_buf

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

internal buffer


The documentation for this class was generated from the following file: