|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
A closed outline in a plane, of straight edges, circular arcs and quadratic Bezier curves, for ProfileSDF to turn about an axis or extrude. Host only; not a shape. More...
#include <EBGeometry_Profile.hpp>

Classes | |
| struct | Edge |
| One edge of the outline. More... | |
Public Member Functions | |
| Profile (const Vec2T< T > &a_start) | |
| Starts an outline at a point. | |
| Profile & | lineTo (const Vec2T< T > &a_point) |
| Draws a straight edge. | |
| Profile & | arcTo (const Vec2T< T > &a_point, T a_radius) |
| Draws a circular arc, the shorter of the two of its radius between its ends (at most a half circle). | |
| Profile & | quadTo (const Vec2T< T > &a_control, const Vec2T< T > &a_point) |
| Draws a quadratic Bezier curve. One whose control point lies on the line between its ends, halfway, is a straight edge, and drawn as one. | |
| Profile & | cubicTo (const Vec2T< T > &a_control1, const Vec2T< T > &a_control2, const Vec2T< T > &a_point, T a_tolerance) |
| Draws a cubic Bezier curve, as quadratic ones that stay within a distance of it. | |
| std::vector< Edge > | closedEdges () const |
| The outline's edges, closed: with the closing edge, when the outline does not end where it started. | |
| const Vec2T< T > & | getCurrentPoint () const noexcept |
| Where the outline is now: where the last edge ended. | |
Static Public Attributes | |
| static constexpr uint32_t | MaxEdges = 96U |
| The most edges a profile can have, a cubic's pieces and the closing edge included. It keeps a ProfileSDF small enough to pass to a kernel by value, in both precisions. | |
Protected Member Functions | |
| void | checkEnd (const Vec2T< T > &a_point, const char *a_who, uint32_t a_count) const |
| Checks a point an edge ends at, and that the outline has room for more edges. | |
Protected Attributes | |
| Vec2T< T > | m_start |
| The first point. | |
| Vec2T< T > | m_current |
| Where the last edge ended. | |
| std::vector< Edge > | m_edges |
| The edges drawn. | |
| uint32_t | m_parts = 0U |
| How many parts the edges drawn belong to. | |
A closed outline in a plane, of straight edges, circular arcs and quadratic Bezier curves, for ProfileSDF to turn about an axis or extrude. Host only; not a shape.
The outline is drawn from a first point, one edge at a time, each from where the last ended, and closes itself with a straight edge back to the first point (none when the last edge ends there). A cubic Bezier curve is drawn as quadratic ones that stay within a given distance of it. The outline may be drawn in either direction, but must not cross or touch itself, which is not checked: the surface's outward normals are taken from the direction the outline runs in, overall, and on an outline that crosses itself they point inward on part of it.
Edge k is the k-th edge drawn (a cubic's pieces in order), the closing edge last, and each edge belongs to a part: the k-th call that drew it, the closing edge being the last part. A cubic's pieces are one part, so that a curve drawn as one is picked as one surface.
| T | Floating-point precision. |
|
explicit |
Starts an outline at a point.
| [in] | a_start | The first point; finite. |
| Profile & EBGeometry::Profile< T >::arcTo | ( | const Vec2T< T > & | a_point, |
| T | a_radius | ||
| ) |
Draws a circular arc, the shorter of the two of its radius between its ends (at most a half circle).
| [in] | a_point | Where it ends; finite, and not where the outline is now. |
| [in] | a_radius | Its radius, signed: positive turns left (counterclockwise about the center), negative right. Its size must be at least half the distance between the ends; half of it draws a half circle. |
|
protected |
Checks a point an edge ends at, and that the outline has room for more edges.
| [in] | a_point | The point. |
| [in] | a_who | The function, for the messages. |
| [in] | a_count | How many edges are to be added. |
| std::vector< Edge > EBGeometry::Profile< T >::closedEdges | ( | ) | const |
The outline's edges, closed: with the closing edge, when the outline does not end where it started.
| Profile & EBGeometry::Profile< T >::cubicTo | ( | const Vec2T< T > & | a_control1, |
| const Vec2T< T > & | a_control2, | ||
| const Vec2T< T > & | a_point, | ||
| T | a_tolerance | ||
| ) |
Draws a cubic Bezier curve, as quadratic ones that stay within a distance of it.
The curve is split into equal stretches of its parameter, as few as keep each stretch's quadratic within the tolerance: the distance between a cubic and the quadratic that matches its ends and its tangents there shrinks with the cube of the stretch. All of them are one part.
| [in] | a_control1 | Its first control point; finite. |
| [in] | a_control2 | Its second control point; finite. |
| [in] | a_point | Where it ends; finite, and not where the outline is now. |
| [in] | a_tolerance | How far the quadratic curves may stray from the cubic; finite and positive. The pieces it takes must fit within MaxEdges. |
|
inlinenoexcept |
Where the outline is now: where the last edge ended.
| Profile & EBGeometry::Profile< T >::lineTo | ( | const Vec2T< T > & | a_point | ) |
Draws a straight edge.
| [in] | a_point | Where it ends; finite, and not where the outline is now. |
| Profile & EBGeometry::Profile< T >::quadTo | ( | const Vec2T< T > & | a_control, |
| const Vec2T< T > & | a_point | ||
| ) |
Draws a quadratic Bezier curve. One whose control point lies on the line between its ends, halfway, is a straight edge, and drawn as one.
| [in] | a_control | Its control point; finite. |
| [in] | a_point | Where it ends; finite, and not where the outline is now. |