MIRA
|
For detailed information see Geometry.
More...
Classes | |
class | BresenhamLineIterator |
Implements an iterator that is able to iterate over a Bresenham line point by point using the prefix ++operator and –operator. More... | |
class | GeneralBresenhamLineIterator< D, T, Drive, Res > |
This more general iterator basically follows the design of BresenhamLineIterator, but works on an arbitrary-dimensional line and handles real-valued start and end positions. More... | |
class | DistanceLUT |
This class creates a look up table (LUT) to calculate the minimum and maximum Euclidean distance between a point and cells that are arranged in a regular grid. More... | |
class | PointBase< T, D, Derived > |
The base template class of point, which covers the basic functionality of each point. More... | |
class | Point< T, D > |
General point class template. More... | |
class | Point< T, 2 > |
Specialization of Point for 2 dimensions with specialized constructors and converters. More... | |
class | Point< T, 3 > |
Specialization of Point for 3 dimensions with specialized constructors and converters. More... | |
class | RasterTransformation |
Map a rectangular area from one raster into another, with an arbitrary transformation (scale, translation, rotation) inbetween. More... | |
class | RectBase< T, D, Derived > |
The base class for rectangles. More... | |
class | Rect< T, D > |
Rect class for defining rectangles. More... | |
class | Rect< T, 2 > |
Specialization for 2D. More... | |
class | Rect< T, 3 > |
Specialization for 3D. More... | |
class | Size< T, D > |
Size class for defining sizes with different data types. More... | |
class | Size< T, 2 > |
Specialization for 2D with special members width() and height(). More... | |
class | Size< T, 3 > |
Specialization for 3D with special members width(),height() and depth(). More... | |
Functions | |
template<typename Visitor > | |
void | bresenham (int x0, int y0, int x1, int y1, Visitor &&visitor) |
Rasterizes a Bresenham line point by point starting at coordinate (x0,y0) and ending in (x1,y1). More... | |
template<typename Visitor > | |
void | bresenham (Point2i p0, Point2i p1, Visitor &&visitor) |
Different interface for standard Bresenham Algorithm. More... | |
template<typename Visitor > | |
void | bresenhamRunSlice (int x0, int y0, int x1, int y1, Visitor &&visitor) |
Rasterizes a Bresenham line starting at coordinate (x0,y0) and ending in (x1,y1). More... | |
template<typename Visitor > | |
void | bresenhamRunSlice (Point2i p0, Point2i p1, Visitor &&visitor) |
Different interface for Bresenham Run-Slice Algorithm. More... | |
template<typename PointType > | |
boost::geometry::model::ring< PointType > | createTriangle (const PointType &p1, const PointType &p2, const PointType &p3) |
The polygon is essentially a sequence of points with an edge also connecting the first and last point. More... | |
template<class TransformationInRegion , class Visitor > | |
void | rasterPolygon (const Polygon2f &polygon, const Rect2i ®ion, TransformationInRegion &&transformation, Visitor &&visitor) |
Function for rasterising a polygon. More... | |
template<class TransformationInRegion , class Visitor > | |
void | rasterPolygon (const Polygon2f &polygon, const Rect2i ®ion, TransformationInRegion &&transformation, Visitor &&visitor, uint precision) |
Function for rasterising a polygon. More... | |
template<typename Visitor > | |
void | rasterRect (int xl, int yl, int xr, int yr, Visitor &&visitor) |
Rasterizes an Rectangle (2D only). More... | |
template<typename Visitor > | |
void | rasterRect (const Rect2i &rect, Visitor &&visitor) |
Rasters a rect (see description above), same as above, just additional interface. More... | |
template<typename Visitor > | |
void | rasterTriangle (Point2i p0, Point2i p1, Point2i p2, Visitor &&visitor) |
Rasters a triangle scanline by scanline. More... | |
template<typename Visitor > | |
void | rasterTriangle (const Polygon2i &polygon, Visitor &&visitor) |
Same function as above, but with a nicer interface. More... | |
For detailed information see Geometry.
|
inline |
Rasterizes a Bresenham line point by point starting at coordinate (x0,y0) and ending in (x1,y1).
For each point on the line the visitors operator()(int x, int y) is called with the two parameters x,y that specify the coordinate of that point/pixel.
Therefore, the visitor must implement the following concept:
[in] | x0 | x coordinate of start point |
[in] | y0 | y coordinate of start point |
[in] | x1 | x coordinate of end point |
[in] | y1 | y coordinate of end point |
[in,out] | visitor | the visitor which implements the functionality, what to do with iterated points |
Different interface for standard Bresenham Algorithm.
(Detailed description see bresenham.)
[in] | p0 | start point |
[in] | p1 | end point |
[in,out] | visitor | the visitor which implements the functionality, what to do with iterated points |
|
inline |
Rasterizes a Bresenham line starting at coordinate (x0,y0) and ending in (x1,y1).
Detailed information on Bresenhams run-slice algorithm and source code can be found here: http://www.phatcode.net/res/224/files/html/ch36/36-01.html.
In contrast to the above method this method uses the Bresenham run-slice algorithm which is significantly faster for lines that mainly move along the x-axis (with small slope). Instead of rastering the line pixel by pixel the line is rastered segment by segment scanline by scanline from top to bottom. For each segment the visitor's operator()(int x, int y, int length) is called with the parameters x,y,length that specify the coordinate starting position of the segment and its length.
Therefore, the visitor must implement the following concept:
Example:
In this example the visitor would be called three times with the segments (1,2,2), (3,3,3) and (6,4,2).
Detailed information on Bresenhams Run-Slice Algorithm and source code can be found here: http://www.phatcode.net/res/224/files/html/ch36/36-01.html
[in] | x0 | x coordinate of start point |
[in] | y0 | y coordinate of start point |
[in] | x1 | x coordinate of end point |
[in] | y1 | y coordinate of end point |
[in,out] | visitor | the visitor which implements the functionality, what to do with iterated points |
[in] | x0 | : the x-coordinate of the first point |
[in] | y0 | : the y-coordinate of the first point |
[in] | x1 | : the x-coordinate of the second point |
[in] | y1 | : the y-coordinate of the second point |
[in] | visitor | : the visitor which has to provide the slice concept |
Different interface for Bresenham Run-Slice Algorithm.
Description see bresenhamRunSlice.
[in] | p0 | start point |
[in] | p1 | end point |
[in,out] | visitor | the visitor which implements the functionality, what to do with iterated points |
|
inline |
The polygon is essentially a sequence of points with an edge also connecting the first and last point.
Since Eigen could not deal with polygons, we switch to support boost geometry more.
An example with 3D points
Boost::geometry polygons support so called "inner" and "outer" rings. The outer ring defines the outer bound, where the polygon begins. The inner rings define holes inside the polygon. There is only one outer ring but multiple inner rings are possible.
However in MIRA we only use polygons that have no inner rings. There we use boost::geometry::model::ring instead of boost::geometry::polygon!
NOTE: Intersections of polygons and rasterization can only be established on 2D polygons. More dimensions for intersection are not supported in boost::geometry and a 3D rasterization needs a triangulation before.
Function to create a triangle from three given points. The function returns a boost::geometry::ring.
[in] | p1 | : first point of the triangle |
[in] | p2 | : second point of the triangle |
[in] | p3 | : third point of the triangle |
void mira::rasterPolygon | ( | const Polygon2f & | polygon, |
const Rect2i & | region, | ||
TransformationInRegion && | transformation, | ||
Visitor && | visitor | ||
) |
Function for rasterising a polygon.
The algorithm determines the intersection with the lines y = n + 0.5, where n is a natural number. These intersections are sorted and grouped in pairs to determine intervals. These intervals are visited by the visitor.
[in] | polygon | : polygon to be rasterised |
[in] | region | : region in which the converted polygon is rasterised |
[in] | transformation | : transformation of the given polygon to another coordinate system (e.g. world to image coordinates). This functor is required to take a Point2f as its argument and to return a Point2f. |
[in] | visitor | Function that takes (x,y) for a visited pixel/cell as two int values and returns a bool value, indicating whether the function should stop iterating here. |
void mira::rasterPolygon | ( | const Polygon2f & | polygon, |
const Rect2i & | region, | ||
TransformationInRegion && | transformation, | ||
Visitor && | visitor, | ||
uint | precision | ||
) |
Function for rasterising a polygon.
The algorithm determines the intersection with the lines y = (n + 0.5)/p, where n is a natural number and p is a precision. These intersections are sorted and grouped in pairs to determine intervals. Intervals with the same |_y_| are merged. These intervals are visited by the visitor.
[in] | polygon | : polygon to be rasterised |
[in] | region | : region in which the converted polygon is rasterised |
[in] | transformation | : transformation of the given polygon to another coordinate system (e.g. world to image coordinates). This functor is required to take a Point2f as its argument and to return a Point2f. |
[in] | visitor | Function that takes (x,y) for a visited pixel/cell as two int values and returns a bool value, indicating whether the function should stop iterating here. |
[in] | precision | Determines how many intersections are calculated between n and n+1. |
|
inline |
Rasterizes an Rectangle (2D only).
Instead of rastering the line pixel by pixel the rectangle is rastered scanline by scanline from top to bottom. For each segment the visitor's operator()(int x, int y, int length) is called with the parameters x, y, and length that specify the coordinate starting position of the segment and its length.
Therefore, the visitor must implement the following concept:
[in] | xl | : the x-coordinate of the lower left corner |
[in] | yl | : the y-coordinate of the lower left corner |
[in] | xr | : the x-coordinate of the upper right corner |
[in] | yr | : the y-coordinate of the upper right corner |
[in] | visitor | : the visitor to execute scanline computations |
|
inline |
Rasters a rect (see description above), same as above, just additional interface.
Rasters a triangle scanline by scanline.
For each scanline the visitors operator()(int xl, int xr, int y) is called, where the parameters xl and xr specify the the x-coordinates of the left and right triangle boundary in the scanline y. For filling a triangle e.g. the pixels between xl and xr (including xl and xr) in line y must be filled.
Therefore, the visitor must implement the following concept:
[in] | p0 | : the first triangle point |
[in] | p1 | : the second triangle point |
[in] | p2 | : the third triangle point |
[in] | visitor | : the visitor to execute scanline computations (see description above) |
|
inline |
Same function as above, but with a nicer interface.
For full description see
[in] | polygon | a polygon with three points OR a polygon with 4 points, where the first and last point are equal |
[in,out] | visitor | the visitor to execute scanline computations |