EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions
EBGeometry::Fused Namespace Reference

Fused CSG: the expression builder's operations as types (see EBGeometry_Fused.hpp). More...

Namespaces

namespace  Detail
 Implementation details of the fused operations.
 

Classes

struct  AffineOp
 An affine map (translation, rotation, scaling, reflection, or a composition of them): the operand's value at the mapped point, times a value scale. More...
 
struct  BlurOp
 Blur: a weighted average of the operand's values at 27 points (CSGOps::blur()). More...
 
struct  CombineOp
 Union or intersection: the minimum or the maximum of the operands' values, in order. More...
 
struct  ComplementOp
 Complement: -v, inside and outside swapped. More...
 
struct  ElongateOp
 Elongation: the operand's value at p - clamp(p, -h, h). More...
 
struct  MollifyOp
 Mollification: the operand convolved with a bump kernel sampled on a grid (CSGOps::mollify()). More...
 
class  Node
 A fused composition: an operation applied to its operands, itself a shape (isShape). More...
 
struct  OperandList
 A list of operands, for the n-ary smooth operations (whose smoothing parameters follow the operands): Fused::SmoothUnion(Fused::operands(a, b, c), s). More...
 
struct  RepetitionOp
 Finite repetition: the minimum of the operand's value over all its copies (CSGOps::repetition()). More...
 
struct  ShiftOp
 Offset (v - r) or annulus (|v| - delta). More...
 
struct  SmoothCombineOp
 Smooth union or intersection: a smooth minimum (maximum) of the two smallest (largest) values. More...
 

Typedefs

using UnionOp = CombineOp< true >
 A union: the minimum of the operands' values.
 
using IntersectionOp = CombineOp< false >
 An intersection: the maximum of the operands' values.
 
template<class Op , class... Cs>
using NodeOf = Node< Op, Cs... >
 The shape type a Fused:: function returns for an operation and its operands.
 

Functions

template<class... Cs>
OperandList< Cs... > operands (const Cs &... a_operands)
 A list of operands for an n-ary smooth operation.
 
template<class C , class... Cs>
auto Union (const C &a_first, const Cs &... a_others)
 Union of shapes: the minimum of their values. One shape is returned as is.
 
template<class C , class... Cs>
auto Intersection (const C &a_first, const Cs &... a_others)
 Intersection of shapes: the maximum of their values. One shape is returned as is.
 
template<class A , class B , class... Bs>
auto Difference (const A &a_first, const B &a_second, const Bs &... a_others)
 Difference A \ (B1 u B2 u ...): max(A, -min_i Bi).
 
template<class C >
Node< ComplementOp, C > Complement (const C &a_operand)
 Complement: inside and outside swapped, -v.
 
template<class A , class B >
Node< SmoothCombineOp< ShapePrecision< A >, true >, A, B > SmoothUnion (const A &a_first, const B &a_second, const ShapePrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth union of two shapes: a smooth minimum of their values.
 
template<class... Cs>
auto SmoothUnion (const OperandList< Cs... > &a_operands, const ShapePrecision< typename Detail::TypeAt< 0, Cs... >::type > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth union of any number of shapes: a smooth minimum of the two smallest values (see EBGeometry::SmoothUnion()).
 
template<class A , class B >
Node< SmoothCombineOp< ShapePrecision< A >, false >, A, B > SmoothIntersection (const A &a_first, const B &a_second, const ShapePrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth intersection of two shapes: a smooth maximum of their values.
 
template<class... Cs>
auto SmoothIntersection (const OperandList< Cs... > &a_operands, const ShapePrecision< typename Detail::TypeAt< 0, Cs... >::type > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth intersection of any number of shapes: a smooth maximum of the two largest values.
 
template<class A , class B >
auto SmoothDifference (const A &a_first, const B &a_second, const ShapePrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth difference A \ B: the smooth intersection of A and the complement of B.
 
template<class A , class... Bs>
auto SmoothDifference (const A &a_first, const OperandList< Bs... > &a_others, const ShapePrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
 Smooth difference A \ (B1, B2, ...): the smooth intersection of A and the complement of each Bi.
 
template<class C >
auto Translate (const C &a_operand, const Vec3T< ShapePrecision< C > > &a_shift)
 Translate a shape by a shift.
 
template<class C >
auto Rotate (const C &a_operand, const ShapePrecision< C > a_degrees, const size_t a_axis)
 Rotate a shape about a coordinate axis through the origin.
 
template<class C >
auto Rotate (const C &a_operand, const ShapePrecision< C > a_degrees, const Vec3T< ShapePrecision< C > > &a_axis)
 Rotate a shape about an arbitrary axis through the origin.
 
template<class C >
auto Scale (const C &a_operand, const ShapePrecision< C > a_factor)
 Scale a shape uniformly about the origin: |s| times its value at p / s.
 
template<class C >
auto Reflect (const C &a_operand, const size_t a_axis)
 Reflect a shape in a coordinate plane through the origin.
 
template<class C >
Node< ShiftOp< ShapePrecision< C >, false >, C > Offset (const C &a_operand, const ShapePrecision< C > a_offset)
 Offset a shape's surface outward by a distance, v - r.
 
template<class C >
Node< ShiftOp< ShapePrecision< C >, true >, C > Annular (const C &a_operand, const ShapePrecision< C > a_delta)
 A shell around a shape's surface, |v| - delta.
 
template<class C >
Node< ElongateOp< ShapePrecision< C > >, C > Elongate (const C &a_operand, const Vec3T< ShapePrecision< C > > &a_elongation)
 Elongate a shape: stretch it by inserting a box of half-lengths h at the origin.
 
template<class C >
Node< RepetitionOp< ShapePrecision< C > >, C > FiniteRepetition (const C &a_operand, const Vec3T< ShapePrecision< C > > &a_period, const Vec3T< ShapePrecision< C > > &a_repeatLo, const Vec3T< ShapePrecision< C > > &a_repeatHi)
 Finite repetition: copies of a shape on a grid of tiles, the minimum over all of them (see EBGeometry::FiniteRepetition()).
 
template<class C >
Node< BlurOp< ShapePrecision< C > >, C > Blur (const C &a_operand, const ShapePrecision< C > a_blur, const ShapePrecision< C > a_alpha=ShapePrecision< C >(0.5))
 Blur a shape: a weighted average of its values at the 27 points p + d (i, j, k), i, j, k in {-1, 0, 1} (see EBGeometry::Blur()).
 
template<class C >
Node< MollifyOp< ShapePrecision< C > >, C > Mollify (const C &a_operand, const ShapePrecision< C > a_dist, const size_t a_samples)
 Mollify a shape: convolve it with a smooth bump kernel sampled on an n x n x n grid over [-r, r]^3 (see EBGeometry::Mollify()).
 

Detailed Description

Fused CSG: the expression builder's operations as types (see EBGeometry_Fused.hpp).

Typedef Documentation

◆ NodeOf

template<class Op , class... Cs>
using EBGeometry::Fused::NodeOf = typedef Node<Op, Cs...>

The shape type a Fused:: function returns for an operation and its operands.

Template Parameters
OpOperation.
CsOperand types.

Function Documentation

◆ Annular()

template<class C >
Node< ShiftOp< ShapePrecision< C >, true >, C > EBGeometry::Fused::Annular ( const C &  a_operand,
const ShapePrecision< C >  a_delta 
)
inline

A shell around a shape's surface, |v| - delta.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_deltaShell half-thickness (finite).
Returns
The shell.

◆ Blur()

template<class C >
Node< BlurOp< ShapePrecision< C > >, C > EBGeometry::Fused::Blur ( const C &  a_operand,
const ShapePrecision< C >  a_blur,
const ShapePrecision< C >  a_alpha = ShapePrecision< C >(0.5) 
)
inline

Blur a shape: a weighted average of its values at the 27 points p + d (i, j, k), i, j, k in {-1, 0, 1} (see EBGeometry::Blur()).

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_blurBlur distance d (finite, >= 0).
[in]a_alphaCenter weight factor in [0, 1]; 1 = no blur.
Returns
The blurred shape.

◆ Complement()

template<class C >
Node< ComplementOp, C > EBGeometry::Fused::Complement ( const C &  a_operand)
inline

Complement: inside and outside swapped, -v.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
Returns
The complement.

◆ Difference()

template<class A , class B , class... Bs>
auto EBGeometry::Fused::Difference ( const A &  a_first,
const B &  a_second,
const Bs &...  a_others 
)
inline

Difference A \ (B1 u B2 u ...): max(A, -min_i Bi).

Template Parameters
AOperand to subtract from.
BFirst operand to subtract.
BsThe others.
Parameters
[in]a_firstOperand to subtract from.
[in]a_secondFirst operand to subtract.
[in]a_othersThe others.
Returns
The difference.

◆ Elongate()

template<class C >
Node< ElongateOp< ShapePrecision< C > >, C > EBGeometry::Fused::Elongate ( const C &  a_operand,
const Vec3T< ShapePrecision< C > > &  a_elongation 
)
inline

Elongate a shape: stretch it by inserting a box of half-lengths h at the origin.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_elongationHalf-lengths h (finite, >= 0).
Returns
The elongated shape.

◆ FiniteRepetition()

template<class C >
Node< RepetitionOp< ShapePrecision< C > >, C > EBGeometry::Fused::FiniteRepetition ( const C &  a_operand,
const Vec3T< ShapePrecision< C > > &  a_period,
const Vec3T< ShapePrecision< C > > &  a_repeatLo,
const Vec3T< ShapePrecision< C > > &  a_repeatHi 
)
inline

Finite repetition: copies of a shape on a grid of tiles, the minimum over all of them (see EBGeometry::FiniteRepetition()).

Template Parameters
COperand type.
Parameters
[in]a_operandShape to repeat; its home copy sits in the tile around the origin.
[in]a_periodTile period along each axis (> 0).
[in]a_repeatLoTiles in the decreasing direction of each axis (>= 0; rounded to whole tiles).
[in]a_repeatHiTiles in the increasing direction of each axis (>= 0; rounded to whole tiles).
Returns
The repetition.

◆ Intersection()

template<class C , class... Cs>
auto EBGeometry::Fused::Intersection ( const C &  a_first,
const Cs &...  a_others 
)
inline

Intersection of shapes: the maximum of their values. One shape is returned as is.

Template Parameters
CFirst operand type.
CsThe others.
Parameters
[in]a_firstFirst operand.
[in]a_othersThe others.
Returns
The intersection.

◆ Mollify()

template<class C >
Node< MollifyOp< ShapePrecision< C > >, C > EBGeometry::Fused::Mollify ( const C &  a_operand,
const ShapePrecision< C >  a_dist,
const size_t  a_samples 
)
inline

Mollify a shape: convolve it with a smooth bump kernel sampled on an n x n x n grid over [-r, r]^3 (see EBGeometry::Mollify()).

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_distMollification distance r: the half-width of the sampling cube (finite).
[in]a_samplesSamples per axis n (between 1 and 64).
Returns
The mollified shape.

◆ Offset()

template<class C >
Node< ShiftOp< ShapePrecision< C >, false >, C > EBGeometry::Fused::Offset ( const C &  a_operand,
const ShapePrecision< C >  a_offset 
)
inline

Offset a shape's surface outward by a distance, v - r.

A bound (an offset of an exact distance by r >= 0 is exact, but the type cannot tell the sign of r).

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_offsetOffset distance r (finite); negative erodes.
Returns
The offset shape.

◆ operands()

template<class... Cs>
OperandList< Cs... > EBGeometry::Fused::operands ( const Cs &...  a_operands)
inline

A list of operands for an n-ary smooth operation.

Template Parameters
CsOperand types (shapes).
Parameters
[in]a_operandsOperands.
Returns
The list.

◆ Reflect()

template<class C >
auto EBGeometry::Fused::Reflect ( const C &  a_operand,
const size_t  a_axis 
)
inline

Reflect a shape in a coordinate plane through the origin.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_axisAxis normal to the plane (0, 1 or 2).
Returns
The reflected shape.

◆ Rotate() [1/2]

template<class C >
auto EBGeometry::Fused::Rotate ( const C &  a_operand,
const ShapePrecision< C >  a_degrees,
const size_t  a_axis 
)
inline

Rotate a shape about a coordinate axis through the origin.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_degreesAngle in degrees, counterclockwise seen from the positive end of the axis (finite).
[in]a_axisCoordinate axis (0, 1 or 2).
Returns
The rotated shape.

◆ Rotate() [2/2]

template<class C >
auto EBGeometry::Fused::Rotate ( const C &  a_operand,
const ShapePrecision< C >  a_degrees,
const Vec3T< ShapePrecision< C > > &  a_axis 
)
inline

Rotate a shape about an arbitrary axis through the origin.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_degreesAngle in degrees, counterclockwise seen from the positive end of the axis (finite).
[in]a_axisAxis direction (finite, non-zero; need not be normalized).
Returns
The rotated shape.

◆ Scale()

template<class C >
auto EBGeometry::Fused::Scale ( const C &  a_operand,
const ShapePrecision< C >  a_factor 
)
inline

Scale a shape uniformly about the origin: |s| times its value at p / s.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_factorScale factor s (finite, non-zero; a negative factor also reflects through the origin).
Returns
The scaled shape.

◆ SmoothDifference() [1/2]

template<class A , class B >
auto EBGeometry::Fused::SmoothDifference ( const A &  a_first,
const B &  a_second,
const ShapePrecision< A >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth difference A \ B: the smooth intersection of A and the complement of B.

Template Parameters
AOperand to subtract from.
BOperand to subtract.
Parameters
[in]a_firstOperand to subtract from.
[in]a_secondOperand to subtract.
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth difference.

◆ SmoothDifference() [2/2]

template<class A , class... Bs>
auto EBGeometry::Fused::SmoothDifference ( const A &  a_first,
const OperandList< Bs... > &  a_others,
const ShapePrecision< A >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth difference A \ (B1, B2, ...): the smooth intersection of A and the complement of each Bi.

Template Parameters
AOperand to subtract from.
BsOperands to subtract.
Parameters
[in]a_firstOperand to subtract from.
[in]a_othersOperands to subtract (Fused::operands(b1, b2, ...)).
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth difference.

◆ SmoothIntersection() [1/2]

template<class A , class B >
Node< SmoothCombineOp< ShapePrecision< A >, false >, A, B > EBGeometry::Fused::SmoothIntersection ( const A &  a_first,
const B &  a_second,
const ShapePrecision< A >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth intersection of two shapes: a smooth maximum of their values.

Template Parameters
AFirst operand type.
BSecond operand type.
Parameters
[in]a_firstFirst operand.
[in]a_secondSecond operand.
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth intersection.

◆ SmoothIntersection() [2/2]

template<class... Cs>
auto EBGeometry::Fused::SmoothIntersection ( const OperandList< Cs... > &  a_operands,
const ShapePrecision< typename Detail::TypeAt< 0, Cs... >::type >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth intersection of any number of shapes: a smooth maximum of the two largest values.

Template Parameters
CsOperand types.
Parameters
[in]a_operandsOperands (Fused::operands(a, b, ...)). One is returned as is.
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth intersection.

◆ SmoothUnion() [1/2]

template<class A , class B >
Node< SmoothCombineOp< ShapePrecision< A >, true >, A, B > EBGeometry::Fused::SmoothUnion ( const A &  a_first,
const B &  a_second,
const ShapePrecision< A >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth union of two shapes: a smooth minimum of their values.

Template Parameters
AFirst operand type.
BSecond operand type.
Parameters
[in]a_firstFirst operand.
[in]a_secondSecond operand.
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth union.

◆ SmoothUnion() [2/2]

template<class... Cs>
auto EBGeometry::Fused::SmoothUnion ( const OperandList< Cs... > &  a_operands,
const ShapePrecision< typename Detail::TypeAt< 0, Cs... >::type >  a_smooth,
const BlendKind  a_blend = BlendKind::Polynomial 
)
inline

Smooth union of any number of shapes: a smooth minimum of the two smallest values (see EBGeometry::SmoothUnion()).

Template Parameters
CsOperand types.
Parameters
[in]a_operandsOperands (Fused::operands(a, b, ...)). One is returned as is.
[in]a_smoothSmoothing length (> 0).
[in]a_blendBlend kind.
Returns
The smooth union.

◆ Translate()

template<class C >
auto EBGeometry::Fused::Translate ( const C &  a_operand,
const Vec3T< ShapePrecision< C > > &  a_shift 
)
inline

Translate a shape by a shift.

Template Parameters
COperand type.
Parameters
[in]a_operandOperand.
[in]a_shiftShift (finite).
Returns
The translated shape. A map of a map is one map, as in the expression builder.

◆ Union()

template<class C , class... Cs>
auto EBGeometry::Fused::Union ( const C &  a_first,
const Cs &...  a_others 
)
inline

Union of shapes: the minimum of their values. One shape is returned as is.

Template Parameters
CFirst operand type.
CsThe others.
Parameters
[in]a_firstFirst operand.
[in]a_othersThe others.
Returns
The union.