EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_Expr.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
16#ifndef EBGEOMETRY_EXPR_HPP
17#define EBGEOMETRY_EXPR_HPP
18
19// Std includes
20#include <cstddef>
21#include <cstdint>
22#include <functional>
23#include <initializer_list>
24#include <memory>
25#include <string>
26#include <string_view>
27#include <type_traits>
28#include <typeindex>
29#include <typeinfo>
30#include <unordered_map>
31#include <utility>
32#include <vector>
33
34// Our includes
35#include "EBGeometry_Affine.hpp"
39#include "EBGeometry_Pool.hpp"
41#include "EBGeometry_Vec.hpp"
42
43namespace EBGeometry {
44
48enum class BlendKind : uint8_t
49{
52};
53
57enum class Accelerate : uint8_t
58{
59 None,
60 BVH
61};
62
63namespace ExprDetail {
64
70template <class B>
72{
73};
74
80template <class T>
81struct BoxPrecision<BoundingVolumes::AABBT<T>>
82{
86 using type = T;
87};
88
95template <class S, class T, class = void>
96struct HasSignedDistance : std::false_type
97{
98};
99
106template <class S, class T>
108 S,
109 T,
110 std::void_t<decltype(std::declval<const S&>().signedDistance(std::declval<const Vec3T<T>&>()))>>
111 : std::is_convertible<decltype(std::declval<const S&>().signedDistance(std::declval<const Vec3T<T>&>())), T>
112{
113};
114
120template <class S, class = void>
122{
126 static constexpr bool value = false;
127};
128
134template <class S>
136 S,
137 std::void_t<typename BoxPrecision<std::decay_t<decltype(std::declval<const S&>().computeBoundingVolume())>>::type>>
138{
142 using precision =
143 typename BoxPrecision<std::decay_t<decltype(std::declval<const S&>().computeBoundingVolume())>>::type;
144
148 static constexpr bool value = std::is_trivially_copyable_v<S> && HasSignedDistance<S, precision>::value;
149};
150
151} // namespace ExprDetail
152
168template <class S>
170
175template <class S>
177
178template <class T>
179class Expr;
180
181namespace ExprDetail {
182
188enum class Kind : uint8_t
189{
190 Primitive,
191 Affine,
192 Elongate,
193 Repeat,
194 Complement,
195 Offset,
196 Annular,
197 Blur,
198 Mollify,
199 Union,
203};
204
210struct Leaf
211{
215 std::shared_ptr<const void> m_object;
216
220 std::type_index m_type = std::type_index(typeid(void));
221
225 bool (*m_isAttachedTo)(const void*, const Pool&) = nullptr;
226
230 uint32_t (*m_numSurfaces)(const void*) = nullptr;
231
235 uint32_t (*m_numParts)(const void*) = nullptr;
236};
237
244template <class T>
245struct Node
246{
250 Kind m_kind = Kind::Primitive;
251
256 std::vector<Expr<T>> m_children;
257
262
267
272
276 T m_valueScale = T(1);
277
282
287
292
297 T m_scalar0 = T(0);
298
302 T m_scalar1 = T(0);
303
307 uint32_t m_count = 0;
308
313
317 bool m_bvh = false;
318
323
328
332 std::string m_surfaceLabel;
333
337 std::shared_ptr<const FaceGroups> m_partGroups;
338
342 std::string m_materialLabel;
343
347 std::string m_regionName;
348
353 bool m_overlay = false;
354
359 bool m_partition = false;
360
365 bool m_namesRegion = false;
366};
367
373template <class A, class = void>
375{
376};
377
383template <class T>
384struct ExprLike<Expr<T>, void>
385{
389 using type = T;
390};
391
397template <class S>
398struct ExprLike<S, std::enable_if_t<isShape<S>>>
399{
404};
405
414template <class S, class T, class = void>
415struct OtherPrecision : std::false_type
416{
417};
418
424template <class S, class T>
425struct OtherPrecision<S, T, std::void_t<typename ExprLike<S>::type>>
426 : std::bool_constant<!std::is_same_v<typename ExprLike<S>::type, T>>
427{
428};
429
430} // namespace ExprDetail
431
437template <class A>
439
450template <class T>
451class Expr
452{
453public:
454 static_assert(std::is_floating_point_v<T>, "Expr requires a floating-point type T");
455
460
464 Expr() = delete;
465
472 template <class S,
473 class = std::enable_if_t<!std::is_same_v<std::decay_t<S>, Expr> &&
474 !std::is_convertible_v<S, std::shared_ptr<const ExprDetail::Node<T>>> &&
477 Expr(const S& a_shape); // NOLINT(google-explicit-constructor): a shape is an expression
478
484 explicit Expr(std::shared_ptr<const ExprDetail::Node<T>> a_node) noexcept;
485
493 [[nodiscard]] EBGEOMETRY_HOST
494 const BV&
495 computeBoundingVolume() const noexcept;
496
503 [[nodiscard]] EBGEOMETRY_HOST
505 getDistanceQuality() const noexcept;
506
511 [[nodiscard]] EBGEOMETRY_HOST
512 const ExprDetail::Node<T>&
513 node() const noexcept;
514
515private:
519 std::shared_ptr<const ExprDetail::Node<T>> m_node;
520};
521
528template <class A>
529[[nodiscard]] EBGEOMETRY_HOST
530inline Expr<ExprPrecision<A>>
531toExpr(const A& a_operand);
532
541template <class A, class B>
542[[nodiscard]] EBGEOMETRY_HOST
543inline Expr<ExprPrecision<A>>
544Union(const A& a_first, const B& a_second);
545
560template <class A>
561[[nodiscard]] EBGEOMETRY_HOST
562inline Expr<ExprPrecision<A>>
563Union(const std::vector<A>& a_operands, Accelerate a_accelerate = Accelerate::None);
564
575template <class A, class B>
576[[nodiscard]] EBGEOMETRY_HOST
577inline Expr<ExprPrecision<A>>
578SmoothUnion(const A& a_first,
579 const B& a_second,
580 const ExprPrecision<A> a_smooth,
581 const BlendKind a_blend = BlendKind::Polynomial);
582
594template <class A>
595[[nodiscard]] EBGEOMETRY_HOST
596inline Expr<ExprPrecision<A>>
597SmoothUnion(const std::vector<A>& a_operands,
598 const ExprPrecision<A> a_smooth,
599 const BlendKind a_blend = BlendKind::Polynomial,
600 const Accelerate a_accelerate = Accelerate::None);
601
610template <class A>
611[[nodiscard]] EBGEOMETRY_HOST
612inline Expr<ExprPrecision<A>>
613SmoothUnion(const std::vector<A>& a_operands, const ExprPrecision<A> a_smooth, const Accelerate a_accelerate);
614
623template <class A, class B>
624[[nodiscard]] EBGEOMETRY_HOST
625inline Expr<ExprPrecision<A>>
626Intersection(const A& a_first, const B& a_second);
627
634template <class A>
635[[nodiscard]] EBGEOMETRY_HOST
636inline Expr<ExprPrecision<A>>
637Intersection(const std::vector<A>& a_operands);
638
649template <class A, class B>
650[[nodiscard]] EBGEOMETRY_HOST
651inline Expr<ExprPrecision<A>>
652SmoothIntersection(const A& a_first,
653 const B& a_second,
654 const ExprPrecision<A> a_smooth,
655 const BlendKind a_blend = BlendKind::Polynomial);
656
665template <class A>
666[[nodiscard]] EBGEOMETRY_HOST
667inline Expr<ExprPrecision<A>>
668SmoothIntersection(const std::vector<A>& a_operands,
669 const ExprPrecision<A> a_smooth,
670 const BlendKind a_blend = BlendKind::Polynomial);
671
680template <class A, class B>
681[[nodiscard]] EBGEOMETRY_HOST
682inline Expr<ExprPrecision<A>>
683Difference(const A& a_first, const B& a_second);
684
695template <class A, class B>
696[[nodiscard]] EBGEOMETRY_HOST
697inline Expr<ExprPrecision<A>>
698Difference(const A& a_first, const std::vector<B>& a_others, Accelerate a_accelerate = Accelerate::None);
699
710template <class A, class B>
711[[nodiscard]] EBGEOMETRY_HOST
712inline Expr<ExprPrecision<A>>
713SmoothDifference(const A& a_first,
714 const B& a_second,
715 const ExprPrecision<A> a_smooth,
716 const BlendKind a_blend = BlendKind::Polynomial);
717
728template <class A, class B>
729[[nodiscard]] EBGEOMETRY_HOST
730inline Expr<ExprPrecision<A>>
731SmoothDifference(const A& a_first,
732 const std::vector<B>& a_others,
733 const ExprPrecision<A> a_smooth,
734 const BlendKind a_blend = BlendKind::Polynomial);
735
753template <class A>
754[[nodiscard]] EBGEOMETRY_HOST
755inline Expr<ExprPrecision<A>>
756FiniteRepetition(const A& a_operand,
757 const Vec3T<ExprPrecision<A>>& a_period,
758 const Vec3T<ExprPrecision<A>>& a_repeatLo,
759 const Vec3T<ExprPrecision<A>>& a_repeatHi);
760
767template <class A>
768[[nodiscard]] EBGEOMETRY_HOST
769inline Expr<ExprPrecision<A>>
770Complement(const A& a_operand);
771
779template <class A>
780[[nodiscard]] EBGEOMETRY_HOST
781inline Expr<ExprPrecision<A>>
782Translate(const A& a_operand, const Vec3T<ExprPrecision<A>>& a_shift);
783
792template <class A>
793[[nodiscard]] EBGEOMETRY_HOST
794inline Expr<ExprPrecision<A>>
795Rotate(const A& a_operand, const ExprPrecision<A> a_degrees, const size_t a_axis);
796
805template <class A>
806[[nodiscard]] EBGEOMETRY_HOST
807inline Expr<ExprPrecision<A>>
808Rotate(const A& a_operand, const ExprPrecision<A> a_degrees, const Vec3T<ExprPrecision<A>>& a_axis);
809
819template <class A>
820[[nodiscard]] EBGEOMETRY_HOST
821inline Expr<ExprPrecision<A>>
822Scale(const A& a_operand, const ExprPrecision<A> a_factor);
823
831template <class A>
832[[nodiscard]] EBGEOMETRY_HOST
833inline Expr<ExprPrecision<A>>
834Reflect(const A& a_operand, const size_t a_axis);
835
844template <class A>
845[[nodiscard]] EBGEOMETRY_HOST
846inline Expr<ExprPrecision<A>>
847Offset(const A& a_operand, const ExprPrecision<A> a_offset);
848
856template <class A>
857[[nodiscard]] EBGEOMETRY_HOST
858inline Expr<ExprPrecision<A>>
859Annular(const A& a_operand, const ExprPrecision<A> a_delta);
860
869template <class A>
870[[nodiscard]] EBGEOMETRY_HOST
871inline Expr<ExprPrecision<A>>
872Elongate(const A& a_operand, const Vec3T<ExprPrecision<A>>& a_elongation);
873
885template <class A>
886[[nodiscard]] EBGEOMETRY_HOST
887inline Expr<ExprPrecision<A>>
888Blur(const A& a_operand, const ExprPrecision<A> a_blur, const ExprPrecision<A> a_alpha = ExprPrecision<A>(0.5));
889
901template <class A>
902[[nodiscard]] EBGEOMETRY_HOST
903inline Expr<ExprPrecision<A>>
904Mollify(const A& a_operand, const ExprPrecision<A> a_dist, const size_t a_samples);
905
921template <class A>
922[[nodiscard]] EBGEOMETRY_HOST
923inline Expr<ExprPrecision<A>>
924SurfaceLabel(const A& a_operand, std::string a_name);
925
941template <class A>
942[[nodiscard]] EBGEOMETRY_HOST
943inline Expr<ExprPrecision<A>>
944SurfaceLabel(const A& a_operand, FaceGroups a_groups);
945
966template <class A>
967[[nodiscard]] EBGEOMETRY_HOST
968inline Expr<ExprPrecision<A>>
969Overlay(const std::vector<A>& a_operands);
970
981template <class A, class B, class... Rest>
982[[nodiscard]] EBGEOMETRY_HOST
983inline Expr<ExprPrecision<A>>
984Overlay(const A& a_first, const B& a_second, const Rest&... a_rest);
985
992[[nodiscard]] EBGEOMETRY_HOST
993inline Expr<double>
994Overlay(std::initializer_list<Expr<double>> a_operands);
995
1001[[nodiscard]] EBGEOMETRY_HOST
1002inline Expr<float>
1003Overlay(std::initializer_list<Expr<float>> a_operands);
1004
1017template <class A>
1018[[nodiscard]] EBGEOMETRY_HOST
1019inline Expr<ExprPrecision<A>>
1020MaterialLabel(const A& a_operand, std::string a_name);
1021
1035template <class A>
1036[[nodiscard]] EBGEOMETRY_HOST
1037inline Expr<ExprPrecision<A>>
1038RegionName(const A& a_operand, std::string a_name);
1039
1056template <class T>
1058{
1059public:
1063 static constexpr uint32_t None = 0xFFFFFFFFU;
1064
1068 struct Node
1069 {
1073 uint32_t m_parent = None;
1074
1078 uint32_t m_firstLeaf = 0;
1079
1083 uint32_t m_numLeaves = 0;
1084
1088 uint32_t m_firstSurface = 0;
1089
1093 uint32_t m_numSurfaces = 0;
1094
1099
1104
1110 std::string m_operation;
1111 };
1112
1117 struct Region
1118 {
1122 uint32_t m_node = None;
1123
1127 uint32_t m_regionGroup = None;
1128
1133
1137 std::string m_name;
1138 };
1139
1145 {
1149 uint32_t m_node = None;
1150
1154 uint32_t m_parent = None;
1155
1159 uint32_t m_firstRegion = 0;
1160
1164 uint32_t m_numRegions = 0;
1165
1170
1174 std::string m_name;
1175 };
1176
1180 ExprIndex() = delete;
1181
1187 explicit ExprIndex(const Expr<T>& a_expr);
1188
1193 [[nodiscard]] EBGEOMETRY_HOST
1194 uint32_t
1195 getNumNodes() const noexcept;
1196
1202 [[nodiscard]] EBGEOMETRY_HOST
1203 const Node&
1204 getNode(uint32_t a_node) const;
1205
1210 [[nodiscard]] EBGEOMETRY_HOST
1211 uint32_t
1212 getNumLeaves() const noexcept;
1213
1219 [[nodiscard]] EBGEOMETRY_HOST
1220 uint32_t
1221 getLeafNode(uint32_t a_leaf) const;
1222
1229 [[nodiscard]] EBGEOMETRY_HOST
1230 std::vector<uint32_t>
1231 pathOf(uint32_t a_leaf) const;
1232
1237 [[nodiscard]] EBGEOMETRY_HOST
1238 uint32_t
1239 getNumSurfaces() const noexcept;
1240
1247 [[nodiscard]] EBGEOMETRY_HOST
1248 uint32_t
1249 getFirstSurface(uint32_t a_leaf) const;
1250
1256 [[nodiscard]] EBGEOMETRY_HOST
1257 uint32_t
1258 getLeafOfSurface(uint32_t a_surface) const;
1259
1266 [[nodiscard]] EBGEOMETRY_HOST
1268 getSurfaceLabel(uint32_t a_leaf) const;
1269
1276 [[nodiscard]] EBGEOMETRY_HOST
1277 uint32_t
1278 getNumPartsOfLeaf(uint32_t a_leaf) const;
1279
1287 [[nodiscard]] EBGEOMETRY_HOST
1289 getPartSurfaceLabel(uint32_t a_leaf, uint32_t a_part) const;
1290
1297 [[nodiscard]] EBGEOMETRY_HOST
1298 const std::vector<SurfaceLabelId>&
1299 getPartSurfaceLabels(uint32_t a_leaf) const;
1300
1305 [[nodiscard]] EBGEOMETRY_HOST
1306 uint32_t
1307 getNumSurfaceLabels() const noexcept;
1308
1314 [[nodiscard]] EBGEOMETRY_HOST
1315 const std::string&
1316 getSurfaceLabelName(SurfaceLabelId a_label) const;
1317
1323 [[nodiscard]] EBGEOMETRY_HOST
1325 findSurfaceLabel(std::string_view a_name) const;
1326
1332 [[nodiscard]] EBGEOMETRY_HOST
1333 uint32_t
1334 getNumRegions() const noexcept;
1335
1341 [[nodiscard]] EBGEOMETRY_HOST
1342 const Region&
1343 getRegion(uint32_t a_region) const;
1344
1350 [[nodiscard]] EBGEOMETRY_HOST
1351 uint32_t
1352 getRegionOfLeaf(uint32_t a_leaf) const;
1353
1359 [[nodiscard]] EBGEOMETRY_HOST
1361 getMaterialOf(uint32_t a_region) const;
1362
1368 [[nodiscard]] EBGEOMETRY_HOST
1369 std::vector<uint32_t>
1370 getRegionsOfRegionGroup(uint32_t a_group) const;
1371
1377 [[nodiscard]] EBGEOMETRY_HOST
1378 std::vector<uint32_t>
1379 getRegionsOfMaterial(MaterialLabelId a_material) const;
1380
1390 [[nodiscard]] EBGEOMETRY_HOST
1391 const std::vector<std::pair<uint32_t, uint32_t>>&
1392 getSidesOfLeaf(uint32_t a_leaf) const;
1393
1398 [[nodiscard]] EBGEOMETRY_HOST
1399 std::vector<std::pair<uint32_t, uint32_t>>
1400 getInterfaces() const;
1401
1406 [[nodiscard]] EBGEOMETRY_HOST
1407 uint32_t
1408 getNumRegionGroups() const noexcept;
1409
1415 [[nodiscard]] EBGEOMETRY_HOST
1416 const RegionGroup&
1417 getRegionGroup(uint32_t a_group) const;
1418
1423 [[nodiscard]] EBGEOMETRY_HOST
1424 uint32_t
1425 getNumMaterialLabels() const noexcept;
1426
1432 [[nodiscard]] EBGEOMETRY_HOST
1433 const std::string&
1434 getMaterialLabelName(MaterialLabelId a_label) const;
1435
1441 [[nodiscard]] EBGEOMETRY_HOST
1443 findMaterialLabel(std::string_view a_name) const;
1444
1450 [[nodiscard]] EBGEOMETRY_HOST
1451 uint32_t
1452 findRegion(std::string_view a_name) const;
1453
1480 template <class TapeType>
1481 [[nodiscard]] EBGEOMETRY_HOST
1482 std::vector<std::string>
1483 checkLabels(const Expr<T>& a_expr, const TapeType& a_tape) const;
1484
1485private:
1489 std::vector<Node> m_nodes;
1490
1494 std::vector<uint32_t> m_leafNodes;
1495
1499 std::vector<SurfaceLabelId> m_leafSurfaceLabels;
1500
1504 std::vector<uint32_t> m_leafSurfaces;
1505
1509 std::vector<std::vector<SurfaceLabelId>> m_leafPartSurfaceLabels;
1510
1514 std::vector<uint32_t> m_leafParts;
1515
1519 std::vector<std::string> m_surfaceLabelNames;
1520
1524 std::unordered_map<std::string, SurfaceLabelId> m_surfaceLabelIds;
1525
1530 std::vector<const ExprDetail::Node<T>*> m_exprNodes;
1531
1535 std::vector<std::vector<uint32_t>> m_operands;
1536
1544 [[nodiscard]] std::string
1545 whyHidden(uint32_t a_node,
1546 const std::vector<const ExprDetail::Node<T>*>& a_nodes,
1547 const std::function<bool(const ExprDetail::Node<T>&, const Vec3T<T>&, T&)>& a_leafValue) const;
1548
1552 std::vector<Region> m_regions;
1553
1557 std::vector<RegionGroup> m_regionGroups;
1558
1562 std::vector<uint32_t> m_leafRegions;
1563
1567 std::vector<std::string> m_materialLabelNames;
1568
1572 std::unordered_map<std::string, MaterialLabelId> m_materialLabelIds;
1573
1577 struct Mask
1578 {
1582 uint32_t m_node;
1583
1588
1592 uint32_t m_firstRegion;
1593
1597 uint32_t m_numRegions;
1598 };
1599
1603 std::vector<BoundingVolumes::AABBT<T>> m_regionBoxes;
1604
1608 std::vector<Mask> m_masks;
1609
1613 std::vector<const ExprDetail::Node<T>*> m_maps;
1614
1618 std::vector<std::vector<std::pair<uint32_t, uint32_t>>> m_leafSides;
1619
1626 sceneBox(const BoundingVolumes::AABBT<T>& a_box) const;
1627
1631 void
1632 addSides();
1633
1640 internMaterial(const std::string& a_name);
1641
1648 void
1649 addRegions(uint32_t a_node, uint32_t a_group, MaterialLabelId a_material);
1650
1659 void
1660 add(const ExprDetail::Node<T>& a_node, uint32_t a_parent, SurfaceLabelId a_label, bool a_object = false);
1661};
1662
1663} // namespace EBGeometry
1664
1665#include "EBGeometry_ExprImplem.hpp"
1666
1667#endif
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:189
@ Affine
Evaluate the child at m_map(p) and multiply by m_valueScale.
@ Repeat
Evaluate the child at p folded into the home tile.
FaceGroups: named groups of a mesh's faces, as a file names them.
#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.
SurfaceRef: which surface of a shape decides its value at a point, and the container protocol that na...
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
The nodes of an expression, numbered, with the leaves below each and their labels: on the host,...
Definition EBGeometry_Expr.hpp:1058
ExprIndex(const Expr< T > &a_expr)
Number the nodes, leaves and labels of an expression.
ExprIndex()=delete
No empty index.
uint32_t getNumNodes() const noexcept
The number of nodes.
A composed object: an immutable tree of shapes and operations, built on the host and compiled by a Ta...
Definition EBGeometry_Expr.hpp:452
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:205
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:49
@ 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.
@ SurfaceLabel
The surface's label (SurfaceLabel()).
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.
Expr< ExprPrecision< A > > RegionName(const A &a_operand, std::string a_name)
Name a region: an operand of an Overlay ("fluid", "wall"), or a whole Overlay nested in another (its ...
constexpr bool isShape
Whether S is a shape: a trivially copyable type with a const signedDistance(const Vec3T<T>&) returnin...
Definition EBGeometry_Expr.hpp:169
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:176
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 > > MaterialLabel(const A &a_operand, std::string a_name)
Name the material of a region: an operand of an Overlay, a whole Overlay nested in another (a default...
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 > > Overlay(const std::vector< A > &a_operands)
Regions by priority, a priority union: each operand is a region of its own, later operands on top of ...
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.
Accelerate
How a Tape evaluates a union of many objects: as written, or through a BVH over the objects' boxes.
Definition EBGeometry_Expr.hpp:58
@ None
As written: the tape evaluates every operand, however many there are.
@ BVH
Through a BVH over the operands' boxes, however many there are.
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:438
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:86
The precision of a bounding box type: T for AABBT<T>, nothing otherwise.
Definition EBGeometry_Expr.hpp:72
T type
The precision.
Definition EBGeometry_Expr.hpp:389
ShapePrecision< S > type
The precision.
Definition EBGeometry_Expr.hpp:403
Whether A is a shape or an Expr, and its precision: the primary template is neither.
Definition EBGeometry_Expr.hpp:375
Whether S has a const signedDistance(const Vec3T<T>&) returning something convertible to T.
Definition EBGeometry_Expr.hpp:97
A shape held by an expression, with its type erased.
Definition EBGeometry_Expr.hpp:211
std::shared_ptr< const void > m_object
Copy of the shape.
Definition EBGeometry_Expr.hpp:215
uint32_t(* m_numParts)(const void *)
For a shape with parts (see hasParts): how many it has. Null for a shape with one part.
Definition EBGeometry_Expr.hpp:235
uint32_t(* m_numSurfaces)(const void *)
For a container (see hasSurfaces): how many surfaces it holds. Null for a shape with one surface.
Definition EBGeometry_Expr.hpp:230
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:225
std::type_index m_type
The shape's type.
Definition EBGeometry_Expr.hpp:220
An expression node.
Definition EBGeometry_Expr.hpp:246
BoundingVolumes::AABBT< T > m_boundingVolume
A box enclosing the node's object.
Definition EBGeometry_Expr.hpp:322
Affine3T< T > m_map
Point map applied before the child is evaluated (Affine).
Definition EBGeometry_Expr.hpp:266
std::string m_regionName
The name RegionName() gave the node; empty for none.
Definition EBGeometry_Expr.hpp:347
Vec3T< T > m_vec1
Tiles in the decreasing direction of each axis, rounded to whole numbers (Repeat).
Definition EBGeometry_Expr.hpp:286
DistanceQuality m_quality
How far the node's value can be trusted as a distance.
Definition EBGeometry_Expr.hpp:327
BlendKind m_blend
Blend kind (smooth operations).
Definition EBGeometry_Expr.hpp:312
T m_scalar0
Offset distance (Offset), shell half-thickness (Annular), blur distance (Blur), mollification distanc...
Definition EBGeometry_Expr.hpp:297
Affine3T< T > m_inverse
Inverse of m_map, which maps the child's box to the node's (Affine).
Definition EBGeometry_Expr.hpp:271
std::shared_ptr< const FaceGroups > m_partGroups
For a primitive: the groups SurfaceLabel(shape, FaceGroups) put its parts in; null for none.
Definition EBGeometry_Expr.hpp:337
Vec3T< T > m_vec0
Elongation half-lengths (Elongate) or tile period (Repeat).
Definition EBGeometry_Expr.hpp:281
std::string m_materialLabel
The name MaterialLabel() gave the node; empty for none.
Definition EBGeometry_Expr.hpp:342
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:256
T m_scalar1
Blend weight alpha (Blur).
Definition EBGeometry_Expr.hpp:302
bool m_overlay
Whether this union is an Overlay: its operands are regions, later ones on top (see Overlay())....
Definition EBGeometry_Expr.hpp:353
Leaf m_leaf
The shape, for a primitive.
Definition EBGeometry_Expr.hpp:261
uint32_t m_count
Samples per axis (Mollify).
Definition EBGeometry_Expr.hpp:307
bool m_bvh
Whether a union asks the tape for a BVH over its operands (Accelerate::BVH).
Definition EBGeometry_Expr.hpp:317
std::string m_surfaceLabel
The name SurfaceLabel() gave the node; empty for none.
Definition EBGeometry_Expr.hpp:332
Vec3T< T > m_vec2
Tiles in the increasing direction of each axis, rounded to whole numbers (Repeat).
Definition EBGeometry_Expr.hpp:291
bool m_partition
Whether the node is a partition into regions: an Overlay, a map of one, or one clipped as the first o...
Definition EBGeometry_Expr.hpp:359
Kind m_kind
What the node does.
Definition EBGeometry_Expr.hpp:250
bool m_namesRegion
Whether the node, or a chain of maps below it, has a material label or a region name (MaterialLabel()...
Definition EBGeometry_Expr.hpp:365
T m_valueScale
Value multiplier applied after the child is evaluated (Affine): |s| for a scaling by s.
Definition EBGeometry_Expr.hpp:276
Whether a type is expression-like with a precision other than T (a shape or an Expr): the primary tem...
Definition EBGeometry_Expr.hpp:416
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:143
Shape detection: a type with computeBoundingVolume() returning AABBT<T>.
Definition EBGeometry_Expr.hpp:122
static constexpr bool value
Whether S is a shape.
Definition EBGeometry_Expr.hpp:126
One node of the expression.
Definition EBGeometry_Expr.hpp:1069
MaterialLabelId m_materialLabel
Its own material label, or none (MaterialLabel()).
Definition EBGeometry_Expr.hpp:1103
SurfaceLabelId m_surfaceLabel
Its own surface label, or none (the label its leaves inherit from further up is getSurfaceLabel()'s).
Definition EBGeometry_Expr.hpp:1098
std::string m_operation
What it does: Primitive, Transform, Elongate, Repeat, Complement, Offset, Annulus,...
Definition EBGeometry_Expr.hpp:1110
A group of regions: an Overlay, whose regions are a contiguous range (a nested Overlay a range inside...
Definition EBGeometry_Expr.hpp:1145
MaterialLabelId m_material
Its material label, the default of its regions without one of their own; or none.
Definition EBGeometry_Expr.hpp:1169
std::string m_name
Its name (RegionName() on the Overlay); empty for none.
Definition EBGeometry_Expr.hpp:1174
One region of the object (see Overlay()): the background (region 0), an operand of an Overlay,...
Definition EBGeometry_Expr.hpp:1118
std::string m_name
Its name (RegionName() on its operand, or on a map above it); empty for none and the background.
Definition EBGeometry_Expr.hpp:1137
MaterialLabelId m_material
Its material: its operand's material label, or its group's, or none.
Definition EBGeometry_Expr.hpp:1132
Named groups of a mesh's faces: an OBJ file's g and o groups, or the named solids of an ASCII STL fil...
Definition EBGeometry_FaceGroups.hpp:29