EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_Tape.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
24#ifndef EBGEOMETRY_TAPE_HPP
25#define EBGEOMETRY_TAPE_HPP
26
27// Std includes
28#include <cstddef>
29#include <cstdint>
30#include <tuple>
31#include <type_traits>
32#include <vector>
33
34// Our includes
40#include "EBGeometry_Expr.hpp"
41#include "EBGeometry_GPU.hpp"
47#include "EBGeometry_Pool.hpp"
48#include "EBGeometry_Ray.hpp"
51#include "EBGeometry_Vec.hpp"
52
53namespace EBGeometry {
54
55template <class TapeType>
56class RegionView;
57
81
110namespace TapeFeature {
111
115struct Tag
116{
117};
118
126{
127};
128
129} // namespace TapeFeature
130
131namespace TapeDetail {
132
139enum class Op : uint8_t
140{
141 Primitive,
142 PushAffine,
144 PopPoint,
145 Negate,
146 Abs,
149 Min,
150 Max,
151 PairInit,
152 PairInsert,
153 PairBlend,
155 Blur,
156 Mollify,
157 Repeat,
159 UnionBVH,
162};
163
171enum class RayOp : uint8_t
172{
173 Leaf,
176 Marched,
184 Union,
186 Complement,
187 PushAffine,
188 PopAffine,
189 UnionBVH
191};
192
199{
203 RayOp m_op = RayOp::Leaf;
204
208 uint8_t m_flags = 0;
209
213 uint16_t m_type = 0;
214
218 uint32_t m_a = 0;
219
223 uint32_t m_b = 0;
224
228 uint32_t m_c = 0;
229};
230
231static_assert(sizeof(RayClause) == 16, "TapeDetail::RayClause must be 16 bytes");
232
237struct Clause
238{
242 Op m_op = Op::Primitive;
243
247 uint8_t m_flags = 0;
248
252 uint16_t m_type = 0;
253
257 uint32_t m_a = 0;
258
262 uint32_t m_b = 0;
263
267 uint32_t m_c = 0;
268};
269
270static_assert(sizeof(Clause) == 16, "TapeDetail::Clause must be 16 bytes");
271
278[[nodiscard]] EBGEOMETRY_HOST_DEVICE
279inline Clause
280stored(const RayClause& a_clause) noexcept
281{
282 Clause c;
283
284 c.m_op = static_cast<Op>(a_clause.m_op);
285 c.m_flags = a_clause.m_flags;
286 c.m_type = a_clause.m_type;
287 c.m_a = a_clause.m_a;
288 c.m_b = a_clause.m_b;
289 c.m_c = a_clause.m_c;
290
291 return c;
292}
293
300[[nodiscard]] EBGEOMETRY_HOST_DEVICE
301inline RayClause
302rayClause(const Clause& a_clause) noexcept
303{
304 RayClause c;
305
306 c.m_op = static_cast<RayOp>(a_clause.m_op);
307 c.m_flags = a_clause.m_flags;
308 c.m_type = a_clause.m_type;
309 c.m_a = a_clause.m_a;
310 c.m_b = a_clause.m_b;
311 c.m_c = a_clause.m_c;
312
313 return c;
314}
315
321{
325 uint32_t m_begin = 0;
326
330 uint32_t m_end = 0;
331};
332
339inline constexpr uint32_t LeafProgram = uint32_t(1) << 31;
340
348template <class T, size_t K>
361
367template <class... Ps>
369{
373 static constexpr size_t size = sizeof...(Ps);
374};
375
382template <size_t I, class List>
383struct TypeAt;
384
391template <class T, class List>
393
400template <class T, class... Ps>
401struct AnyContainer<T, TypeList<Ps...>> : std::bool_constant<(hasSurfaces<Ps, T> || ...)>
402{
403};
404
412template <class T, class List>
413struct AnyDrill;
414
421template <class T, class... Ps>
422struct AnyDrill<T, TypeList<Ps...>> : std::bool_constant<((hasSurfaces<Ps, T> || hasParts<Ps, T>) || ...)>
423{
424};
425
432template <size_t I, class... Ps>
433struct TypeAt<I, TypeList<Ps...>>
434{
438 using type = std::tuple_element_t<I, std::tuple<Ps...>>;
439};
440
447template <class P, class List>
448struct IndexOf;
449
455template <class P>
456struct IndexOf<P, TypeList<>>
457{
461 static constexpr size_t value = 0;
462};
463
471template <class P, class Q, class... Rest>
472struct IndexOf<P, TypeList<Q, Rest...>>
473{
477 static constexpr size_t value = std::is_same_v<P, Q> ? 0 : 1 + IndexOf<P, TypeList<Rest...>>::value;
478};
479
485template <class... Lists>
486struct Concat
487{
492};
493
500template <class... Ps, class... Rest>
501struct Concat<TypeList<Ps...>, Rest...>
502{
506 using type = typename Concat<TypeList<Ps...>, typename Concat<Rest...>::type>::type;
507};
508
515template <class... Ps, class... Qs>
516struct Concat<TypeList<Ps...>, TypeList<Qs...>>
517{
521 using type = TypeList<Ps..., Qs...>;
522};
523
529template <class A>
530inline constexpr bool IsFeature = std::is_base_of_v<TapeFeature::Tag, A>;
531
537template <class... Args>
539
545template <class... Args>
547
553template <class... Ps>
555{
556};
557
564template <class P, class... Ps>
577
583template <class List>
584struct StoreOf;
585
591template <class... Ps>
592struct StoreOf<TypeList<Ps...>>
593{
597 using type = PrimitiveStore<Ps...>;
598};
599
609template <size_t I, class P, class... Ps>
610[[nodiscard]] EBGEOMETRY_HOST_DEVICE
611inline const auto&
612storeAt(const PrimitiveStore<P, Ps...>& a_store) noexcept
613{
614 if constexpr (I == 0) {
615 return a_store.m_head;
616 }
617 else {
618 return storeAt<I - 1>(a_store.m_tail);
619 }
620}
621
631template <size_t I, class P, class... Ps>
632[[nodiscard]] EBGEOMETRY_HOST_DEVICE
633inline auto&
635{
636 if constexpr (I == 0) {
637 return a_store.m_head;
638 }
639 else {
640 return storeAt<I - 1>(a_store.m_tail);
641 }
642}
643
655template <class T, class... UserPrimitives>
659 BoxSDF<T>,
671 TriMeshSDF<T, BVH::DefaultBranchingRatio<T>(), TriangleSoA::DefaultWidth<T>()>>,
672 UserTypesOf<UserPrimitives...>,
681 WedgeSDF<T>>>::type;
682
689template <class T, class List>
691
698template <class T, class... Ps>
699struct UserTypes<T, TypeList<Ps...>>
700{
704 static constexpr bool shapes = (isShape<Ps> && ...);
705
709 static constexpr bool precision = (std::is_same_v<ShapePrecision<Ps>, T> && ...);
710};
711
719template <class T, size_t K, class List>
720struct Staging;
721
722} // namespace TapeDetail
723
756template <class T, class... UserPrimitives>
757class Tape : public PoolHandle
758{
759public:
760 static_assert(std::is_floating_point_v<T>, "Tape requires a floating-point type T");
761 static_assert(TapeDetail::UserTypes<T, TapeDetail::UserTypesOf<UserPrimitives...>>::shapes,
762 "Tape: every user primitive type must be a shape (see isShape)");
763 static_assert(TapeDetail::UserTypes<T, TapeDetail::UserTypesOf<UserPrimitives...>>::precision,
764 "Tape: every user primitive type must have the tape's precision");
765
769 using Features = TapeDetail::FeaturesOf<UserPrimitives...>;
770
775 template <class F>
776 static constexpr bool hasFeature = TapeDetail::IndexOf<F, Features>::value < Features::size;
777
782
786 static constexpr size_t BranchingRatio = 4;
787
791 static constexpr unsigned MaxCallDepth = 4;
792
796 static constexpr uint32_t ValueStackSize = 16;
797
801 static constexpr uint32_t PointStackSize = 8;
802
806 static constexpr uint32_t RayStackSize = 4;
807
811 using Primitives = TapeDetail::Primitives<T, UserPrimitives...>;
812
817
920
924 Tape() = delete;
925
934 Tape(Pool& a_pool, const Expr<T>& a_expr, const TapeOptions& a_options = TapeOptions());
935
945 Tape(const Layout& a_layout, const PoolLocation& a_location) noexcept : PoolHandle(a_location), m_layout(a_layout)
946 {}
947
957 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
958 inline T
959 signedDistance(const Vec3T<T>& a_point) const noexcept;
960
971 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
972 inline LeafRef<T>
973 closestLeaf(const Vec3T<T>& a_point) const noexcept;
974
987 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
988 inline HitT<T>
989 firstHit(const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
990
1001 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1002 inline HitT<T>
1003 firstHit(const Vec3T<T>& a_from,
1004 const Vec3T<T>& a_to,
1005 T a_tMin = T(0),
1006 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1007
1017 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1018 inline SurfaceHitT<T>
1019 firstSurface(const RayT<T>& a_ray,
1020 T a_tMin,
1021 T a_tMax,
1022 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1023
1033 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1034 inline SurfaceHitT<T>
1035 firstSurface(const Vec3T<T>& a_from,
1036 const Vec3T<T>& a_to,
1037 T a_tMin = T(0),
1038 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1039
1049 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1050 inline HitStatus
1051 intersects(const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1052
1062 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1063 inline HitStatus
1064 intersects(const Vec3T<T>& a_from,
1065 const Vec3T<T>& a_to,
1066 T a_tMin = T(0),
1067 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1068
1075 template <class P>
1076 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1077 inline bool
1078 isPrimitive(const LeafRef<T>& a_ref) const noexcept;
1079
1088 template <class P>
1089 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1090 inline P
1091 primitive(const LeafRef<T>& a_ref) const noexcept;
1092
1102 template <class F>
1104 inline void
1105 visitPrimitive(const LeafRef<T>& a_ref, F&& a_f) const noexcept;
1106
1111 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1112 inline BV
1113 computeBoundingVolume() const noexcept;
1114
1121 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1122 inline DistanceQuality
1123 getDistanceQuality() const noexcept;
1124
1129 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1130 inline uint32_t
1131 getNumPrograms() const noexcept;
1132
1137 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1138 inline uint32_t
1139 getNumClauses() const noexcept;
1140
1145 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1146 inline uint32_t
1147 getNumBVHUnions() const noexcept;
1148
1153 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1154 inline uint32_t
1155 getNumPrimitives() const noexcept;
1156
1163 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1164 inline uint32_t
1165 getLargestPlainUnion() const noexcept;
1166
1176 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1177 inline SurfaceLabelId
1178 getSurfaceLabel(uint32_t a_leaf) const noexcept;
1179
1185 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1186 inline SurfaceLabelId
1187 getSurfaceLabel(const LeafRef<T>& a_ref) const noexcept;
1188
1193 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1194 inline uint32_t
1195 getNumSurfaceLabels() const noexcept;
1196
1206 [[nodiscard]] EBGEOMETRY_HOST
1207 bool
1208 leafValue(uint32_t a_leaf, const Vec3T<T>& a_point, T& a_value) const;
1209
1215 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1216 inline uint32_t
1217 getNumRegions() const noexcept;
1218
1224 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1225 inline MaterialLabelId
1226 getMaterialOf(uint32_t a_region) const noexcept;
1227
1235 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1237 inline uint32_t
1238 region(const Vec3T<T>& a_point) const noexcept;
1239
1250 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1252 inline T
1253 signedDistance(const Vec3T<T>& a_point, uint32_t a_region) const noexcept;
1254
1267 template <class Visit>
1269 inline void
1270 regionDistances(const Vec3T<T>& a_point, Visit&& a_visit) const noexcept;
1271
1283 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1285 inline SurfaceRef<T>
1286 closestSurface(const Vec3T<T>& a_point, uint32_t a_region) const noexcept;
1287
1299 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1301 inline T
1302 signedDistance(const Vec3T<T>& a_point, const Subdomains& a_subdomains, uint32_t a_subdomain) const noexcept;
1303
1315 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1317 inline SurfaceRef<T>
1318 closestSurface(const Vec3T<T>& a_point, const Subdomains& a_subdomains, uint32_t a_subdomain) const noexcept;
1319
1335 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1337 inline SurfaceHitT<T>
1338 firstRegionChange(const RayT<T>& a_ray,
1339 T a_tMin,
1340 T a_tMax,
1341 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1342
1352 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1353 inline SurfaceHitT<T>
1354 firstRegionChange(const Vec3T<T>& a_from,
1355 const Vec3T<T>& a_to,
1356 T a_tMin = T(0),
1357 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1358
1372 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1374 inline SurfaceHitT<T>
1375 firstSurface(const RayT<T>& a_ray,
1376 T a_tMin,
1377 T a_tMax,
1378 const Subdomains& a_subdomains,
1379 uint32_t a_subdomain,
1380 const RayOptions<T>& a_options = RayOptions<T>()) const noexcept;
1381
1395 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1396 inline SurfaceRef<T>
1397 closestSurface(const Vec3T<T>& a_point) const noexcept;
1398
1403 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1404 inline uint32_t
1405 getNumSurfaces() const noexcept;
1406
1413 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1414 inline uint32_t
1415 getFirstSurface(uint32_t a_leaf) const noexcept;
1416
1421 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1422 inline uint32_t
1423 getCallDepth() const noexcept;
1424
1429 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1430 inline const Layout&
1431 layout() const noexcept;
1432
1440 [[nodiscard]] EBGEOMETRY_HOST
1441 inline Tape
1442 rebasedView(const Pool& a_pool) const noexcept;
1443
1449 [[nodiscard]] EBGEOMETRY_HOST
1450 inline Tape
1451 deepCopy(Pool& a_dstPool) const;
1452
1453private:
1457 friend struct RayForm<Tape>;
1458
1462 template <class TapeType>
1463 friend class RegionView;
1464
1468 static constexpr uint32_t MarchedLeaf = UINT32_MAX;
1469
1473 static constexpr uint32_t LevelLeaf = UINT32_MAX - 1;
1474
1478 Layout m_layout;
1479
1484 template <unsigned D>
1485 struct Subtree
1486 {
1490 const Tape* m_tape;
1491
1495 uint32_t m_program;
1496
1500 BV m_box;
1501
1505 DistanceQuality m_quality;
1506
1510 const void* m_base;
1511
1515 PoolLocation m_location;
1516
1522 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1523 inline T
1524 signedDistance(const Vec3T<T>& a_point) const noexcept
1525 {
1526 return m_tape->template evaluate<D>(m_program, a_point, m_base, m_location);
1527 }
1528
1533 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1534 inline BV
1535 computeBoundingVolume() const noexcept
1536 {
1537 return m_box;
1538 }
1539
1544 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1545 inline DistanceQuality
1546 getDistanceQuality() const noexcept
1547 {
1548 return m_quality;
1549 }
1550 };
1551
1560 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1561 inline HitT<T>
1562 traceRay(const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) const noexcept;
1563
1574 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1576 inline HitT<T>
1577 traceProgram(
1578 uint32_t a_program, const RayT<T>& a_ray, T a_tMin, T a_tMax, const RayOptions<T>& a_options) const noexcept;
1579
1594 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1596 inline HitT<T>
1597 tracePart(uint32_t a_program,
1598 const RayT<T>& a_ray,
1599 T a_tMin,
1600 T a_tMax,
1601 const RayOptions<T>& a_options,
1602 uint32_t& a_part) const noexcept;
1603
1621 template <bool Whole, bool Part = false>
1622 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1623 inline HitT<T>
1624 traceBody(uint32_t a_program,
1625 const RayT<T>& a_ray,
1626 T a_tMin,
1627 T a_tMax,
1628 const RayOptions<T>& a_options,
1629 uint32_t* a_part = nullptr) const noexcept;
1630
1641 inline void
1642 raySpans(const RayT<T>& a_ray,
1643 T a_tMin,
1644 T a_tMax,
1645 const RayOptions<T>& a_options,
1646 bool a_firstOnly,
1647 RaySpansT<T>& a_spans) const noexcept;
1648
1662 template <unsigned D>
1665 inline void
1666 rayEvaluate(uint32_t a_program,
1667 const RayT<T>& a_ray,
1668 T a_t0,
1669 T a_t1,
1670 const RayOptions<T>& a_options,
1671 bool a_all,
1672 const void* a_base,
1673 const PoolLocation& a_location,
1674 RaySpansT<T>& a_spans) const noexcept;
1675
1697 template <unsigned D, bool Level = false, bool Part = false>
1698 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1700 inline HitT<T>
1701 rayLeafHit(uint32_t a_program,
1702 const RayT<T>& a_ray,
1703 T a_t,
1704 uint32_t a_clause,
1705 const RayOptions<T>& a_options,
1706 const void* a_base,
1707 const PoolLocation& a_location) const noexcept;
1708
1721 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1723 inline HitT<T>
1724 primitiveLeafHit(const TapeDetail::RayClause& a_clause,
1725 const RayT<T>& a_ray,
1726 T a_t,
1727 const RayOptions<T>& a_options,
1728 const void* a_base,
1729 const PoolLocation& a_location) const noexcept;
1730
1743 template <size_t I>
1744 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1745 inline HitT<T>
1746 dispatchLeafHit(const TapeDetail::RayClause& a_clause,
1747 const RayT<T>& a_ray,
1748 T a_t,
1749 const RayOptions<T>& a_options,
1750 const void* a_base,
1751 const PoolLocation& a_location) const noexcept;
1752
1768 template <unsigned D>
1771 inline void
1772 rayMarchedWithin(const TapeDetail::RayClause& a_clause,
1773 const RayT<T>& a_ray,
1774 const RayOptions<T>& a_options,
1775 bool a_firstOnly,
1776 const RaySpansT<T>& a_within,
1777 const void* a_base,
1778 const PoolLocation& a_location,
1779 RaySpansT<T>& a_spans) const noexcept;
1780
1795 inline void
1796 rayLeaf(const TapeDetail::RayClause& a_clause,
1797 const RayT<T>& a_ray,
1798 T a_t0,
1799 T a_t1,
1800 const RayOptions<T>& a_options,
1801 bool a_firstOnly,
1802 const void* a_base,
1803 const PoolLocation& a_location,
1804 RaySpansT<T>& a_spans) const noexcept;
1805
1823 void
1824 rayLevelLeaf(const TapeDetail::RayClause& a_clause,
1825 const RayT<T>& a_ray,
1826 T a_t0,
1827 T a_t1,
1828 const RayOptions<T>& a_options,
1829 bool a_firstOnly,
1830 const void* a_base,
1831 const PoolLocation& a_location,
1832 RaySpansT<T>& a_spans) const noexcept;
1833
1850 void
1851 rayLevelWithin(const TapeDetail::RayClause& a_clause,
1852 const RayT<T>& a_ray,
1853 const RayOptions<T>& a_options,
1854 bool a_firstOnly,
1855 const RaySpansT<T>& a_within,
1856 const void* a_base,
1857 const PoolLocation& a_location,
1858 RaySpansT<T>& a_spans) const noexcept;
1859
1872 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1875 HitT<T>
1876 levelClauseHit(const TapeDetail::RayClause& a_clause,
1877 const RayT<T>& a_ray,
1878 T a_t,
1879 const RayOptions<T>& a_options,
1880 const void* a_base,
1881 const PoolLocation& a_location) const noexcept;
1882
1896 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1899 HitT<T>
1900 resolveLevelHit(uint32_t a_clause,
1901 const RayT<T>& a_ray,
1902 T a_t,
1903 const RayOptions<T>& a_options,
1904 const void* a_base,
1905 const PoolLocation& a_location) const noexcept;
1906
1918 template <size_t I, bool MeshOnly, class Visit>
1920 inline void
1921 visitLevelPrimitive(const TapeDetail::RayClause& a_clause,
1922 const void* a_base,
1923 const PoolLocation& a_location,
1924 const Visit& a_visit) const noexcept;
1925
1939 template <size_t I>
1941 inline void
1942 dispatchRayLeaf(const TapeDetail::RayClause& a_clause,
1943 const RayT<T>& a_ray,
1944 T a_t0,
1945 T a_t1,
1946 const RayOptions<T>& a_options,
1947 bool a_firstOnly,
1948 const void* a_base,
1949 const PoolLocation& a_location,
1950 RaySpansT<T>& a_spans) const noexcept;
1951
1966 template <unsigned D>
1968 inline void
1969 rayUnion(const TapeDetail::RayClause& a_clause,
1970 const RayT<T>& a_ray,
1971 T a_t0,
1972 T a_t1,
1973 const RayOptions<T>& a_options,
1974 bool a_all,
1975 const void* a_base,
1976 const PoolLocation& a_location,
1977 RaySpansT<T>& a_spans) const noexcept;
1978
2002 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2003 inline T
2004 wholeValue(const Vec3T<T>& a_point) const noexcept;
2005
2011 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2012 inline uint32_t
2013 numRegionOperands() const noexcept;
2014
2020 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2021 inline LeafRef<T>
2022 leafOf(const CSGOps::Tagged<T>& a_value) const noexcept;
2023
2035 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2037 inline LeafRef<T>
2038 tracedLeaf(const uint32_t a_program, const uint32_t a_leaf, const Vec3T<T>& a_point) const noexcept;
2039
2047 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2049 inline SurfaceRef<T>
2050 surfaceOf(const LeafRef<T>& a_ref, uint32_t a_part = SurfaceRef<T>::None) const noexcept;
2051
2059 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2061 inline CSGOps::Tagged<T>
2062 regionSolidTagged(uint32_t a_region, uint32_t a_level, const Vec3T<T>& a_point) const noexcept;
2063
2072 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2074 inline T
2075 regionSolid(uint32_t a_region, uint32_t a_level, const Vec3T<T>& a_point) const noexcept;
2076
2084 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2085 inline uint32_t
2086 sharedMasks(uint32_t a_first, uint32_t a_second) const noexcept;
2087
2088 template <unsigned D, class V = T>
2089 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2091 inline V
2092 evaluate(const uint32_t a_program,
2093 const Vec3T<T>& a_point,
2094 const void* a_base,
2095 const PoolLocation& a_location) const noexcept;
2096
2134 template <unsigned D, class V = T>
2135 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2136 inline V
2137 evaluateBody(const uint32_t a_program,
2138 const Vec3T<T>& a_point,
2139 const void* a_base,
2140 const PoolLocation& a_location) const noexcept;
2141
2150 template <size_t I, class F>
2152 inline void
2153 dispatchVisit(const LeafRef<T>& a_ref, F&& a_f) const noexcept;
2154
2167 template <size_t I, bool Handles>
2168 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2169 inline T
2170 dispatchPrimitive(const uint32_t a_type,
2171 const uint32_t a_index,
2172 const Vec3T<T>& a_point,
2173 const void* a_base,
2174 const PoolLocation& a_location) const noexcept;
2175
2181 static constexpr size_t DispatchSplit = 6;
2182
2192 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2194 T
2195 dispatchRest(const uint32_t a_type,
2196 const uint32_t a_index,
2197 const Vec3T<T>& a_point,
2198 const void* a_base,
2199 const PoolLocation& a_location) const noexcept;
2200
2210 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2211 inline T
2212 evaluatePrimitive(const uint32_t a_type,
2213 const uint32_t a_index,
2214 const Vec3T<T>& a_point,
2215 const void* a_base,
2216 const PoolLocation& a_location) const noexcept;
2217
2230 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2232 inline T
2233 evaluateHandle(const uint32_t a_type,
2234 const uint32_t a_index,
2235 const Vec3T<T>& a_point,
2236 const void* a_base,
2237 const PoolLocation& a_location) const noexcept;
2238
2250 template <unsigned D, class V = T>
2251 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2253 inline V
2254 evaluateBlur(const TapeDetail::Clause& a_clause,
2255 const Vec3T<T>& a_point,
2256 const T* a_params,
2257 const void* a_base,
2258 const PoolLocation& a_location) const noexcept;
2259
2273 template <unsigned D, class V = T>
2274 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2275 inline V
2276 evaluateRepeat(const TapeDetail::Clause& a_clause,
2277 const Vec3T<T>& a_point,
2278 const T* a_params,
2279 const void* a_base,
2280 const PoolLocation& a_location) const noexcept;
2281
2294 template <class V>
2295 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2297 inline V
2298 evaluateLeaf(uint32_t a_program,
2299 const Vec3T<T>& a_point,
2300 const void* a_base,
2301 const PoolLocation& a_location) const noexcept;
2302
2314 template <unsigned D, class V = T>
2315 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2316 inline V
2317 evaluateUnion(const TapeDetail::Clause& a_clause,
2318 const Vec3T<T>& a_point,
2319 const T* a_params,
2320 const void* a_base,
2321 const PoolLocation& a_location) const noexcept;
2322
2329 void
2330 finalize(Pool& a_pool, const TapeDetail::Staging<T, BranchingRatio, Primitives>& a_staging);
2331};
2332
2338template <class T, class... UserPrimitives>
2339struct RayForm<Tape<T, UserPrimitives...>>
2340{
2350 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2351 static inline HitT<T>
2353 const RayT<T>& a_ray,
2354 T a_tMin,
2355 T a_tMax,
2356 const RayOptions<T>& a_options) noexcept
2357 {
2358 return a_shape.traceRay(a_ray, a_tMin, a_tMax, a_options);
2359 }
2360
2371 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
2372 static inline CrossingT<T>
2374 const RayT<T>& a_ray,
2375 T a_tMin,
2376 T a_tMax,
2377 const RayOptions<T>& a_options) noexcept
2378 {
2379 const auto trace =
2380 [&a_shape, &a_ray, &a_options](const T a_t0, const T a_t1, const bool a_all, RaySpansT<T>& a_spans) noexcept {
2381 a_shape.raySpans(a_ray, a_t0, a_t1, a_options, !a_all, a_spans);
2382 };
2383
2384 return RayDetail::traceCrossing(trace, a_ray, a_tMin, a_tMax);
2385 }
2386
2398 static inline void
2400 const RayT<T>& a_ray,
2401 T a_tMin,
2402 T a_tMax,
2403 const RayOptions<T>& a_options,
2404 bool a_firstOnly,
2405 RaySpansT<T>& a_spans) noexcept
2406 {
2407 a_shape.raySpans(a_ray, a_tMin, a_tMax, a_options, a_firstOnly, a_spans);
2408 }
2409};
2410
2411} // namespace EBGeometry
2412
2413#include "EBGeometry_TapeImplem.hpp"
2414
2415#endif
File containing various analytic signed distance fields.
BVH-accelerated unions of many primitives of one or more types: BVHUnion and BVHSmoothUnion.
Declarations of bounding volume types used in bounding volume hierarchies.
The ray forms (see RayForm) of compositions: the fused union, intersection, difference,...
How far a function's value can be trusted as a distance: DistanceQuality, and the distanceQualityOf t...
The tape's front end: Expr, a host-side value that describes a composed object, and the free function...
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_NOINLINE
Keep a function out of line in a host pass (GCC and Clang); nothing in a device pass.
Definition EBGeometry_GPU.hpp:135
#define EBGEOMETRY_DEVICE_NOINLINE
Keep a function out of line in the device pass (CUDA/HIP); nothing on the host.
Definition EBGeometry_GPU.hpp:110
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
LeafRef: which leaf of a composition decides its value at a point.
Declaration of signed distance functions for DCEL meshes.
Ray forms of offsets and annuli: the level sets of their operands' values.
Placement-independent POD array views for the GPU memory foundation.
The flattened, device-callable bounding volume hierarchy: PackedBVH, its node layout,...
Growable bump arena for the GPU memory foundation.
Ray queries on any shape: where a ray, or the segment between two points, first crosses its surface (...
Subdomains: the subdomain of each region of a tape, read on the host or a device.
SurfaceRef: which surface of a shape decides its value at a point, and the container protocol that na...
typename Concat< TypeList< PlaneSDF< T >, SphereSDF< T >, BoxSDF< T >, TorusSDF< T >, CylinderSDF< T >, InfiniteCylinderSDF< T >, CapsuleSDF< T >, InfiniteConeSDF< T >, ConeSDF< T >, RoundedBoxSDF< T >, RoundedCylinderSDF< T >, PerlinSDF< T >, FlatMeshSDF< T >, MeshSDF< T, BVH::DefaultBranchingRatio< T >()>, TriMeshSDF< T, BVH::DefaultBranchingRatio< T >(), TriangleSoA::DefaultWidth< T >()> >, UserTypesOf< UserPrimitives... >, TypeList< EllipsoidSDF< T >, CappedConeSDF< T >, RoundConeSDF< T >, PolygonPrismSDF< T >, TubeSDF< T >, CappedTorusSDF< T >, CutSphereSDF< T >, CutHollowSphereSDF< T >, WedgeSDF< T > > >::type Primitives
The tape's primitive types: twelve analytic shapes (PlaneSDF to PerlinSDF), the three mesh SDFs with ...
Definition EBGeometry_Tape.hpp:681
const auto & storeAt(const PrimitiveStore< P, Ps... > &a_store) noexcept
The pool array of the I-th primitive type.
Definition EBGeometry_Tape.hpp:612
RayOp
The operations of a ray program.
Definition EBGeometry_Tape.hpp:172
@ PopAffine
Pop a ray, and map the top list back through the map at params[m_a..m_a+12).
RayClause rayClause(const Clause &a_clause) noexcept
The ray program clause a stored clause is.
Definition EBGeometry_Tape.hpp:302
constexpr uint32_t LeafProgram
The bit a BVH union's leaf sets on its sub-program's index when that sub-program is one shape,...
Definition EBGeometry_Tape.hpp:339
Clause stored(const RayClause &a_clause) noexcept
A ray program clause, stored in the clause array (the two have the same fields).
Definition EBGeometry_Tape.hpp:280
Op
The tape's operations.
Definition EBGeometry_Tape.hpp:140
@ PairInsert
Pop v and insert it into the pair below: the two smallest, or largest if m_flags is 1.
@ MulConstant
v -> v * params[m_a].
@ PushAffine
Push the top point mapped by the affine map at params[m_a..m_a+12).
@ Max
Pop b and a, push max(a, b).
@ Min
Pop b and a, push min(a, b).
@ AddConstant
v -> v + params[m_a].
@ PushElongate
Push p - clamp(p, -h, h), h at params[m_a..m_a+3).
@ PairInit
Push the empty pair of extreme values (+inf, +inf), or (-inf, -inf) if m_flags is 1.
typename Concat< std::conditional_t< IsFeature< Args >, TypeList<>, TypeList< Args > >... >::type UserTypesOf
The user primitive types among a Tape's template arguments: those that are not features.
Definition EBGeometry_Tape.hpp:546
constexpr bool IsFeature
Whether a Tape template argument is a feature (see TapeFeature).
Definition EBGeometry_Tape.hpp:530
typename Concat< std::conditional_t< IsFeature< Args >, TypeList< Args >, TypeList<> >... >::type FeaturesOf
The features among a Tape's template arguments.
Definition EBGeometry_Tape.hpp:538
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Forward declaration of the linearised BVH, defined below.
Definition EBGeometry_PackedBVH.hpp:369
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
Signed distance field for an axis-aligned box (AABB).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:352
Signed distance field for a capped cone (a frustum): a cone cut flat at both ends,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2779
Signed distance field for a capped torus: an arc of a torus with flat ends, such as a pipe elbow.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3841
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1178
Signed distance field for a finite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1516
Signed distance field for a cut hollow sphere: a spherical shell of some thickness,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4326
Signed distance field for a cut sphere: the part of a sphere above a horizontal plane,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4116
Signed distance field for a finite, flat-capped cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:758
A composed object: an immutable tree of shapes and operations, built on the host and compiled by a Ta...
Definition EBGeometry_Expr.hpp:452
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition EBGeometry_MeshDistanceFunctions.hpp:99
Signed distance field for an infinite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1390
Signed distance field for an infinitely long cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1008
A FlatMeshSDF must be trivially copyable: that is what lets a rebasedView() be byte-copied into a dev...
Definition EBGeometry_MeshDistanceFunctions.hpp:315
Ken Perlin's gradient-noise implicit function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1863
Signed distance field for a regular prism: a regular polygon of n sides, extruded between two end cen...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3294
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:563
PoolHandle() noexcept=default
An unset location; the first reservation attaches it.
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
The visible regions of a tape, as a shape to look at: its surfaces are the regions' surfaces,...
Definition EBGeometry_RegionView.hpp:51
Signed distance field for a round cone: two spheres, of different radii, and the cone tangent to both...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3040
Signed distance field for an axis-aligned box with rounded edges and corners.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1688
Signed distance field for a cylinder with rounded (toroidal) edges.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2165
Signed distance field for a sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:200
The subdomains of a domain (see Domain), read on the host or a device: the subdomain of each region o...
Definition EBGeometry_Subdomains.hpp:51
A composed object compiled into a pool: a trivially copyable handle that evaluates the object's signe...
Definition EBGeometry_Tape.hpp:758
static constexpr uint32_t RayStackSize
Span lists a ray program may hold at once; a subtree that would need more is marched.
Definition EBGeometry_Tape.hpp:806
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,...
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].
MaterialLabelId getMaterialOf(uint32_t a_region) const noexcept
A region's material, as ExprIndex numbers the material labels. Callable on a device.
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.
Definition EBGeometry_Tape.hpp:945
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,...
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 o...
static constexpr uint32_t ValueStackSize
Values a sub-program may hold at once.
Definition EBGeometry_Tape.hpp:796
Tape()=delete
No empty tape.
uint32_t getNumClauses() const noexcept
Number of clauses over all sub-programs (the ray programs' not counted).
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),...
uint32_t getFirstSurface(uint32_t a_leaf) const noexcept
A leaf's first surface: the leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)),...
static constexpr size_t BranchingRatio
Branching factor of the BVHs over union operands.
Definition EBGeometry_Tape.hpp:786
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.
static constexpr uint32_t PointStackSize
Points a sub-program may hold at once (its input point included).
Definition EBGeometry_Tape.hpp:801
SurfaceLabelId getSurfaceLabel(uint32_t a_leaf) const noexcept
A leaf's label, as SurfaceLabel() resolves it (ExprIndex::getSurfaceLabel()): the nearest label above...
uint32_t getCallDepth() const noexcept
How deep sub-program calls nest (0 if the tape has no Blur, Mollify, FiniteRepetition or BVH union).
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 signedDi...
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).
TapeDetail::Primitives< T, UserPrimitives... > Primitives
The primitive types: the built-in ones, then UserPrimitives.
Definition EBGeometry_Tape.hpp:811
Tape deepCopy(Pool &a_dstPool) const
Copy the tape, and every pool-resident primitive and BVH it holds, into another pool.
bool isPrimitive(const LeafRef< T > &a_ref) const noexcept
Whether a reference's leaf is a primitive of type P.
uint32_t getNumSurfaces() const noexcept
How many surfaces the tape numbers (see closestSurface()).
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),...
T signedDistance(const Vec3T< T > &a_point) const noexcept
The object's value at a point: negative inside, positive outside, zero on the surface.
uint32_t getNumRegions() const noexcept
How many regions the object has: the background (region 0) and one per operand of its Overlays,...
uint32_t getNumPrimitives() const noexcept
Number of primitives (leaves) in the tape, each occurrence counted.
TapeDetail::FeaturesOf< UserPrimitives... > Features
The features the tape compiles (see TapeFeature): its template arguments derived from TapeFeature::Ta...
Definition EBGeometry_Tape.hpp:769
uint32_t getNumSurfaceLabels() const noexcept
How many distinct labels the expression has (ExprIndex::getNumSurfaceLabels()).
uint32_t getLargestPlainUnion() const noexcept
The most objects in one union evaluated as written (one not built with Accelerate::BVH),...
Tape rebasedView(const Pool &a_pool) const noexcept
A view of this tape resolving against another pool of its mirror chain.
Tape(Pool &a_pool, const Expr< T > &a_expr, const TapeOptions &a_options=TapeOptions())
Compile an expression into a pool.
const Layout & layout() const noexcept
The tape's arrays, with no location: what an outer pool-resident object stores.
static constexpr bool hasFeature
Whether the tape compiles feature F (see TapeFeature).
Definition EBGeometry_Tape.hpp:776
static constexpr unsigned MaxCallDepth
How deep Blur, Mollify, FiniteRepetition and BVH unions may nest.
Definition EBGeometry_Tape.hpp:791
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.
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(),...
uint32_t getNumBVHUnions() const noexcept
Number of unions evaluated with a BVH (those built with Accelerate::BVH).
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,...
Signed distance field for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:563
Signed distance function for a pure triangle mesh using SoA-grouped primitives in a compact (lineariz...
Definition EBGeometry_MeshDistanceFunctions.hpp:627
Signed distance field for a tube (a pipe): the space between two coaxial cylinders,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3605
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Signed distance field for an infinite wedge: a knife edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4545
Construction
The preset BVH construction methods that the library's own BVH users accept.
Definition EBGeometry_PackedBVH.hpp:65
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.
@ Part
The surface's part: a box's face, a mesh's face.
Expr< ExprPrecision< A > > Intersection(const A &a_first, const B &a_second)
Intersection of two objects: the maximum of their values.
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 > > Complement(const A &a_operand)
Complement: inside and outside swapped, -v.
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
@ NotADistance
Only the sign is meaningful, so the function describes a surface (its zero level set) but says nothin...
HitStatus
The outcome of a ray query.
Definition EBGeometry_Ray.hpp:86
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...
@ None
As written: the tape evaluates every operand, however many there are.
The BVH's arrays as offsets into its pool, and its root box: a PackedBVH minus its location.
Definition EBGeometry_PackedBVH.hpp:1140
Where a ray first crosses a surface, without the normal or the primitive there: what firstCrossing() ...
Definition EBGeometry_Ray.hpp:157
Where a ray first crosses a surface.
Definition EBGeometry_Ray.hpp:98
The deciding leaf of a composition at a point: the primitive whose surface the composed value comes f...
Definition EBGeometry_LeafRef.hpp:42
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:131
Where a pool-resident descriptor resolves its offsets, and the rules for moving it.
Definition EBGeometry_Pool.hpp:99
static HitT< T > firstHit(const Tape< T, UserPrimitives... > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the tape's object along a ray.
Definition EBGeometry_Tape.hpp:2352
static void spans(const Tape< T, UserPrimitives... > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options, bool a_firstOnly, RaySpansT< T > &a_spans) noexcept
Where a ray is inside the tape's object over an interval.
Definition EBGeometry_Tape.hpp:2399
static CrossingT< T > firstCrossing(const Tape< T, UserPrimitives... > &a_shape, const RayT< T > &a_ray, T a_tMin, T a_tMax, const RayOptions< T > &a_options) noexcept
The first crossing of the tape's object along a ray, without the normal or primitive there: the trace...
Definition EBGeometry_Tape.hpp:2373
How to ray trace a shape directly, instead of marching its signed distance.
Definition EBGeometry_Ray.hpp:401
How a query marches, where a shape has no ray form.
Definition EBGeometry_Ray.hpp:203
Where a ray is inside an object over an interval [t0, t1]: its spans, in order, each from where it en...
Definition EBGeometry_Ray.hpp:296
A ray: the points origin + t * direction.
Definition EBGeometry_Ray.hpp:56
A ray's first crossing of a shape's surface, with the surface it crossed, as firstSurface() reports i...
Definition EBGeometry_Ray.hpp:550
The surface that decides a shape's value at a point, as closestSurface() reports it.
Definition EBGeometry_SurfaceRef.hpp:39
Whether a TypeList holds a container (see hasSurfaces).
Definition EBGeometry_Tape.hpp:392
Whether a TypeList holds a container or a shape with parts (see hasSurfaces, hasParts): whether close...
Definition EBGeometry_Tape.hpp:413
One tape clause.
Definition EBGeometry_Tape.hpp:238
uint32_t m_a
First operand.
Definition EBGeometry_Tape.hpp:257
uint32_t m_b
Second operand.
Definition EBGeometry_Tape.hpp:262
Op m_op
Operation.
Definition EBGeometry_Tape.hpp:242
uint16_t m_type
Primitive type index (Primitive).
Definition EBGeometry_Tape.hpp:252
uint32_t m_c
Third operand.
Definition EBGeometry_Tape.hpp:267
uint8_t m_flags
Operation flags.
Definition EBGeometry_Tape.hpp:247
typename Concat< TypeList< Ps... >, typename Concat< Rest... >::type >::type type
The concatenation.
Definition EBGeometry_Tape.hpp:506
The concatenation of TypeLists.
Definition EBGeometry_Tape.hpp:487
TypeList<> type
The concatenation.
Definition EBGeometry_Tape.hpp:491
The index of type P in a TypeList (its size if P is not in it).
Definition EBGeometry_Tape.hpp:448
PODVector< CSGDetail::Stored< P > > m_head
The first type's primitives.
Definition EBGeometry_Tape.hpp:570
PrimitiveStore< Ps... > m_tail
The remaining types' primitives.
Definition EBGeometry_Tape.hpp:575
One pool array per primitive type, holding the type's stored form (CSGDetail::Stored).
Definition EBGeometry_Tape.hpp:555
A sub-program: a range of clauses.
Definition EBGeometry_Tape.hpp:321
uint32_t m_begin
First clause.
Definition EBGeometry_Tape.hpp:325
uint32_t m_end
One past the last clause.
Definition EBGeometry_Tape.hpp:330
One ray program clause.
Definition EBGeometry_Tape.hpp:199
RayOp m_op
Operation.
Definition EBGeometry_Tape.hpp:203
uint16_t m_type
Primitive type index (Leaf, and a Marched clause holding a deferred level set).
Definition EBGeometry_Tape.hpp:213
uint32_t m_c
Third operand.
Definition EBGeometry_Tape.hpp:228
uint8_t m_flags
Operation flags.
Definition EBGeometry_Tape.hpp:208
uint32_t m_a
First operand.
Definition EBGeometry_Tape.hpp:218
uint32_t m_b
Second operand.
Definition EBGeometry_Tape.hpp:223
Host-side arrays the compiler fills before they are reserved in the pool.
Definition EBGeometry_Tape.hpp:720
The PrimitiveStore for the types of a TypeList.
Definition EBGeometry_Tape.hpp:584
std::tuple_element_t< I, std::tuple< Ps... > > type
The type.
Definition EBGeometry_Tape.hpp:438
The I-th type of a TypeList.
Definition EBGeometry_Tape.hpp:383
A list of types.
Definition EBGeometry_Tape.hpp:369
static constexpr size_t size
Number of types.
Definition EBGeometry_Tape.hpp:373
A BVH union's two parts, as layouts in the tape's pool: a BVH over the sub-programs with bounded boxe...
Definition EBGeometry_Tape.hpp:350
BVH::PackedBVH< T, uint32_t, K >::Layout m_bvh
BVH over the sub-programs with bounded boxes.
Definition EBGeometry_Tape.hpp:354
BVH::PackedBVH< T, uint32_t, K >::Layout m_unbounded
Leaf holding the sub-programs with unbounded boxes.
Definition EBGeometry_Tape.hpp:359
Whether a tape's user primitive types are shapes of its precision.
Definition EBGeometry_Tape.hpp:690
Ray queries trace an Offset or Annular of a primitive with closed-form level sets (or of an affine ma...
Definition EBGeometry_Tape.hpp:126
Base of every feature: a Tape template argument derived from it is a feature, not a primitive type.
Definition EBGeometry_Tape.hpp:116
Settings for compiling an Expr into a Tape.
Definition EBGeometry_Tape.hpp:62
BVH::Construction m_construction
How the BVHs of unions built with Accelerate::BVH are built.
Definition EBGeometry_Tape.hpp:79
uint32_t m_largeUnionWarning
A union or smooth union evaluated as written (not built with Accelerate::BVH) of at least this many o...
Definition EBGeometry_Tape.hpp:74
The tape's arrays as offsets into its pool, with no location (see PoolHandle).
Definition EBGeometry_Tape.hpp:822
PODVector< uint32_t > m_regionPrograms
The regions: the number n of the Overlays' operands (0 without an Overlay), then each operand's recor...
Definition EBGeometry_Tape.hpp:913
uint32_t m_largestPlainUnion
The most objects in one union evaluated as written (see getLargestPlainUnion()).
Definition EBGeometry_Tape.hpp:881
uint32_t m_numPrograms
How many sub-programs there are (the first entries of m_programs).
Definition EBGeometry_Tape.hpp:871
uint32_t m_rayPrograms
Where in m_programs the ray programs begin: sub-program i's is entry m_rayPrograms + i (an empty rang...
Definition EBGeometry_Tape.hpp:887
uint32_t m_numLabels
How many distinct labels the expression has.
Definition EBGeometry_Tape.hpp:918
BV m_boundingVolume
A box enclosing the object.
Definition EBGeometry_Tape.hpp:856
PODVector< TapeDetail::UnionBVH< T, BranchingRatio > > m_unions
The BVH unions.
Definition EBGeometry_Tape.hpp:851
PODVector< TapeDetail::Clause > m_clauses
The clauses of every sub-program, one after another.
Definition EBGeometry_Tape.hpp:831
PODVector< uint32_t > m_surfaceLabels
Each leaf's label (see getSurfaceLabel()); empty when the expression has no Label.
Definition EBGeometry_Tape.hpp:892
PODVector< TapeDetail::Program > m_programs
Each sub-program's clause range; sub-program 0 is the whole object. After the m_numPrograms sub-progr...
Definition EBGeometry_Tape.hpp:841
PODVector< uint32_t > m_partSurfaceLabels
The part labels (see SurfaceLabel(shape, FaceGroups)): first, per leaf, where its parts' labels begin...
Definition EBGeometry_Tape.hpp:904
DistanceQuality m_quality
How far the value can be trusted as a distance.
Definition EBGeometry_Tape.hpp:861
PODVector< uint32_t > m_surfaces
Each leaf's first surface, and the number of surfaces last (see getFirstSurface()); empty when no lea...
Definition EBGeometry_Tape.hpp:898
PODVector< T > m_params
Constant parameters the clauses refer to.
Definition EBGeometry_Tape.hpp:846
uint32_t m_numPrimitives
How many primitives (leaves) the tape has, each occurrence counted.
Definition EBGeometry_Tape.hpp:876
uint32_t m_callDepth
How deep sub-program calls nest from sub-program 0.
Definition EBGeometry_Tape.hpp:866
TapeDetail::StoreOf< Primitives >::type m_primitives
One array per primitive type.
Definition EBGeometry_Tape.hpp:826