16#ifndef EBGEOMETRY_EXPR_HPP
17#define EBGEOMETRY_EXPR_HPP
79template <
class S,
class T,
class =
void>
90template <
class S,
class T>
94 std::void_t<decltype(std::declval<const S&>().signedDistance(std::declval<const Vec3T<T>&>()))>>
95 : std::is_convertible<decltype(std::declval<const S&>().signedDistance(std::declval<const Vec3T<T>&>())), T>
104template <
class S,
class =
void>
110 static constexpr bool value =
false;
121 std::void_t<typename BoxPrecision<std::decay_t<decltype(std::declval<const S&>().computeBoundingVolume())>>::type>>
163namespace ExprDetail {
202 std::type_index
m_type = std::type_index(
typeid(
void));
302template <
class A,
class =
void>
359 static_assert(std::is_floating_point_v<T>,
"Expr requires a floating-point type T");
378 class = std::enable_if_t<!std::is_same_v<std::decay_t<S>,
Expr> &&
379 !std::is_convertible_v<S, std::shared_ptr<const ExprDetail::Node<T>>>>>
416 const ExprDetail::Node<T>&
423 std::shared_ptr<const ExprDetail::Node<T>> m_node;
445template <class A, class B>
448Union(const A& a_first, const B& a_second);
462Union(const std::vector<A>& a_operands);
474template <class A, class B>
507template <class A, class B>
533template <class A, class B>
564template <class A, class B>
577template <class A, class B>
592template <class A, class B>
610template <class A, class B>
614 const std::vector<B>& a_others,
714Reflect(const A& a_operand, const
size_t a_axis);
788#include "EBGeometry_ExprImplem.hpp"
Declaration of Affine3T, an affine map of 3D space (a 3x3 matrix and a shift).
Declarations of bounding volume types used in bounding volume hierarchies.
How far a function's value can be trusted as a distance: DistanceQuality, and the distanceQualityOf t...
Kind
What an expression node does.
Definition EBGeometry_Expr.hpp:171
@ Affine
Evaluate the child at m_map(p) and multiply by m_valueScale.
@ Repeat
Evaluate the child at p folded into the home tile.
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Growable bump arena for the GPU memory foundation.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
A composed object: an immutable tree of shapes and operations, built on the host and compiled by a Ta...
Definition EBGeometry_Expr.hpp:357
Expr()=delete
No empty expression.
const BV & computeBoundingVolume() const noexcept
A box enclosing the object.
DistanceQuality getDistanceQuality() const noexcept
How far the object's value can be trusted as a distance.
const ExprDetail::Node< T > & node() const noexcept
The root node, for the tape compiler.
Expr(std::shared_ptr< const ExprDetail::Node< T > > a_node) noexcept
Wrap a node; used by the builder functions.
Expr(const S &a_shape)
Wrap a shape.
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:183
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Expr< ExprPrecision< A > > Union(const A &a_first, const B &a_second)
Union of two objects: the minimum of their values.
BlendKind
How a smooth union, intersection or difference blends the two extreme values.
Definition EBGeometry_Expr.hpp:42
@ Polynomial
SmoothMinOp/SmoothMaxOp: quadratic blend over a band of width s; deepens by at most s/4.
@ Exponential
ExpMinOp/ExpMaxOp: log-sum-exp blend with length scale s; deepens by at most s ln 2.
Expr< ExprPrecision< A > > Reflect(const A &a_operand, const size_t a_axis)
Reflect an object in a coordinate plane through the origin.
Expr< ExprPrecision< A > > Difference(const A &a_first, const B &a_second)
Difference A \ B: max(A, -B), inside A and outside B.
Expr< ExprPrecision< A > > SmoothDifference(const A &a_first, const B &a_second, const ExprPrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
Smooth difference A \ B: the smooth intersection of A and the complement of B.
Expr< ExprPrecision< A > > SmoothUnion(const A &a_first, const B &a_second, const ExprPrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
Smooth union of two objects: a smooth minimum of their values.
constexpr bool isShape
Whether S is a shape: a trivially copyable type with a const signedDistance(const Vec3T<T>&) returnin...
Definition EBGeometry_Expr.hpp:151
Expr< ExprPrecision< A > > toExpr(const A &a_operand)
Convert a shape or an Expr to an Expr.
Expr< ExprPrecision< A > > Intersection(const A &a_first, const B &a_second)
Intersection of two objects: the maximum of their values.
typename ExprDetail::ShapeInfo< S >::precision ShapePrecision
The precision of a shape type: T for a shape whose box type is AABBT<T>.
Definition EBGeometry_Expr.hpp:158
Expr< ExprPrecision< A > > Blur(const A &a_operand, const ExprPrecision< A > a_blur, const ExprPrecision< A > a_alpha=ExprPrecision< A >(0.5))
Blur an object: a weighted average of its values at the 27 points p + d (i, j, k),...
Expr< ExprPrecision< A > > Translate(const A &a_operand, const Vec3T< ExprPrecision< A > > &a_shift)
Translate an object by a shift.
Expr< ExprPrecision< A > > Complement(const A &a_operand)
Complement: inside and outside swapped, -v.
Expr< ExprPrecision< A > > Elongate(const A &a_operand, const Vec3T< ExprPrecision< A > > &a_elongation)
Elongate an object: stretch it by inserting a box of half-lengths h at the origin.
Expr< ExprPrecision< A > > SmoothIntersection(const A &a_first, const B &a_second, const ExprPrecision< A > a_smooth, const BlendKind a_blend=BlendKind::Polynomial)
Smooth intersection of two objects: a smooth maximum of their values.
Expr< ExprPrecision< A > > Scale(const A &a_operand, const ExprPrecision< A > a_factor)
Scale an object uniformly about the origin.
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
@ Exact
The value's magnitude is the Euclidean distance to the surface.
Expr< ExprPrecision< A > > Mollify(const A &a_operand, const ExprPrecision< A > a_dist, const size_t a_samples)
Mollify an object: convolve it with a smooth, non-negative bump kernel sampled on an n x n x n grid s...
Expr< ExprPrecision< A > > Annular(const A &a_operand, const ExprPrecision< A > a_delta)
A shell around an object's surface, |v| - delta.
Expr< ExprPrecision< A > > Offset(const A &a_operand, const ExprPrecision< A > a_offset)
Offset an object's surface outward by a distance, v - r.
Expr< ExprPrecision< A > > FiniteRepetition(const A &a_operand, const Vec3T< ExprPrecision< A > > &a_period, const Vec3T< ExprPrecision< A > > &a_repeatLo, const Vec3T< ExprPrecision< A > > &a_repeatHi)
Finite repetition: copies of an object on a grid of tiles, a_repeatLo tiles below and a_repeatHi tile...
Expr< ExprPrecision< A > > Rotate(const A &a_operand, const ExprPrecision< A > a_degrees, const size_t a_axis)
Rotate an object about a coordinate axis through the origin.
typename ExprDetail::ExprLike< A >::type ExprPrecision
The precision of an expression-like type: T for Expr<T> or for a shape of precision T....
Definition EBGeometry_Expr.hpp:343
An affine map of 3D space, x -> A x + b, with A stored by rows.
Definition EBGeometry_Affine.hpp:37
static Affine3T identity() noexcept
The identity map.
T type
The precision.
Definition EBGeometry_Expr.hpp:70
The precision of a bounding box type: T for AABBT<T>, nothing otherwise.
Definition EBGeometry_Expr.hpp:56
T type
The precision.
Definition EBGeometry_Expr.hpp:318
ShapePrecision< S > type
The precision.
Definition EBGeometry_Expr.hpp:332
Whether A is a shape or an Expr, and its precision: the primary template is neither.
Definition EBGeometry_Expr.hpp:304
Whether S has a const signedDistance(const Vec3T<T>&) returning something convertible to T.
Definition EBGeometry_Expr.hpp:81
A shape held by an expression, with its type erased.
Definition EBGeometry_Expr.hpp:193
std::shared_ptr< const void > m_object
Copy of the shape.
Definition EBGeometry_Expr.hpp:197
bool(* m_isAttachedTo)(const void *, const Pool &)
For a pool-resident shape: whether it lives in a given pool. Null otherwise.
Definition EBGeometry_Expr.hpp:207
std::type_index m_type
The shape's type.
Definition EBGeometry_Expr.hpp:202
An expression node.
Definition EBGeometry_Expr.hpp:218
BoundingVolumes::AABBT< T > m_boundingVolume
A box enclosing the node's object.
Definition EBGeometry_Expr.hpp:289
Affine3T< T > m_map
Point map applied before the child is evaluated (Affine).
Definition EBGeometry_Expr.hpp:238
Vec3T< T > m_vec1
Tiles in the decreasing direction of each axis, rounded to whole numbers (Repeat).
Definition EBGeometry_Expr.hpp:258
DistanceQuality m_quality
How far the node's value can be trusted as a distance.
Definition EBGeometry_Expr.hpp:294
BlendKind m_blend
Blend kind (smooth operations).
Definition EBGeometry_Expr.hpp:284
T m_scalar0
Offset distance (Offset), shell half-thickness (Annular), blur distance (Blur), mollification distanc...
Definition EBGeometry_Expr.hpp:269
Affine3T< T > m_inverse
Inverse of m_map, which maps the child's box to the node's (Affine).
Definition EBGeometry_Expr.hpp:243
Vec3T< T > m_vec0
Elongation half-lengths (Elongate) or tile period (Repeat).
Definition EBGeometry_Expr.hpp:253
std::vector< Expr< T > > m_children
Children (none for a primitive, one for a map or value operation, any number for a union or intersect...
Definition EBGeometry_Expr.hpp:228
T m_scalar1
Blend weight alpha (Blur).
Definition EBGeometry_Expr.hpp:274
Leaf m_leaf
The shape, for a primitive.
Definition EBGeometry_Expr.hpp:233
uint32_t m_count
Samples per axis (Mollify).
Definition EBGeometry_Expr.hpp:279
Vec3T< T > m_vec2
Tiles in the increasing direction of each axis, rounded to whole numbers (Repeat).
Definition EBGeometry_Expr.hpp:263
Kind m_kind
What the node does.
Definition EBGeometry_Expr.hpp:222
T m_valueScale
Value multiplier applied after the child is evaluated (Affine): |s| for a scaling by s.
Definition EBGeometry_Expr.hpp:248
typename BoxPrecision< std::decay_t< decltype(std::declval< const S & >().computeBoundingVolume())> >::type precision
The shape's precision, read from its bounding box type.
Definition EBGeometry_Expr.hpp:127
Shape detection: a type with computeBoundingVolume() returning AABBT<T>.
Definition EBGeometry_Expr.hpp:106
static constexpr bool value
Whether S is a shape.
Definition EBGeometry_Expr.hpp:110