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

Signed distance field for a lattice of walls along a triply periodic minimal surface: a gyroid, Schwarz's P or D (diamond) surface, or Neovius' surface. Porous media, heat exchangers, scaffolds. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Types

enum class  Kind : uint32_t { Gyroid , SchwarzP , SchwarzD , Neovius }
 Which surface, in coordinates scaled so that a cell is 2 pi. More...
 

Public Member Functions

 LatticeSDF ()=default
 Default constructor. Constructs a gyroid of unit cells, with walls 0.1 thick.
 
 LatticeSDF (const Kind a_kind, const Vec3T< T > &a_cellSize, const T a_thickness)
 Full constructor.
 
 LatticeSDF (const LatticeSDF &)=default
 Copy constructor.
 
 LatticeSDF (LatticeSDF &&)=default
 Move constructor.
 
LatticeSDF & operator= (const LatticeSDF &)=default
 Copy assignment.
 
LatticeSDF & operator= (LatticeSDF &&)=default
 Move assignment.
 
Kind getKind () const noexcept
 Get which surface this is.
 
const Vec3T< T > & getCellSize () const noexcept
 Get the cell size.
 
const T & getThickness () const noexcept
 Get the walls' thickness.
 
T field (const Vec3T< T > &a_point) const noexcept
 The surface's field f at a point, zero on the surface.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the lattice: a bound.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: unbounded.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality = DistanceQuality::Bound
 How far signedDistance() can be trusted as a distance: never more than the Euclidean distance.
 

Protected Attributes

Kind m_kind = Kind::Gyroid
 Which surface.
 
Vec3T< T > m_cellSize = Vec3T<T>::ones()
 The cell size.
 
T m_thickness = T(0.1)
 The walls' thickness.
 
T m_scale = T(1) / (T(2) * pi<T> * T(1.7320508075688772))
 One over the field's largest slope in space.
 

Detailed Description

template<class T>
class EBGeometry::LatticeSDF< T >

Signed distance field for a lattice of walls along a triply periodic minimal surface: a gyroid, Schwarz's P or D (diamond) surface, or Neovius' surface. Porous media, heat exchangers, scaffolds.

The four share their code: each is the zero set of a sum of products of sines and cosines f of the point scaled so that a cell is 2 pi, and the solid is the wall around it, |f| / g <= t / 2, with g the largest slope of f in space: G times 2 pi over the smallest cell size, G the largest gradient of f in the scaled coordinates (sqrt(3) for the gyroid, P and D, 7 for Neovius). The value is |f| / g - t / 2, a bound: it never changes faster than the distance. The wall is t thick where f is steepest, and thicker elsewhere. The lattice fills all of space; cut it to a part with an Intersection. By default it is a gyroid of unit cells with walls 0.1 thick.

Template Parameters
TFloating-point precision.

Member Enumeration Documentation

◆ Kind

template<class T >
enum class EBGeometry::LatticeSDF::Kind : uint32_t
strong

Which surface, in coordinates scaled so that a cell is 2 pi.

Enumerator
Gyroid 

sin x cos y + sin y cos z + sin z cos x.

SchwarzP 

cos x + cos y + cos z.

SchwarzD 

The diamond: sin x sin y sin z + sin x cos y cos z + cos x sin y cos z + cos x cos y sin z.

Neovius 

3 (cos x + cos y + cos z) + 4 cos x cos y cos z.

Constructor & Destructor Documentation

◆ LatticeSDF()

template<class T >
EBGeometry::LatticeSDF< T >::LatticeSDF ( const Kind  a_kind,
const Vec3T< T > &  a_cellSize,
const T  a_thickness 
)
inline

Full constructor.

Parameters
[in]a_kindWhich surface.
[in]a_cellSizeThe size of a cell along x, y and z, finite and positive.
[in]a_thicknessThe walls' thickness where they are thinnest, positive and less than the smallest cell size.

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box: unbounded.

Returns
The bounding box.

◆ field()

template<class T >
T EBGeometry::LatticeSDF< T >::field ( const Vec3T< T > &  a_point) const
inlinenoexcept

The surface's field f at a point, zero on the surface.

Out of line on a device (the lattice'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 trigonometry.

Parameters
[in]a_pointPosition.
Returns
The field.

◆ getCellSize()

template<class T >
const Vec3T< T > & EBGeometry::LatticeSDF< T >::getCellSize ( ) const
inlinenoexcept

Get the cell size.

Returns
m_cellSize.

◆ getKind()

template<class T >
Kind EBGeometry::LatticeSDF< T >::getKind ( ) const
inlinenoexcept

Get which surface this is.

Returns
m_kind.

◆ getThickness()

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

Get the walls' thickness.

Returns
m_thickness.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the lattice: a bound.

Parameters
[in]a_pointPosition.
Returns
A signed value whose magnitude never exceeds the distance from a_point to the surface; negative inside.

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