EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
EBGeometry::BoxFrameSDF< T > Class Template Reference

Signed distance field for the frame of a box: its twelve edges, as bars of square cross-section. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 BoxFrameSDF ()=default
 Default constructor. Constructs the frame of the cube [-0.5, 0.5]^3, with bars 0.1 thick.
 
 BoxFrameSDF (const Vec3T< T > &a_loCorner, const Vec3T< T > &a_hiCorner, T a_thickness)
 Full constructor.
 
 BoxFrameSDF (const BoxFrameSDF &)=default
 Copy constructor.
 
 BoxFrameSDF (BoxFrameSDF &&)=default
 Move constructor.
 
BoxFrameSDF & operator= (const BoxFrameSDF &)=default
 Copy assignment.
 
BoxFrameSDF & operator= (BoxFrameSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getLowCorner () const noexcept
 Get the lower corner of the box the frame fits.
 
const Vec3T< T > & getHighCorner () const noexcept
 Get the upper corner of the box the frame fits.
 
const T & getThickness () const noexcept
 Get the thickness of a bar.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the frame.
 
uint32_t getNumParts () const noexcept
 How many parts the shape has (see hasParts): its twelve bars.
 
uint32_t closestPart (const Vec3T< T > &a_point) const noexcept
 The part whose term decides the value at a point (see hasParts): the nearest bar, 4 a + 2 i + j for the bar along axis a (x, y, z) on the low (0) or high (1) side of the first (i) and the second (j) of the other two axes, in the order x, y, z. Where two bars meet, the one along the lower axis.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: the box the frame fits.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality = DistanceQuality::Exact
 How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
 

Protected Member Functions

Vec3T< T > barTerms (const Vec3T< T > &a_point) const noexcept
 The three bars that meet at the corner of the octant a point is in: the signed distance to the one along x, along y and along z.
 

Protected Attributes

Vec3T< T > m_loCorner = Vec3T<T>(T(-0.5), T(-0.5), T(-0.5))
 Lower corner of the box.
 
Vec3T< T > m_hiCorner = Vec3T<T>(T(0.5), T(0.5), T(0.5))
 Upper corner of the box.
 
T m_thickness = T(0.1)
 Thickness of a bar.
 

Detailed Description

template<class T>
class EBGeometry::BoxFrameSDF< T >

Signed distance field for the frame of a box: its twelve edges, as bars of square cross-section.

The frame fits the box between the two corners, and each bar is as thick as given, measured across it. The distance is exact. Outside, it is Quilez's box frame: the point is folded into one octant of the box, and the frame there is three bars meeting at a corner, the nearest of which is the distance. Inside, it is the distance to the box's outer faces or to the openings between the bars, which the nearest bar's depth undercuts where bars meet. Round its edges with Offset of a slightly smaller frame. By default the frame is that of the cube [-0.5, 0.5]^3, with bars 0.1 thick.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ BoxFrameSDF()

template<class T >
EBGeometry::BoxFrameSDF< T >::BoxFrameSDF ( const Vec3T< T > &  a_loCorner,
const Vec3T< T > &  a_hiCorner,
T  a_thickness 
)
inline

Full constructor.

Parameters
[in]a_loCornerLower corner of the box the frame fits (minimum x, y, z).
[in]a_hiCornerUpper corner. Each component must be strictly greater than that of a_loCorner.
[in]a_thicknessThickness of a bar, across it: positive, and less than half of the box's shortest side.

Member Function Documentation

◆ barTerms()

template<class T >
Vec3T< T > EBGeometry::BoxFrameSDF< T >::barTerms ( const Vec3T< T > &  a_point) const
inlineprotectednoexcept

The three bars that meet at the corner of the octant a point is in: the signed distance to the one along x, along y and along z.

Out of line on a device (the frame's solver): 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. A call costs little beside its three bars.

Parameters
[in]a_pointPosition.
Returns
The three distances.

◆ closestPart()

template<class T >
uint32_t EBGeometry::BoxFrameSDF< T >::closestPart ( const Vec3T< T > &  a_point) const
inlinenoexcept

The part whose term decides the value at a point (see hasParts): the nearest bar, 4 a + 2 i + j for the bar along axis a (x, y, z) on the low (0) or high (1) side of the first (i) and the second (j) of the other two axes, in the order x, y, z. Where two bars meet, the one along the lower axis.

Parameters
[in]a_pointPosition.
Returns
The part.

◆ computeBoundingVolume()

template<class T >
BoundingVolumes::AABBT< T > EBGeometry::BoxFrameSDF< T >::computeBoundingVolume ( ) const
inlinenoexcept

The shape's axis-aligned bounding box: the box the frame fits.

Returns
The bounding box.

◆ getHighCorner()

template<class T >
const Vec3T< T > & EBGeometry::BoxFrameSDF< T >::getHighCorner ( ) const
inlinenoexcept

Get the upper corner of the box the frame fits.

Returns
m_hiCorner.

◆ getLowCorner()

template<class T >
const Vec3T< T > & EBGeometry::BoxFrameSDF< T >::getLowCorner ( ) const
inlinenoexcept

Get the lower corner of the box the frame fits.

Returns
m_loCorner.

◆ getNumParts()

template<class T >
uint32_t EBGeometry::BoxFrameSDF< T >::getNumParts ( ) const
inlinenoexcept

How many parts the shape has (see hasParts): its twelve bars.

Returns
The count.

◆ getThickness()

template<class T >
const T & EBGeometry::BoxFrameSDF< T >::getThickness ( ) const
inlinenoexcept

Get the thickness of a bar.

Returns
m_thickness.

◆ operator=() [1/2]

template<class T >
BoxFrameSDF & EBGeometry::BoxFrameSDF< T >::operator= ( BoxFrameSDF< T > &&  )
default

Move assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T >
BoxFrameSDF & EBGeometry::BoxFrameSDF< T >::operator= ( const BoxFrameSDF< T > &  )
default

Copy assignment.

Returns
Reference to (*this).

◆ signedDistance()

template<class T >
T EBGeometry::BoxFrameSDF< T >::signedDistance ( const Vec3T< T > &  a_point) const
inlinenoexcept

Signed distance function for the frame.

Parameters
[in]a_pointPosition.
Returns
Signed distance from a_point to the surface; negative inside a bar.

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