EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Functions | Variables
EBGeometry_Fused.hpp File Reference

Fused CSG: the operations of the expression builder (EBGeometry_Expr.hpp) as types, which the compiler evaluates fully inlined, on the host and on a device. More...

#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>
#include "EBGeometry_Affine.hpp"
#include "EBGeometry_BVHUnion.hpp"
#include "EBGeometry_BoundingVolumes.hpp"
#include "EBGeometry_CSGOps.hpp"
#include "EBGeometry_DistanceQuality.hpp"
#include "EBGeometry_Expr.hpp"
#include "EBGeometry_GPU.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_Pool.hpp"
#include "EBGeometry_Vec.hpp"
#include "EBGeometry_FusedImplem.hpp"
#include "EBGeometry_CSGRayForms.hpp"
Include dependency graph for EBGeometry_Fused.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EBGeometry::Fused::Detail::Pack<>
 The empty pack. More...
 
struct  EBGeometry::Fused::Detail::Pack< S, Rest... >
 A pack: its first operand and the rest. More...
 
struct  EBGeometry::Fused::Detail::TypeAt< 0, C, Rest... >
 Type 0: the first. More...
 
struct  EBGeometry::Fused::Detail::TypeAt< I, C, Rest... >
 Type I > 0: type I - 1 of the rest. More...
 
struct  EBGeometry::Fused::Detail::Base< Handle >
 A value node's base: no pool, and an unset location for the code that asks for one. More...
 
struct  EBGeometry::Fused::Detail::Base< true >
 A pool-resident node's base: a PoolHandle, holding the location its operands resolve against. More...
 
struct  EBGeometry::Fused::Detail::Operands< Cs >
 The operands of a node, with the location their pool-resident ones resolve against. More...
 
class  EBGeometry::Fused::Node< Op, Cs >
 A fused composition: an operation applied to its operands, itself a shape (isShape). More...
 
struct  EBGeometry::Fused::Node< Op, Cs >::Layout
 Everything the node holds: the operation's parameters and its operands (their layouts for pool-resident ones). It holds only offsets into a pool, so it is right in every mirror of the pool. More...
 
struct  EBGeometry::Fused::CombineOp< IsUnion >
 Union or intersection: the minimum or the maximum of the operands' values, in order. More...
 
struct  EBGeometry::Fused::SmoothCombineOp< T, IsUnion >
 Smooth union or intersection: a smooth minimum (maximum) of the two smallest (largest) values. More...
 
struct  EBGeometry::Fused::ComplementOp
 Complement: -v, inside and outside swapped. More...
 
struct  EBGeometry::Fused::AffineOp< T >
 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  EBGeometry::Fused::ElongateOp< T >
 Elongation: the operand's value at p - clamp(p, -h, h). More...
 
struct  EBGeometry::Fused::ShiftOp< T, IsAnnulus >
 Offset (v - r) or annulus (|v| - delta). More...
 
struct  EBGeometry::Fused::RepetitionOp< T >
 Finite repetition: the minimum of the operand's value over all its copies (CSGOps::repetition()). More...
 
struct  EBGeometry::Fused::BlurOp< T >
 Blur: a weighted average of the operand's values at 27 points (CSGOps::blur()). More...
 
struct  EBGeometry::Fused::MollifyOp< T >
 Mollification: the operand convolved with a bump kernel sampled on a grid (CSGOps::mollify()). More...
 
struct  EBGeometry::Fused::OperandList< Cs >
 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...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 
namespace  EBGeometry::Fused
 Fused CSG: the expression builder's operations as types (see EBGeometry_Fused.hpp).
 
namespace  EBGeometry::Fused::Detail
 Implementation details of the fused operations.
 

Typedefs

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

Functions

template<size_t I, class S , class... Rest>
const auto & EBGeometry::Fused::Detail::get (const Pack< S, Rest... > &a_pack) noexcept
 Operand I of a pack.
 
template<size_t I, class S , class... Rest>
auto & EBGeometry::Fused::Detail::get (Pack< S, Rest... > &a_pack) noexcept
 Operand I of a pack, for writing.
 
template<class... Cs>
constexpr DistanceQuality EBGeometry::Fused::Detail::worstAndBound () noexcept
 The worst distance quality among some operand types, and Bound (Exact < Bound < NotADistance).
 
template<class... Cs>
OperandList< Cs... > EBGeometry::Fused::operands (const Cs &... a_operands)
 A list of operands for an n-ary smooth operation.
 
template<class C , class... Cs>
auto EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::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 > EBGeometry::Fused::Complement (const C &a_operand)
 Complement: inside and outside swapped, -v.
 
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)
 Smooth union of two shapes: a smooth minimum of their values.
 
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)
 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 > EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::Translate (const C &a_operand, const Vec3T< ShapePrecision< C > > &a_shift)
 Translate a shape by a shift.
 
template<class C >
auto EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::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 EBGeometry::Fused::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 > EBGeometry::Fused::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 > EBGeometry::Fused::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 > EBGeometry::Fused::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 > 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)
 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 > EBGeometry::Fused::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 > EBGeometry::Fused::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()).
 

Variables

template<class... Cs>
constexpr bool EBGeometry::Fused::Detail::anyPoolHandle = (isPoolHandle<Cs> || ...)
 Whether any of the operand types lives in a pool.
 

Detailed Description

Fused CSG: the operations of the expression builder (EBGeometry_Expr.hpp) as types, which the compiler evaluates fully inlined, on the host and on a device.

Fused::Union(a, b), Fused::Translate(a, shift), ... compose shapes like their namesakes in namespace EBGeometry, but instead of an Expr to be compiled into a Tape they return a Fused::Node: a trivially copyable shape (isShape) whose type spells out the whole composition. Its signedDistance() is the composition's value, computed as a Tape computes it (both take each operation's arithmetic from EBGeometry_CSGOps.hpp), but with no clauses to fetch and dispatch, so it runs as fast as the same solid written out by hand. A fused shape can be used wherever a shape can: queried directly or through GPU::transform(), held in a BVHUnion, or listed as a Tape primitive.

Call the functions qualified (Fused::Union, not Union): the builder's functions of the same names take shapes too, so an unqualified call is ambiguous.

Mesh SDFs, BVH unions and tapes live in a Pool. A fused shape with one of them inside is a pool handle itself (see PoolHandle): it stores its operands' layouts and one location, offers rebasedView(), deepCopy(), layout() and a (Layout, PoolLocation) constructor, and its pool-resident operands must all live in one pool, which must outlive the fused shape and every copy of it.

Author
Robert Marskar