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

A composed object compiled into a pool: a trivially copyable handle that evaluates the object's signed distance (or implicit function value) on the host or on a device. More...

#include <EBGeometry_Tape.hpp>

Inheritance diagram for EBGeometry::Tape< T, UserPrimitives >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::Tape< T, UserPrimitives >:
Collaboration graph
[legend]

Classes

struct  Layout
 The tape's arrays as offsets into its pool, with no location (see PoolHandle). More...
 

Public Types

using Features = TapeDetail::FeaturesOf< UserPrimitives... >
 The features the tape compiles (see TapeFeature): its template arguments derived from TapeFeature::Tag.
 
using BV = BoundingVolumes::AABBT< T >
 Bounding box type.
 
using Primitives = TapeDetail::Primitives< T, UserPrimitives... >
 The primitive types: the built-in ones, then UserPrimitives.
 
using UnionRoot = BVH::PackedBVH< T, uint32_t, BranchingRatio >
 The BVH type over union operands.
 

Public Member Functions

 Tape ()=delete
 No empty tape.
 
 Tape (Pool &a_pool, const Expr< T > &a_expr, const TapeOptions &a_options=TapeOptions())
 Compile an expression into a pool.
 
 Tape (const Layout &a_layout, const PoolLocation &a_location) noexcept
 Rebuild a handle from a stored layout and the location of the pool that holds it.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 The object's value at a point: negative inside, positive outside, zero on the surface.
 
LeafRef< T > closestLeaf (const Vec3T< T > &a_point) const noexcept
 The deciding leaf at a point: the primitive whose surface the value comes from there (see LeafRef), with the point in its own frame.
 
HitT< T > firstHit (const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first crossing of the object's surface along a ray, entering or leaving.
 
HitT< T > firstHit (const Vec3T< T > &a_from, const Vec3T< T > &a_to, T a_tMin=T(0), const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first crossing of the object's surface on the segment from a_from to a_to.
 
SurfaceHitT< T > firstSurface (const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first crossing along a ray, and the surface crossed: the ray counterpart of closestSurface(), as firstHit() is of signedDistance(). The same as the free function firstSurface(). Callable on a device.
 
SurfaceHitT< T > firstSurface (const Vec3T< T > &a_from, const Vec3T< T > &a_to, T a_tMin=T(0), const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first crossing on the segment from a_from to a_to, and the surface crossed (see firstSurface() for a ray). Callable on a device.
 
HitStatus intersects (const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 Whether a ray crosses the object's surface in [a_tMin, a_tMax].
 
HitStatus intersects (const Vec3T< T > &a_from, const Vec3T< T > &a_to, T a_tMin=T(0), const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 Whether the segment from a_from to a_to crosses the object's surface.
 
template<class P >
bool isPrimitive (const LeafRef< T > &a_ref) const noexcept
 Whether a reference's leaf is a primitive of type P.
 
template<class P >
P primitive (const LeafRef< T > &a_ref) const noexcept
 The primitive a reference names, by value: the shape itself, or for a pool-resident type (a mesh SDF, a BVH union, a tape) its handle, rebuilt with the tape's location, so that it resolves against the same pool (or mirror) the tape does.
 
template<class F >
void visitPrimitive (const LeafRef< T > &a_ref, F &&a_f) const noexcept
 Call a function with the primitive a reference names, as primitive.
 
BV computeBoundingVolume () const noexcept
 A box enclosing the object.
 
DistanceQuality getDistanceQuality () const noexcept
 How far signedDistance() can be trusted as a distance.
 
uint32_t getNumPrograms () const noexcept
 Number of sub-programs (1 plus one per Blur, Mollify, FiniteRepetition and BVH union operand).
 
uint32_t getNumClauses () const noexcept
 Number of clauses over all sub-programs (the ray programs' not counted).
 
uint32_t getNumBVHUnions () const noexcept
 Number of unions evaluated with a BVH (those built with Accelerate::BVH).
 
uint32_t getNumPrimitives () const noexcept
 Number of primitives (leaves) in the tape, each occurrence counted.
 
uint32_t getLargestPlainUnion () const noexcept
 The most objects in one union evaluated as written (one not built with Accelerate::BVH), nested sharp unions counted as one: what TapeOptions::m_largeUnionWarning is compared with. An Overlay, which is evaluated as written and takes no BVH, is not counted.
 
SurfaceLabelId getSurfaceLabel (uint32_t a_leaf) const noexcept
 A leaf's label, as SurfaceLabel() resolves it (ExprIndex::getSurfaceLabel()): the nearest label above the leaf, the leaf's own included, but a label above a chain of maps relabels the object below them.
 
SurfaceLabelId getSurfaceLabel (const LeafRef< T > &a_ref) const noexcept
 The label of the leaf a reference names (see getSurfaceLabel(uint32_t)).
 
uint32_t getNumSurfaceLabels () const noexcept
 How many distinct labels the expression has (ExprIndex::getNumSurfaceLabels()).
 
bool leafValue (uint32_t a_leaf, const Vec3T< T > &a_point, T &a_value) const
 A leaf's own value at a point in its frame (as LeafRef::m_localPoint gives one): its shape's signedDistance(), on the host, for diagnostics (ExprIndex::checkLabels()). The tape's pool must be readable on the host.
 
uint32_t getNumRegions () const noexcept
 How many regions the object has: the background (region 0) and one per operand of its Overlays, numbered as ExprIndex numbers them; 2 for an object with no Overlay (the outside and the object).
 
MaterialLabelId getMaterialOf (uint32_t a_region) const noexcept
 A region's material, as ExprIndex numbers the material labels. Callable on a device.
 
uint32_t region (const Vec3T< T > &a_point) const noexcept
 The region a point is in: the last operand of the Overlays whose solid holds it (later operands are on top), or the background (0). Exact in sign: every point is in exactly one region. Callable on a device.
 
T signedDistance (const Vec3T< T > &a_point, uint32_t a_region) const noexcept
 A region's implicit function: negative exactly inside the region, its zero contour the region's surface, interfaces with other regions included. For region k it is max(S_k, -min of the later S_j), S_j being operand j's solid; for the background, minus signedDistance(). A distance bound, exact near a smooth piece of surface of exact operands; what a cut-cell code cuts for one region. Callable on a device.
 
template<class Visit >
void regionDistances (const Vec3T< T > &a_point, Visit &&a_visit) const noexcept
 Every region's function at a point (signedDistance(point, region), the same values), in one pass: calls a_visit(region, value) for each region, from the last one down to the background (0). Each operand's solid is evaluated once, twice when the regions share masks, where asking signedDistance() region by region evaluates the later solids again for each; regions with different masks are asked one by one. Callable on a device.
 
SurfaceRef< T > closestSurface (const Vec3T< T > &a_point, uint32_t a_region) const noexcept
 The surface of a region that decides its function at a point: the region's own boundary, an interface with a later region, or a mask's cut; drilled, with its part and surface label, as closestSurface() reports a surface, and with the regions on its two sides at that point: m_ownerRegion the region asked about (inside), m_neighborRegion the region across. The sides belong to the point, not to the surface: one surface can face different regions in different places. For the background, the whole object's surface. Callable on a device.
 
T signedDistance (const Vec3T< T > &a_point, const Subdomains &a_subdomains, uint32_t a_subdomain) const noexcept
 A subdomain's implicit function: half the difference of the smallest function of a region in the subdomain and the smallest of one not in it (the background included), negative exactly inside the subdomain and zero only on its surface: where one of its regions meets a region not in it, never on the contact between two of its own. A distance bound, exact near a smooth piece of surface; what a cut-cell solver cuts for the subdomain, and the function of a union of materials (a subdomain of their regions). Callable on a device.
 
SurfaceRef< T > closestSurface (const Vec3T< T > &a_point, const Subdomains &a_subdomains, uint32_t a_subdomain) const noexcept
 The surface of a subdomain that decides its function at a point: that of its region whose function is smallest there (see closestSurface(p, region)), with the regions on its two sides; the surface's role for the solver is a_subdomains.role(surface). A contact between two of the subdomain's own regions is not its surface: where that region's nearest surface is one, the nearest region outside the subdomain names the surface instead, seen from the subdomain's side, if it borders the subdomain there. Callable on a device.
 
SurfaceHitT< T > firstRegionChange (const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first point along a ray where the region changes: for a particle crossing layers, from inside any region, the background included. The crossing is the nearer of leaving the current region's solid and entering a later one, each traced exactly where the operands have ray forms (and marched where they do not). m_hit is the crossing, its normal pointing from the region left into the region entered; m_surface the surface crossed (leaf, part, surface label), its m_ownerRegion the region left and m_neighborRegion the region entered. The ray starts counting a hundredth of the march's tolerance at the object's scale past a_tMin (RayOptions::m_tolerance times m_scale, or the box's diagonal), so a ray crossing several layers asks again from the last crossing's t, and layers thinner than that are passed over. Callable on a device.
 
SurfaceHitT< T > firstRegionChange (const Vec3T< T > &a_from, const Vec3T< T > &a_to, T a_tMin=T(0), const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first change of region along a particle's step from one point to another (see firstRegionChange(ray)), t measured from a_from.
 
SurfaceHitT< T > firstSurface (const RayT< T > &a_ray, T a_tMin, T a_tMax, const Subdomains &a_subdomains, uint32_t a_subdomain, const RayOptions< T > &a_options=RayOptions< T >()) const noexcept
 The first point along a ray where it crosses a subdomain's boundary, entering or leaving the subdomain: changes between two of its regions are passed through. For rendering, the subdomain is the set of visible regions: hidden ones are seen through. Reported as firstRegionChange() reports a crossing. Callable on a device.
 
SurfaceRef< T > closestSurface (const Vec3T< T > &a_point) const noexcept
 The surface that decides the value at a point: the deciding leaf (closestLeaf()), drilled into when it is a container (a sphere cloud, a BVH union, a nested tape; see hasSurfaces) down to the member that decides there, at any depth.
 
uint32_t getNumSurfaces () const noexcept
 How many surfaces the tape numbers (see closestSurface()).
 
uint32_t getFirstSurface (uint32_t a_leaf) const noexcept
 A leaf's first surface: the leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)), so per-member data of a container leaf (a sphere's) is an array indexed by SurfaceRef::m_surface minus it.
 
uint32_t getCallDepth () const noexcept
 How deep sub-program calls nest (0 if the tape has no Blur, Mollify, FiniteRepetition or BVH union).
 
const Layout & layout () const noexcept
 The tape's arrays, with no location: what an outer pool-resident object stores.
 
Tape rebasedView (const Pool &a_pool) const noexcept
 A view of this tape resolving against another pool of its mirror chain.
 
Tape deepCopy (Pool &a_dstPool) const
 Copy the tape, and every pool-resident primitive and BVH it holds, into another pool.
 
- Public Member Functions inherited from EBGeometry::PoolHandle
PoolLocation location () const noexcept
 Where this handle's arrays live.
 
bool isAttachedTo (const Pool &a_pool) const noexcept
 Check whether this handle's arrays were reserved from a_pool.
 

Static Public Attributes

template<class F >
static constexpr bool hasFeature = TapeDetail::IndexOf<F, Features>::value < Features::size
 Whether the tape compiles feature F (see TapeFeature).
 
static constexpr size_t BranchingRatio = 4
 Branching factor of the BVHs over union operands.
 
static constexpr unsigned MaxCallDepth = 4
 How deep Blur, Mollify, FiniteRepetition and BVH unions may nest.
 
static constexpr uint32_t ValueStackSize = 16
 Values a sub-program may hold at once.
 
static constexpr uint32_t PointStackSize = 8
 Points a sub-program may hold at once (its input point included).
 
static constexpr uint32_t RayStackSize = 4
 Span lists a ray program may hold at once; a subtree that would need more is marched.
 

Friends

struct RayForm< Tape >
 Tape's ray form follows the ray programs.
 
template<class TapeType >
class RegionView
 A view of the tape's regions traces the whole object through traceProgram(), out of line.
 

Additional Inherited Members

- Protected Member Functions inherited from EBGeometry::PoolHandle
 PoolHandle () noexcept=default
 An unset location; the first reservation attaches it.
 
 PoolHandle (const PoolLocation &a_location) noexcept
 Adopt a location, as a handle rebuilt from a stored layout does.
 
 PoolHandle (const PoolHandle &) noexcept=default
 Copy a handle, as a derived handle's copy does.
 
 PoolHandle (PoolHandle &&) noexcept=default
 Move a handle; the same as a copy.
 
PoolHandle & operator= (const PoolHandle &) noexcept=default
 Copy-assign a handle, as a derived handle's assignment does.
 
PoolHandle & operator= (PoolHandle &&) noexcept=default
 Move-assign a handle; the same as a copy.
 
 ~PoolHandle () noexcept=default
 Destructor; protected, since a PoolHandle exists only as the base of a handle.
 
void * base () noexcept
 The base address this handle's offsets resolve against; see PoolLocation::base().
 
const void * base () const noexcept
 The base address this handle's offsets resolve against, for read-only access.
 
void attach (const Pool &a_pool, const char *a_who, const bool a_deviceWritten=false) noexcept
 Follow a_pool, as the first reservation does; see PoolLocation::attach().
 
PoolLocation rebasedLocation (const Pool &a_pool, uint64_t a_endByte, const char *a_who) const noexcept
 The location of this handle's arrays in another pool of its mirror chain; see PoolLocation::rebasedOnto().
 
void setLocation (const PoolLocation &a_location) noexcept
 Replace the location, for a view or a copy made by a derived handle.
 

Detailed Description

template<class T, class... UserPrimitives>
class EBGeometry::Tape< T, UserPrimitives >

A composed object compiled into a pool: a trivially copyable handle that evaluates the object's signed distance (or implicit function value) on the host or on a device.

Build one from an Expr:

const auto shape = Difference(Union(SphereSDF<T>(c, r), Translate(BoxSDF<T>(lo, hi), shift)), mesh);
const Tape<T> tape(pool, shape);
const T d = tape.signedDistance(p);
Signed distance field for an axis-aligned box (AABB).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:352
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
Signed distance field for a sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:200
A composed object compiled into a pool: a trivially copyable handle that evaluates the object's signe...
Definition EBGeometry_Tape.hpp:758
Expr< ExprPrecision< A > > Union(const A &a_first, const B &a_second)
Union of two objects: the minimum of their values.
Expr< ExprPrecision< A > > Difference(const A &a_first, const B &a_second)
Difference A \ B: max(A, -B), inside A and outside B.
HostMemoryResource & hostMemoryResource() noexcept
Process-wide default host memory resource.
Expr< ExprPrecision< A > > Translate(const A &a_operand, const Vec3T< ExprPrecision< A > > &a_shift)
Translate an object by a shift.

The analytic shapes and the mesh SDFs (FlatMeshSDF, and MeshSDF and TriMeshSDF with the default branching factor and width) are built-in primitive types; any other shape type, such as a BVHUnion, a MeshSDF with another branching factor, another Tape or a type of your own, is listed in UserPrimitives. A pool-resident primitive must live in the tape's pool. The pool must outlive the tape and every copy and view of it (see PoolHandle).

The compiler works out each sub-expression's bounding box and distance quality (see Expr). A union or smooth union is evaluated as written, unless it was built with Accelerate::BVH: then with a BVH over its operands' boxes, pruned as BVHUnion is, unless an operand is not a distance. With exact distances the value is the plain minimum; with operands that are only bounds (DistanceQuality::Bound) pruning can skip an operand whose value is below its box's distance, so the value can be larger than the plain minimum, but it keeps the sign and is still a bound. Blur, Mollify, FiniteRepetition and BVH unions evaluate a sub-program several times; they nest at most MaxCallDepth deep, and a sub-program needs at most ValueStackSize values and PointStackSize points at once; the constructor rejects an expression that needs more.

Optional features (see TapeFeature) are listed among the template arguments, before the user primitive types by convention: Tape<T, TapeFeature::ExactOffsets, MyUnion>. A tape compiles only the features it lists, and without one computes the same object by the general path.

Template Parameters
TFloating-point precision.
UserPrimitivesAdditional primitive types (each a shape of precision T), and features (see TapeFeature).

Constructor & Destructor Documentation

◆ Tape() [1/2]

template<class T , class... UserPrimitives>
EBGeometry::Tape< T, UserPrimitives >::Tape ( Pool &  a_pool,
const Expr< T > &  a_expr,
const TapeOptions &  a_options = TapeOptions() 
)

Compile an expression into a pool.

Parameters
[in,out]a_poolPool to compile into; pool-resident primitives must live in it too. Must outlive this object and every copy of it.
[in]a_exprExpression.
[in]a_optionsCompile settings.

◆ Tape() [2/2]

template<class T , class... UserPrimitives>
EBGeometry::Tape< T, UserPrimitives >::Tape ( const Layout &  a_layout,
const PoolLocation &  a_location 
)
inlinenoexcept

Rebuild a handle from a stored layout and the location of the pool that holds it.

How an outer pool-resident object evaluates a Tape it stores as a layout. a_location must belong to the pool the layout was reserved from, to a mirror of it, or to a pool holding its image (Pool::forImage()); nothing is checked, since a device has no pool to check against.

Parameters
[in]a_layoutThe arrays.
[in]a_locationWhere they live.

Member Function Documentation

◆ closestLeaf()

template<class T , class... UserPrimitives>
LeafRef< T > EBGeometry::Tape< T, UserPrimitives >::closestLeaf ( const Vec3T< T > &  a_point) const
inlinenoexcept

The deciding leaf at a point: the primitive whose surface the value comes from there (see LeafRef), with the point in its own frame.

Evaluates the tape as signedDistance() does, carrying with each value the leaf it comes from. The leaves are numbered in expression order, depth first, each occurrence counted. A primitive that is itself a composition (a fused one, a tape, a BVH union) is one leaf: the tape is the scene, its leaves the parts. closestSurface() goes on into a leaf that is a collection. Callable on a device, like signedDistance().

Parameters
[in]a_pointQuery point.
Returns
The leaf, its type and index in the tape, and the point in its frame.

◆ closestSurface() [1/3]

template<class T , class... UserPrimitives>
SurfaceRef< T > EBGeometry::Tape< T, UserPrimitives >::closestSurface ( const Vec3T< T > &  a_point) const
inlinenoexcept

The surface that decides the value at a point: the deciding leaf (closestLeaf()), drilled into when it is a container (a sphere cloud, a BVH union, a nested tape; see hasSurfaces) down to the member that decides there, at any depth.

The surfaces are numbered across the scene: each leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)), one surface for a leaf that is not a container, and a container's are its own numbers (a cloud's cloud indices, a union's members in the order it was given them) after the leaf's first. A container costs one more query of that leaf (a second search of a cloud, say), paid only here; for a tape without one, the surface is the leaf. For a ray hit, closestSurface(hit.m_point) names the surface crossed. Labels of a nested tape are its own, not reported here. Callable on a device.

Parameters
[in]a_pointQuery point.
Returns
The surface, its leaf and label, and the point in the frame of the deepest shape reached.

◆ closestSurface() [2/3]

template<class T , class... UserPrimitives>
SurfaceRef< T > EBGeometry::Tape< T, UserPrimitives >::closestSurface ( const Vec3T< T > &  a_point,
const Subdomains &  a_subdomains,
uint32_t  a_subdomain 
) const
inlinenoexcept

The surface of a subdomain that decides its function at a point: that of its region whose function is smallest there (see closestSurface(p, region)), with the regions on its two sides; the surface's role for the solver is a_subdomains.role(surface). A contact between two of the subdomain's own regions is not its surface: where that region's nearest surface is one, the nearest region outside the subdomain names the surface instead, seen from the subdomain's side, if it borders the subdomain there. Callable on a device.

Parameters
[in]a_pointPoint, on or near the subdomain's surface.
[in]a_subdomainsThe subdomains.
[in]a_subdomainSubdomain.
Returns
The surface.

◆ closestSurface() [3/3]

template<class T , class... UserPrimitives>
SurfaceRef< T > EBGeometry::Tape< T, UserPrimitives >::closestSurface ( const Vec3T< T > &  a_point,
uint32_t  a_region 
) const
inlinenoexcept

The surface of a region that decides its function at a point: the region's own boundary, an interface with a later region, or a mask's cut; drilled, with its part and surface label, as closestSurface() reports a surface, and with the regions on its two sides at that point: m_ownerRegion the region asked about (inside), m_neighborRegion the region across. The sides belong to the point, not to the surface: one surface can face different regions in different places. For the background, the whole object's surface. Callable on a device.

Parameters
[in]a_pointPoint, on or near the region's surface.
[in]a_regionRegion (below getNumRegions()).
Returns
The surface.

◆ computeBoundingVolume()

template<class T , class... UserPrimitives>
BV EBGeometry::Tape< T, UserPrimitives >::computeBoundingVolume ( ) const
inlinenoexcept

A box enclosing the object.

Returns
The box (unbounded along directions where the object is).

◆ deepCopy()

template<class T , class... UserPrimitives>
Tape EBGeometry::Tape< T, UserPrimitives >::deepCopy ( Pool &  a_dstPool) const
inline

Copy the tape, and every pool-resident primitive and BVH it holds, into another pool.

Parameters
[in,out]a_dstPoolPool to copy into.
Returns
The copy, resolving against a_dstPool.

◆ firstHit() [1/2]

template<class T , class... UserPrimitives>
HitT< T > EBGeometry::Tape< T, UserPrimitives >::firstHit ( const RayT< T > &  a_ray,
T  a_tMin,
T  a_tMax,
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first crossing of the object's surface along a ray, entering or leaving.

The tape is traced along its ray program: exactly through its unions, intersections, complements and affine maps of primitives with ray forms, and marched in the parts that have anything else (see EBGeometry_Ray.hpp). HitT::m_primitive is the leaf crossed (see closestLeaf()). The same as the free function firstHit(). Callable on a device.

Parameters
[in]a_rayThe ray, with a unit direction.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
[in]a_optionsHow to march.
Returns
The crossing, a miss, or an unresolved query.

◆ firstHit() [2/2]

template<class T , class... UserPrimitives>
HitT< T > EBGeometry::Tape< T, UserPrimitives >::firstHit ( const Vec3T< T > &  a_from,
const Vec3T< T > &  a_to,
T  a_tMin = T(0),
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first crossing of the object's surface on the segment from a_from to a_to.

HitT::m_t is the distance from a_from. The same as the free function firstHit(). Callable on a device.

Parameters
[in]a_fromStart of the segment.
[in]a_toEnd of the segment.
[in]a_tMinDistance from a_from where the search starts.
[in]a_optionsHow to march.
Returns
The crossing, a miss, or an unresolved query.

◆ firstRegionChange() [1/2]

template<class T , class... UserPrimitives>
SurfaceHitT< T > EBGeometry::Tape< T, UserPrimitives >::firstRegionChange ( const RayT< T > &  a_ray,
T  a_tMin,
T  a_tMax,
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first point along a ray where the region changes: for a particle crossing layers, from inside any region, the background included. The crossing is the nearer of leaving the current region's solid and entering a later one, each traced exactly where the operands have ray forms (and marched where they do not). m_hit is the crossing, its normal pointing from the region left into the region entered; m_surface the surface crossed (leaf, part, surface label), its m_ownerRegion the region left and m_neighborRegion the region entered. The ray starts counting a hundredth of the march's tolerance at the object's scale past a_tMin (RayOptions::m_tolerance times m_scale, or the box's diagonal), so a ray crossing several layers asks again from the last crossing's t, and layers thinner than that are passed over. Callable on a device.

Parameters
[in]a_rayThe ray, with a unit direction.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
[in]a_optionsHow to march the parts without a ray form.
Returns
The crossing, or a miss.

◆ firstRegionChange() [2/2]

template<class T , class... UserPrimitives>
SurfaceHitT< T > EBGeometry::Tape< T, UserPrimitives >::firstRegionChange ( const Vec3T< T > &  a_from,
const Vec3T< T > &  a_to,
T  a_tMin = T(0),
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first change of region along a particle's step from one point to another (see firstRegionChange(ray)), t measured from a_from.

Parameters
[in]a_fromStart of the step.
[in]a_toEnd of the step.
[in]a_tMinDistance from a_from where the step starts counting.
[in]a_optionsHow to march the parts without a ray form.
Returns
The crossing, or a miss.

◆ firstSurface() [1/3]

template<class T , class... UserPrimitives>
SurfaceHitT< T > EBGeometry::Tape< T, UserPrimitives >::firstSurface ( const RayT< T > &  a_ray,
T  a_tMin,
T  a_tMax,
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first crossing along a ray, and the surface crossed: the ray counterpart of closestSurface(), as firstHit() is of signedDistance(). The same as the free function firstSurface(). Callable on a device.

Parameters
[in]a_rayThe ray, with a unit direction.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
[in]a_optionsHow to march.
Returns
The crossing and its surface, a miss, or an unresolved query.

◆ firstSurface() [2/3]

template<class T , class... UserPrimitives>
SurfaceHitT< T > EBGeometry::Tape< T, UserPrimitives >::firstSurface ( const RayT< T > &  a_ray,
T  a_tMin,
T  a_tMax,
const Subdomains &  a_subdomains,
uint32_t  a_subdomain,
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first point along a ray where it crosses a subdomain's boundary, entering or leaving the subdomain: changes between two of its regions are passed through. For rendering, the subdomain is the set of visible regions: hidden ones are seen through. Reported as firstRegionChange() reports a crossing. Callable on a device.

Parameters
[in]a_rayThe ray, with a unit direction.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
[in]a_subdomainsThe subdomains.
[in]a_subdomainSubdomain.
[in]a_optionsHow to march the parts without a ray form.
Returns
The crossing, or a miss.

◆ firstSurface() [3/3]

template<class T , class... UserPrimitives>
SurfaceHitT< T > EBGeometry::Tape< T, UserPrimitives >::firstSurface ( const Vec3T< T > &  a_from,
const Vec3T< T > &  a_to,
T  a_tMin = T(0),
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

The first crossing on the segment from a_from to a_to, and the surface crossed (see firstSurface() for a ray). Callable on a device.

Parameters
[in]a_fromStart of the segment.
[in]a_toEnd of the segment.
[in]a_tMinDistance from a_from where the search starts.
[in]a_optionsHow to march.
Returns
The crossing and its surface, a miss, or an unresolved query.

◆ getCallDepth()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getCallDepth ( ) const
inlinenoexcept

How deep sub-program calls nest (0 if the tape has no Blur, Mollify, FiniteRepetition or BVH union).

Returns
The depth.

◆ getDistanceQuality()

template<class T , class... UserPrimitives>
DistanceQuality EBGeometry::Tape< T, UserPrimitives >::getDistanceQuality ( ) const
inlinenoexcept

How far signedDistance() can be trusted as a distance.

A runtime value, unlike a shape's static distanceQuality; a Tape used as another object's primitive therefore counts as DistanceQuality::Bound there.

Returns
The quality.

◆ getFirstSurface()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getFirstSurface ( uint32_t  a_leaf) const
inlinenoexcept

A leaf's first surface: the leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)), so per-member data of a container leaf (a sphere's) is an array indexed by SurfaceRef::m_surface minus it.

Parameters
[in]a_leafLeaf number, at most getNumPrimitives() (which gives getNumSurfaces()).
Returns
The surface, or SurfaceRef<T>::None past that.

◆ getLargestPlainUnion()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getLargestPlainUnion ( ) const
inlinenoexcept

The most objects in one union evaluated as written (one not built with Accelerate::BVH), nested sharp unions counted as one: what TapeOptions::m_largeUnionWarning is compared with. An Overlay, which is evaluated as written and takes no BVH, is not counted.

Returns
The count (0 if the tape has no such union).

◆ getMaterialOf()

template<class T , class... UserPrimitives>
MaterialLabelId EBGeometry::Tape< T, UserPrimitives >::getMaterialOf ( uint32_t  a_region) const
inlinenoexcept

A region's material, as ExprIndex numbers the material labels. Callable on a device.

Parameters
[in]a_regionRegion.
Returns
The material, or none.

◆ getNumBVHUnions()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumBVHUnions ( ) const
inlinenoexcept

Number of unions evaluated with a BVH (those built with Accelerate::BVH).

Returns
The count.

◆ getNumClauses()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumClauses ( ) const
inlinenoexcept

Number of clauses over all sub-programs (the ray programs' not counted).

Returns
The count.

◆ getNumPrimitives()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumPrimitives ( ) const
inlinenoexcept

Number of primitives (leaves) in the tape, each occurrence counted.

Returns
The count.

◆ getNumPrograms()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumPrograms ( ) const
inlinenoexcept

Number of sub-programs (1 plus one per Blur, Mollify, FiniteRepetition and BVH union operand).

Returns
The count.

◆ getNumRegions()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumRegions ( ) const
inlinenoexcept

How many regions the object has: the background (region 0) and one per operand of its Overlays, numbered as ExprIndex numbers them; 2 for an object with no Overlay (the outside and the object).

Returns
The count.

◆ getNumSurfaceLabels()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumSurfaceLabels ( ) const
inlinenoexcept

How many distinct labels the expression has (ExprIndex::getNumSurfaceLabels()).

Returns
The count.

◆ getNumSurfaces()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::getNumSurfaces ( ) const
inlinenoexcept

How many surfaces the tape numbers (see closestSurface()).

Returns
The count: the number of leaves when no leaf is a container.

◆ getSurfaceLabel() [1/2]

template<class T , class... UserPrimitives>
SurfaceLabelId EBGeometry::Tape< T, UserPrimitives >::getSurfaceLabel ( const LeafRef< T > &  a_ref) const
inlinenoexcept

The label of the leaf a reference names (see getSurfaceLabel(uint32_t)).

Parameters
[in]a_refReference from closestLeaf().
Returns
The label, or SurfaceLabelId::none().

◆ getSurfaceLabel() [2/2]

template<class T , class... UserPrimitives>
SurfaceLabelId EBGeometry::Tape< T, UserPrimitives >::getSurfaceLabel ( uint32_t  a_leaf) const
inlinenoexcept

A leaf's label, as SurfaceLabel() resolves it (ExprIndex::getSurfaceLabel()): the nearest label above the leaf, the leaf's own included, but a label above a chain of maps relabels the object below them.

Labels are numbered from 0 in the order their names first appear in the expression, depth first, as ExprIndex numbers them, which also holds the names. A device reads the label from the tape's pool, so per-label data (a boundary condition, a restitution coefficient) is an array indexed by it.

Parameters
[in]a_leafLeaf number: LeafRef::m_leaf from closestLeaf(), or HitT::m_primitive of a hit.
Returns
The label, or SurfaceLabelId::none() if the leaf has none (or is not a leaf of the tape).

◆ intersects() [1/2]

template<class T , class... UserPrimitives>
HitStatus EBGeometry::Tape< T, UserPrimitives >::intersects ( const RayT< T > &  a_ray,
T  a_tMin,
T  a_tMax,
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

Whether a ray crosses the object's surface in [a_tMin, a_tMax].

The same as the free function intersects(). Callable on a device.

Parameters
[in]a_rayThe ray, with a unit direction.
[in]a_tMinStart of the interval.
[in]a_tMaxEnd of the interval.
[in]a_optionsHow to march.
Returns
Hit, Miss, or Unresolved.

◆ intersects() [2/2]

template<class T , class... UserPrimitives>
HitStatus EBGeometry::Tape< T, UserPrimitives >::intersects ( const Vec3T< T > &  a_from,
const Vec3T< T > &  a_to,
T  a_tMin = T(0),
const RayOptions< T > &  a_options = RayOptions< T >() 
) const
inlinenoexcept

Whether the segment from a_from to a_to crosses the object's surface.

The same as the free function intersects(). Callable on a device.

Parameters
[in]a_fromStart of the segment.
[in]a_toEnd of the segment.
[in]a_tMinDistance from a_from where the search starts.
[in]a_optionsHow to march.
Returns
Hit, Miss, or Unresolved.

◆ isPrimitive()

template<class T , class... UserPrimitives>
template<class P >
bool EBGeometry::Tape< T, UserPrimitives >::isPrimitive ( const LeafRef< T > &  a_ref) const
inlinenoexcept

Whether a reference's leaf is a primitive of type P.

Template Parameters
PPrimitive type (one of the tape's types).
Parameters
[in]a_refReference from closestLeaf().
Returns
True if it is.

◆ layout()

template<class T , class... UserPrimitives>
const Layout & EBGeometry::Tape< T, UserPrimitives >::layout ( ) const
inlinenoexcept

The tape's arrays, with no location: what an outer pool-resident object stores.

Returns
The layout.

◆ leafValue()

template<class T , class... UserPrimitives>
bool EBGeometry::Tape< T, UserPrimitives >::leafValue ( uint32_t  a_leaf,
const Vec3T< T > &  a_point,
T &  a_value 
) const

A leaf's own value at a point in its frame (as LeafRef::m_localPoint gives one): its shape's signedDistance(), on the host, for diagnostics (ExprIndex::checkLabels()). The tape's pool must be readable on the host.

Parameters
[in]a_leafThe leaf, numbered as ExprIndex numbers them.
[in]a_pointThe point, in the leaf's frame.
[out]a_valueIts value.
Returns
Whether the tape holds the leaf (a leaf inside a collection is not one of the tape's).

◆ primitive()

template<class T , class... UserPrimitives>
template<class P >
P EBGeometry::Tape< T, UserPrimitives >::primitive ( const LeafRef< T > &  a_ref) const
inlinenoexcept

The primitive a reference names, by value: the shape itself, or for a pool-resident type (a mesh SDF, a BVH union, a tape) its handle, rebuilt with the tape's location, so that it resolves against the same pool (or mirror) the tape does.

Template Parameters
PPrimitive type; the leaf must be one (isPrimitive<P>()).
Parameters
[in]a_refReference from closestLeaf().
Returns
The primitive.

◆ rebasedView()

template<class T , class... UserPrimitives>
Tape EBGeometry::Tape< T, UserPrimitives >::rebasedView ( const Pool &  a_pool) const
inlinenoexcept

A view of this tape resolving against another pool of its mirror chain.

The pool must be this tape's own pool or a mirror of it (see PoolLocation::rebasedOnto()). Pool-resident primitives follow the view, since they are stored as layouts.

Parameters
[in]a_poolPool to resolve against.
Returns
The view.

◆ region()

template<class T , class... UserPrimitives>
uint32_t EBGeometry::Tape< T, UserPrimitives >::region ( const Vec3T< T > &  a_point) const
inlinenoexcept

The region a point is in: the last operand of the Overlays whose solid holds it (later operands are on top), or the background (0). Exact in sign: every point is in exactly one region. Callable on a device.

Parameters
[in]a_pointPoint.
Returns
The region.

◆ regionDistances()

template<class T , class... UserPrimitives>
template<class Visit >
void EBGeometry::Tape< T, UserPrimitives >::regionDistances ( const Vec3T< T > &  a_point,
Visit &&  a_visit 
) const
inlinenoexcept

Every region's function at a point (signedDistance(point, region), the same values), in one pass: calls a_visit(region, value) for each region, from the last one down to the background (0). Each operand's solid is evaluated once, twice when the regions share masks, where asking signedDistance() region by region evaluates the later solids again for each; regions with different masks are asked one by one. Callable on a device.

Region k's function is max(S_k, -min of the later solids without the masks the two share). With the same masks on every region (none, usually), every later solid drops all of them, so a running minimum of the unmasked solids, taken from the top down, serves every region: n solids, or 2n with masks, instead of n^2 / 2.

Template Parameters
VisitA callable taking (uint32_t region, T value).
Parameters
[in]a_pointPoint.
[in]a_visitWhat to do with each region's value.

◆ signedDistance() [1/3]

template<class T , class... UserPrimitives>
T EBGeometry::Tape< T, UserPrimitives >::signedDistance ( const Vec3T< T > &  a_point) const
inlinenoexcept

The object's value at a point: negative inside, positive outside, zero on the surface.

The sign is always meaningful. The magnitude is what getDistanceQuality() says: the distance to the surface (Exact), at most that distance (Bound), or nothing (NotADistance). The name is the same for every shape whatever its quality; see isShape. Callable on a device through a view onto a mirrored pool (rebasedView()).

Parameters
[in]a_pointQuery point.
Returns
The value.

◆ signedDistance() [2/3]

template<class T , class... UserPrimitives>
T EBGeometry::Tape< T, UserPrimitives >::signedDistance ( const Vec3T< T > &  a_point,
const Subdomains &  a_subdomains,
uint32_t  a_subdomain 
) const
inlinenoexcept

A subdomain's implicit function: half the difference of the smallest function of a region in the subdomain and the smallest of one not in it (the background included), negative exactly inside the subdomain and zero only on its surface: where one of its regions meets a region not in it, never on the contact between two of its own. A distance bound, exact near a smooth piece of surface; what a cut-cell solver cuts for the subdomain, and the function of a union of materials (a subdomain of their regions). Callable on a device.

Parameters
[in]a_pointPoint.
[in]a_subdomainsThe subdomains (built from this tape's regions).
[in]a_subdomainSubdomain (below a_subdomains.getNumSubdomains()).
Returns
The value.

◆ signedDistance() [3/3]

template<class T , class... UserPrimitives>
T EBGeometry::Tape< T, UserPrimitives >::signedDistance ( const Vec3T< T > &  a_point,
uint32_t  a_region 
) const
inlinenoexcept

A region's implicit function: negative exactly inside the region, its zero contour the region's surface, interfaces with other regions included. For region k it is max(S_k, -min of the later S_j), S_j being operand j's solid; for the background, minus signedDistance(). A distance bound, exact near a smooth piece of surface of exact operands; what a cut-cell code cuts for one region. Callable on a device.

Parameters
[in]a_pointPoint.
[in]a_regionRegion (below getNumRegions()).
Returns
The value.

◆ visitPrimitive()

template<class T , class... UserPrimitives>
template<class F >
void EBGeometry::Tape< T, UserPrimitives >::visitPrimitive ( const LeafRef< T > &  a_ref,
F &&  a_f 
) const
inlinenoexcept

Call a function with the primitive a reference names, as primitive.

() returns it, whatever its type.

Template Parameters
FCallable taking any of the tape's primitive types (a generic lambda in host code). In a CUDA or HIP translation unit, pass a functor whose call operator is EBGEOMETRY_HOST_DEVICE: the device compiler treats a lambda's call operator as a host function here.
Parameters
[in]a_refReference from closestLeaf().
[in]a_fFunction.

Member Data Documentation

◆ hasFeature

template<class T , class... UserPrimitives>
template<class F >
constexpr bool EBGeometry::Tape< T, UserPrimitives >::hasFeature = TapeDetail::IndexOf<F, Features>::value < Features::size
staticconstexpr

Whether the tape compiles feature F (see TapeFeature).

Template Parameters
FFeature.

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