|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Signed distance field for a profile turned about the y axis (a solid of revolution, as made on a lathe), or extruded along it. More...
#include <EBGeometry_Profile.hpp>

Public Member Functions | |
| ProfileSDF () | |
| Default constructor: the square from (0, 0) to (1, 1), turned, which is the cylinder of radius 1 from y = 0 to 1. | |
| ProfileSDF (const ProfileSDF &)=default | |
| Copy constructor. | |
| ProfileSDF (ProfileSDF &&)=default | |
| Move constructor. | |
| ProfileSDF & | operator= (const ProfileSDF &)=default |
| Copy assignment. | |
| ProfileSDF & | operator= (ProfileSDF &&)=default |
| Move assignment. | |
| bool | isRevolved () const noexcept |
| Whether the profile is turned about the y axis (otherwise it is extruded). | |
| T | getHeight () const noexcept |
| How far an extruded profile is extruded (0 for a turned one). | |
| uint32_t | getNumEdges () const noexcept |
| How many edges the outline has. | |
| ProfileEdge | getEdgeKind (const uint32_t a_edge) const noexcept |
| An edge's kind. | |
| const Vec2T< T > & | getEdgeStart (const uint32_t a_edge) const noexcept |
| Where an edge starts. | |
| const Vec2T< T > & | getEdgeEnd (const uint32_t a_edge) const noexcept |
| Where an edge ends: where the next one starts. | |
| const Vec2T< T > & | getEdgeControl (const uint32_t a_edge) const noexcept |
| An arc's center, or a Bezier curve's control point (unused for a straight edge). | |
| uint32_t | getEdgePart (const uint32_t a_edge) const noexcept |
| The part an edge belongs to. | |
| bool | isOnAxis (const uint32_t a_edge) const noexcept |
| Whether an edge lies on the axis of a turned profile: it turns into a line, which is no surface, and is left out of the distance. | |
| bool | isCounterclockwise () const noexcept |
| Whether the outline runs counterclockwise in its plane (its inside on the left of each edge, the r axis first and h second for a turned profile, u first and v second for an extruded one), as it was drawn. | |
| T | profileDistance (const Vec2T< T > &a_point) const noexcept |
| The signed distance from a point to the outline, in its plane; negative inside. | |
| T | signedDistance (const Vec3T< T > &a_point) const noexcept |
| Signed distance function for the solid. | |
| uint32_t | getNumParts () const noexcept |
| How many parts the shape has (see hasParts): the profile's, and an extrusion's two ends. | |
| uint32_t | closestPart (const Vec3T< T > &a_point) const noexcept |
| The part nearest a point (see hasParts): that of the nearest edge (the first on a tie), or, for an extrusion, the end the point is nearer, when the slab between the ends decides the distance there. | |
| BoundingVolumes::AABBT< T > | computeBoundingVolume () const noexcept |
| The shape's axis-aligned bounding box: that of the outline, turned or extruded. | |
| Vec2T< T > | inPlane (const Vec3T< T > &a_point) const noexcept |
| Where a point is in the outline's plane: (sqrt(x^2 + z^2), y) turned, (x, z) extruded. | |
Static Public Member Functions | |
| static ProfileSDF | revolve (const Profile< T > &a_profile) |
| A profile turned about the y axis: its point (r, h) sweeps the circle of radius r at height y = h. | |
| static ProfileSDF | extrude (const Profile< T > &a_profile, T a_height) |
| A profile extruded along y: its point (u, v) is (x, z) = (u, v), from y = 0 to the height. | |
Static Public Attributes | |
| static constexpr DistanceQuality | distanceQuality = DistanceQuality::Exact |
| How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface. | |
| static constexpr uint32_t | MaxEdges = Profile<T>::MaxEdges |
| The most edges a profile can have. | |
Protected Member Functions | |
| void | build (const Profile< T > &a_profile, bool a_revolved, T a_height, const char *a_who) |
| Sets the shape from a profile. | |
| uint32_t | nearestEdge (const Vec2T< T > &a_point, T &a_squared) const noexcept |
| The nearest edge to a point in the plane, and the square of its distance. | |
| bool | insideOutline (const Vec2T< T > &a_point) const noexcept |
| Whether a point in the plane is inside the outline: the ray from it towards +u crosses the outline an odd number of times (arcs and curves split where they turn back in v). | |
Protected Attributes | |
| uint32_t | m_numEdges = 0U |
| Number of edges. | |
| uint32_t | m_numParts = 0U |
| Number of the profile's parts. | |
| uint32_t | m_revolved = 1U |
| 1 if turned, 0 if extruded. | |
| uint32_t | m_counterclockwise = 1U |
| 1 if the outline runs counterclockwise in its plane, 0 if clockwise: which side of each edge is outside. | |
| T | m_height = T(0) |
| An extrusion's height. | |
| Vec2T< T > | m_lo |
| The low corner of the outline's box in its plane. | |
| Vec2T< T > | m_hi |
| The high corner of the outline's box in its plane. | |
| Array< Vec2T< T >, MaxEdges > | m_points |
| Where each edge starts. | |
| Array< Vec2T< T >, MaxEdges > | m_controls |
| Each arc's center, or each Bezier curve's control point. | |
| Array< uint8_t, MaxEdges > | m_kinds |
| Each edge's kind (a ProfileEdge). | |
| Array< uint8_t, MaxEdges > | m_parts |
| Each edge's part. | |
Static Protected Attributes | |
| static constexpr uint8_t | OnAxis = 0x80U |
| The bit of m_kinds that marks a straight edge on the axis of a turned profile, which is no surface. | |
Signed distance field for a profile turned about the y axis (a solid of revolution, as made on a lathe), or extruded along it.
A profile (see Profile) is a closed outline of straight edges, circular arcs and quadratic Bezier curves. Turned (revolve()), its point (r, h) sweeps the circle of radius r about the y axis at height y = h, so the solid is the outline's inside turned about the axis; every point of the outline must have r >= 0, and edges may lie on the axis. Extruded (extrude()), its point (u, v) is (x, z) = (u, v), from y = 0 to the height. Move or turn either with Translate and Rotate, like TorusSDF and ConeSDF.
The distance is exact. That to the outline in its plane is exact (a straight edge's and an arc's in closed form, a quadratic Bezier curve's from the roots of a cubic, polished by Newton steps), and its sign comes from how often a ray in the plane crosses the outline, each arc and curve taken as its pieces that run one way in v. Turned, the distance to the solid is the outline's at (sqrt(x^2 + z^2), y); extruded, it is the outline's at (x, z) combined with that to the slab between the ends, as for any extrusion. The edges are held in the shape itself, in arrays of fixed size, so it is trivially copyable and needs no pool.
Part k is edge k's part (see Profile); an extrusion's ends are the two parts after them, the one at y = 0 first. By default the shape is the square from (0, 0) to (1, 1), turned: the cylinder of radius 1 from y = 0 to 1.
| T | Floating-point precision. |
|
protected |
Sets the shape from a profile.
| [in] | a_profile | The profile. |
| [in] | a_revolved | Whether it is turned. |
| [in] | a_height | An extrusion's height. |
| [in] | a_who | The factory's name, for the messages. |
|
noexcept |
The part nearest a point (see hasParts): that of the nearest edge (the first on a tie), or, for an extrusion, the end the point is nearer, when the slab between the ends decides the distance there.
Out of line on a device, as profileDistance().
| [in] | a_point | Position. |
|
noexcept |
The shape's axis-aligned bounding box: that of the outline, turned or extruded.
|
static |
A profile extruded along y: its point (u, v) is (x, z) = (u, v), from y = 0 to the height.
| [in] | a_profile | The profile. |
| [in] | a_height | How far it is extruded; finite and positive. |
|
inlinenoexcept |
An arc's center, or a Bezier curve's control point (unused for a straight edge).
| [in] | a_edge | The edge, below getNumEdges(). |
|
inlinenoexcept |
Where an edge ends: where the next one starts.
| [in] | a_edge | The edge, below getNumEdges(). |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
How far an extruded profile is extruded (0 for a turned one).
|
inlinenoexcept |
How many edges the outline has.
|
inlinenoexcept |
How many parts the shape has (see hasParts): the profile's, and an extrusion's two ends.
|
inlinenoexcept |
Where a point is in the outline's plane: (sqrt(x^2 + z^2), y) turned, (x, z) extruded.
| [in] | a_point | Position. |
|
protectednoexcept |
Whether a point in the plane is inside the outline: the ray from it towards +u crosses the outline an odd number of times (arcs and curves split where they turn back in v).
| [in] | a_point | The point in the plane. |
|
inlinenoexcept |
Whether the outline runs counterclockwise in its plane (its inside on the left of each edge, the r axis first and h second for a turned profile, u first and v second for an extruded one), as it was drawn.
|
inlinenoexcept |
Whether an edge lies on the axis of a turned profile: it turns into a line, which is no surface, and is left out of the distance.
| [in] | a_edge | The edge, below getNumEdges(). |
|
inlinenoexcept |
Whether the profile is turned about the y axis (otherwise it is extruded).
|
protectednoexcept |
The nearest edge to a point in the plane, and the square of its distance.
| [in] | a_point | The point in the plane. |
| [out] | a_squared | The square of the distance. |
|
default |
Copy assignment.
|
default |
Move assignment.
|
noexcept |
The signed distance from a point to the outline, in its plane; negative inside.
Out of line on a device (its loop over the edges is the whole distance): inlined, it would be copied into every level of every tape kernel, whatever shapes the tape holds, which makes the device compile of every tape kernel much slower.
| [in] | a_point | The point, as (r, h) for a turned profile or (u, v) for an extruded one. |
|
static |
A profile turned about the y axis: its point (r, h) sweeps the circle of radius r at height y = h.
| [in] | a_profile | The profile; every point of it must have r >= 0. |
|
noexcept |
Signed distance function for the solid.
Out of line on a device, whole (not only profileDistance()): what a tape's evaluator inlines of a shape is copied into every level of every tape kernel, and the few lines around the outline's distance were enough to raise the plain tape kernels' register count.
| [in] | a_point | Position. |