ROOT
master
Reference Guide
Loading...
Searching...
No Matches
bvh2_extra_kernels.h
Go to the documentation of this file.
1
#ifndef ROOT_GEOM_BVH2_EXTRA
2
3
namespace
bvh::v2::extra
{
4
5
// reusable geometry kernels used in multiple places
6
// for interaction with BVH2 structures
7
8
// determines if a point is inside the bounding box
9
template
<
typename
T>
10
bool
contains
(
bvh::v2::BBox<T, 3>
const
&
box
,
bvh::v2::Vec<T, 3>
const
&
p
)
11
{
12
auto
min =
box
.min;
13
auto
max =
box
.max;
14
return
(
p
[0] >= min[0] &&
p
[0] <= max[0]) && (
p
[1] >= min[1] &&
p
[1] <= max[1]) &&
15
(
p
[2] >= min[2] &&
p
[2] <= max[2]);
16
}
17
18
// determines the largest squared distance of point to any of the bounding box corners
19
template
<
typename
T>
20
auto
RmaxSqToNode
(
bvh::v2::BBox<T, 3>
const
&
box
,
bvh::v2::Vec<T, 3>
const
&
p
)
21
{
22
// construct the 8 corners to get the maximal distance
23
const
auto
minCorner
=
box
.min;
24
const
auto
maxCorner
=
box
.max;
25
using
Vec3
=
bvh::v2::Vec<T, 3>
;
26
// these are the corners of the bounding box
27
const
std::array<bvh::v2::Vec<T, 3>, 8>
corners
{
28
Vec3
{
minCorner
[0],
minCorner
[1],
minCorner
[2]},
Vec3
{
minCorner
[0],
minCorner
[1],
maxCorner
[2]},
29
Vec3
{
minCorner
[0],
maxCorner
[1],
minCorner
[2]},
Vec3
{
minCorner
[0],
maxCorner
[1],
maxCorner
[2]},
30
Vec3
{
maxCorner
[0],
minCorner
[1],
minCorner
[2]},
Vec3
{
maxCorner
[0],
minCorner
[1],
maxCorner
[2]},
31
Vec3
{
maxCorner
[0],
maxCorner
[1],
minCorner
[2]},
Vec3
{
maxCorner
[0],
maxCorner
[1],
maxCorner
[2]}};
32
33
T
Rmax_sq
{0};
34
for
(
const
auto
&corner :
corners
) {
35
float
R_sq
= 0.;
36
const
auto
dx
= corner[0] -
p
[0];
37
R_sq
+=
dx
*
dx
;
38
const
auto
dy
= corner[1] -
p
[1];
39
R_sq
+=
dy
*
dy
;
40
const
auto
dz
= corner[2] -
p
[2];
41
R_sq
+=
dz
*
dz
;
42
Rmax_sq
= std::max(
Rmax_sq
,
R_sq
);
43
}
44
return
Rmax_sq
;
45
};
46
47
// determines the minimum squared distance of point to a bounding box ("safey square")
48
template
<
typename
T>
49
auto
SafetySqToNode
(
bvh::v2::BBox<T, 3>
const
&
box
,
bvh::v2::Vec<T, 3>
const
&
p
)
50
{
51
T
sqDist
{0.0};
52
for
(
int
i = 0; i < 3; i++) {
53
T
v
=
p
[i];
54
if
(
v
<
box
.min[i]) {
55
sqDist
+= (
box
.min[i] -
v
) * (
box
.min[i] -
v
);
56
}
else
if
(
v
>
box
.max[i]) {
57
sqDist
+= (
v
-
box
.max[i]) * (
v
-
box
.max[i]);
58
}
59
}
60
return
sqDist
;
61
};
62
63
}
// namespace bvh::v2::extra
64
65
#endif
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:360
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
ROOT::Detail::TRangeCast
Definition
TCollection.h:313
box
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition
fillpatterns.C:1
bvh::v2::extra
Definition
bvh2_extra_kernels.h:3
bvh::v2::extra::RmaxSqToNode
auto RmaxSqToNode(bvh::v2::BBox< T, 3 > const &box, bvh::v2::Vec< T, 3 > const &p)
Definition
bvh2_extra_kernels.h:20
bvh::v2::extra::contains
bool contains(bvh::v2::BBox< T, 3 > const &box, bvh::v2::Vec< T, 3 > const &p)
Definition
bvh2_extra_kernels.h:10
bvh::v2::extra::SafetySqToNode
auto SafetySqToNode(bvh::v2::BBox< T, 3 > const &box, bvh::v2::Vec< T, 3 > const &p)
Definition
bvh2_extra_kernels.h:49
v
@ v
Definition
rootcling_impl.cxx:3554
bvh::v2::BBox
Definition
bbox.h:12
bvh::v2::Vec
Definition
vec.h:14
geom
geom
inc
bvh2_extra_kernels.h
ROOTmaster - Reference Guide Generated on Fri Mar 13 2026 03:30:09 (GVA Time) using Doxygen 1.10.0