12#ifndef EBGEOMETRY_EXPLODEDVIEW_HPP
13#define EBGEOMETRY_EXPLODEDVIEW_HPP
32namespace EBGeometry::Render::ViewerDetail {
64 using T =
typename V::T;
69 using Box = RegionNeighborhoodDetail::Box<T>;
85 ExplodedView(
const V& a_view,
const std::vector<Box>& a_boxes,
const T a_factor)
97 : m_view(a_view), m_rest(a_view)
99 const uint32_t numRegions = a_view.getNumRegions();
116 for (uint32_t k = 1; k < m_count; k++) {
117 if (!a_view.isVisible(k)) {
122 if (k < a_boxes.size() && !a_boxes[k].m_some) {
126 const bool hasBox = k < a_boxes.size();
128 m_offset[k] = (k < a_offsets.size()) ? a_offsets[k] :
Vec3T<T>::zeros();
131 m_moved |= uint64_t(1U) << k;
148 m_rest = a_view.withSettings(rest);
173 return this->decide(a_point, back).m_value;
184 return m_view.getDistanceQuality();
208 const Decided decided = this->decide(a_point, a_back);
210 return (decided.m_region !=
RegionSettings::None) ? decided.m_region : m_view.getTape().region(a_point);
225 const Decided decided = this->decide(a_point, back);
228 return m_rest.closestLeaf(a_point);
233 ref.
m_leaf = this->keyOf(m_view.getTape().closestSurface(back, decided.m_region), decided.m_region);
250 const Decided decided = this->decide(a_point, back);
253 return m_rest.sectionKey(a_point);
256 return m_view.getTape().getMaterialOf((decided.m_value <=
T(0)) ? decided.m_region : 0U).value();
272 exploded.m_view = a_view;
273 exploded.m_rest = m_hasRest ? a_view.withSettings(m_rest.getSettings()) : a_view;
297 static inline std::vector<Vec3T<T>>
300 const auto bounded = [](
const Box& a_box) {
304 bool finite = a_box.m_some;
306 for (
int d = 0; d < 3; d++) {
307 finite = finite && std::isfinite(lo[d]) && std::isfinite(hi[d]) && lo[d] <= hi[d];
316 for (std::size_t k = 1; k < a_boxes.size(); k++) {
317 if (bounded(a_boxes[k])) {
318 lo =
min(lo, a_boxes[k].m_lo);
319 hi =
max(hi, a_boxes[k].m_hi);
325 const Vec3T<T> middle =
T(0.5) * (lo + hi);
327 for (std::size_t k = 1; k < a_boxes.size(); k++) {
328 if (bounded(a_boxes[k])) {
329 offsets[k] = a_factor * (
T(0.5) * (a_boxes[k].m_lo + a_boxes[k].m_hi) - middle);
368 for (uint32_t k = 1; k < m_count; k++) {
369 if (((m_moved >> k) & 1U) == 0U) {
373 const Vec3T<T> q = a_point - m_offset[k];
378 for (
int d = 0; d < 3; d++) {
379 const T beyond =
Math::max(m_low[k][d] - q[d], q[d] - m_high[k][d]);
381 outside += (beyond >
T(0)) ? beyond * beyond :
T(0);
384 if ((best.m_value >
T(0)) ? (outside >= best.m_value * best.m_value) : (outside >
T(0))) {
388 const T value = m_view.getTape().signedDistance(q, k);
390 if (value < best.m_value) {
391 best = Decided{value, k};
397 const T value = m_rest.signedDistance(a_point);
399 if (value < best.m_value) {
416 keyOf(
const SurfaceRef<T>& a_surface,
const uint32_t a_region)
const noexcept
418 const RegionSettings& settings = m_view.getSettings();
420 switch (settings.m_coloring) {
425 return settings.m_surfaceGroups.surfaceGroupOf(a_surface);
428 return m_view.getTape().getMaterialOf(a_region).value();
431 return a_surface.m_surfaceLabel.value();
434 return a_surface.m_surface;
437 return a_surface.m_part;
458 bool m_hasRest =
false;
463 uint32_t m_count = 0;
468 uint64_t m_moved = 0U;
488 BoundingVolumes::AABBT<T> m_box;
500[[nodiscard]]
inline std::vector<RegionNeighborhoodDetail::Box<T>>
503 std::vector<RegionNeighborhoodDetail::Box<T>> boxes(
506 RegionNeighborhoodDetail::regionBoxes(a_expr, boxes);
A fixed-size array that compiles for both host and device.
Declarations of bounding volume types used in bounding volume hierarchies.
std::vector< RegionNeighborhoodDetail::Box< T > > regionBoxes(const Expr< T > &a_expr)
Each region's box, by region number, from the expression a tape was compiled from (the background's,...
Definition EBGeometry_ExplodedView.hpp:501
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_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.
Scalar helpers and numeric limits that compile for both host and device.
RegionNeighborhood: some regions of an expression with their neighbors, as a smaller expression (host...
RegionSettings: how the regions of an object are shown (visibility, coloring, a domain's surface grou...
RegionView: the visible regions of a tape (see Overlay()) as a shape to look at, its surfaces those o...
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
Vec3T< T > & getLowCorner() noexcept
Get a modifiable reference to the low corner of the AABB.
Vec3T< T > & getHighCorner() noexcept
Get a modifiable reference to the high corner of the AABB.
A composed object: an immutable tree of shapes and operations, built on the host and compiled by a Ta...
Definition EBGeometry_Expr.hpp:452
A view of regions drawn exploded, as in an assembly drawing: each region moved by its own offset....
Definition EBGeometry_ExplodedView.hpp:59
ExplodedView(const V &a_view, const std::vector< Box > &a_boxes, const T a_factor)
Each region moved away from the middle: by a_factor times its box's center less the center of the box...
Definition EBGeometry_ExplodedView.hpp:85
const V & getView() const noexcept
The view drawn exploded.
Definition EBGeometry_ExplodedView.hpp:284
ExplodedView(const V &a_view, const std::vector< Box > &a_boxes, const std::vector< Vec3T< T > > &a_offsets)
Each region moved by its own offset.
Definition EBGeometry_ExplodedView.hpp:96
DistanceQuality getDistanceQuality() const noexcept
The distance quality: the view's, since the value is made of its regions' functions.
Definition EBGeometry_ExplodedView.hpp:182
uint32_t regionAt(const Vec3T< T > &a_point, Vec3T< T > &a_back) const noexcept
The region that decides the value at a point, and the point moved back into the view's frame.
Definition EBGeometry_ExplodedView.hpp:206
ExplodedView withView(const V &a_view) const noexcept
The same exploded view of another view of the same regions: the view on a mirror of its pool (whose m...
Definition EBGeometry_ExplodedView.hpp:268
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The box of the moved regions (and of the view, with regions that stay where they are).
Definition EBGeometry_ExplodedView.hpp:193
T signedDistance(const Vec3T< T > &a_point) const noexcept
The value: the least function of a visible region at the point moved back by the region's offset.
Definition EBGeometry_ExplodedView.hpp:169
static constexpr uint32_t MaxRegions
How many regions (the background included) can be moved; the later ones stay where they are.
Definition EBGeometry_ExplodedView.hpp:74
LeafRef< T > closestLeaf(const Vec3T< T > &a_point) const noexcept
The key of the surface that decides the value at a point, as the view names it, as a leaf reference (...
Definition EBGeometry_ExplodedView.hpp:222
uint32_t sectionKey(const Vec3T< T > &a_point) const noexcept
What a point is in, for a section plane's fill: the material of the region the point is in,...
Definition EBGeometry_ExplodedView.hpp:247
RegionNeighborhoodDetail::Box< T > Box
A region's box, or none.
Definition EBGeometry_ExplodedView.hpp:69
typename V::T T
Floating-point precision.
Definition EBGeometry_ExplodedView.hpp:64
static std::vector< Vec3T< T > > offsetsOf(const std::vector< Box > &a_boxes, const T a_factor)
Each region's offset for a factor: a_factor times its box's center less the center of all boxes but t...
Definition EBGeometry_ExplodedView.hpp:298
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > infinity() noexcept
Return a vector with infinite components.
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
constexpr T max(const T &a_a, const T &a_b) noexcept
The larger of two values.
Definition EBGeometry_Math.hpp:61
constexpr T min(const T &a_a, const T &a_b) noexcept
The smaller of two values.
Definition EBGeometry_Math.hpp:44
Vec2T< T > min(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise minimum of two vectors.
@ SurfaceGroup
The surface group the surface is in (RegionSettings::m_surfaceGroups), or none.
@ Interface
The pair of regions on its two sides there (see RegionSettings::interfaceKey()).
@ Part
The surface's part: a box's face, a mesh's face.
@ Surface
The surface itself (SurfaceRef::m_surface): each shape, each member of a collection.
@ SurfaceLabel
The surface's label (SurfaceLabel()).
@ Material
That region's material.
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise maximum of two vectors.
The deciding leaf of a composition at a point: the primitive whose surface the composed value comes f...
Definition EBGeometry_LeafRef.hpp:42
Vec3T< T > m_localPoint
The point in the primitive's own frame (after the composition's maps), at which it can be queried its...
Definition EBGeometry_LeafRef.hpp:68
uint32_t m_leaf
The leaf: its number in expression order, depth first, each occurrence counted.
Definition EBGeometry_LeafRef.hpp:51
Numeric limits, with the meanings of the std::numeric_limits members of the same names.
Definition EBGeometry_Math.hpp:91
How the regions of an object are shown (see RegionView): which regions are visible,...
Definition EBGeometry_RegionSettings.hpp:66
uint64_t m_hidden
The hidden regions, a bit each (bit k for region k); regions from 64 on are always shown.
Definition EBGeometry_RegionSettings.hpp:86
static constexpr uint32_t None
No key.
Definition EBGeometry_RegionSettings.hpp:70
static uint32_t interfaceKey(const uint32_t a_first, const uint32_t a_second) noexcept
The key of the interface between two regions, the same whichever side it is seen from.
Definition EBGeometry_RegionSettings.hpp:292