Image Component Library (ICL)
|
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::Point > | m_buf |
internal buffer More... | |
std::vector< int > | m_br |
optionally given bounding rect More... | |
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
The LineSampler replaces the former LineSampler class and the SampledLine class
The class uses several optimizations to speed up linesampling.
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;
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
icl::core::LineSampler::LineSampler | ( | const utils::Rect & | br | ) |
createe line sampler with given bounding rect
void icl::core::LineSampler::removeBoundingBox | ( | int | bufferSize | ) |
removes the bouding rect and sets the internal buffer size
Result icl::core::LineSampler::sample | ( | const utils::Point & | a, |
const utils::Point & | b | ||
) |
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
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
|
protected |
optionally given bounding rect
|
protected |
internal buffer