ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
graphics
VP1
VP1HEPVis
src
RevolutionSurfaceUtil.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef REVOLUTIONSURFACEUTIL_H
6
#define REVOLUTIONSURFACEUTIL_H
7
8
#include <algorithm>
//for std::min,std::max
9
#include <cmath>
10
11
class
RevolutionSurfaceUtil
{
12
13
//Added by Thomas Kittelmann, September 2007.
14
//
15
//Used by SoTubs, SoPcons, SoCons, SoLAr, ... to get correct and tight bounding boxes.
16
//
17
18
public
:
19
20
//_________________________________________________________________________________________________
21
static
int
nphiDivisions
(
const
float
& dphi,
const
float
& complexity,
int
OverrideNPhi = 0 ) {
22
int
NPHI = ( OverrideNPhi > 0 ? OverrideNPhi : std::max(3,
static_cast<
int
>
(fabs(20.0*complexity*dphi/
M_PI
)) ) );
23
int
lim1 =
static_cast<
int
>
(dphi*8.0/(2*
M_PI
)+0.5);
24
if
(NPHI<lim1) {
25
if
(OverrideNPhi<=0) {
26
NPHI = lim1;
27
}
else
{
28
int
lim2 =
static_cast<
int
>
(dphi*5.0/(2*
M_PI
)+0.5);
29
if
(NPHI<lim2)
30
NPHI = lim2;
31
}
32
}
33
if
(NPHI<2)
34
NPHI = 2;
35
return
NPHI;
36
}
37
38
39
//_________________________________________________________________________________________________
40
static
void
setBBoxPars
(
const
float
& sphi,
const
float
& dphi,
const
float
& rmin,
const
float
& rmax,
41
const
float
& zmin,
const
float
& zmax, SbBox3f &box, SbVec3f ¢er ) {
42
43
44
if
(dphi>(2.0*
M_PI
*0.99)) {
45
SbVec3f vmin(-rmax,-rmax,zmin),
46
vmax( rmax, rmax, zmax);
47
center.setValue(0,0,0);
48
box.setBounds(vmin,vmax);
49
}
else
{
50
//Get start/end angle in correct interval:
51
float
anglestart = sphi;
52
while
(anglestart < 0.0) anglestart += 2*
M_PI
;
53
while
(anglestart > 2*
M_PI
) anglestart -= 2*
M_PI
;
54
if
(anglestart<0.0) anglestart = 0.0;
55
float
angleend = anglestart + dphi;
56
57
//Get bounds:
58
double
cosanglestart(cos(anglestart));
59
double
cosangleend(cos(angleend));
60
double
sinanglestart(sin(anglestart));
61
double
sinangleend(sin(angleend));
62
63
float
ymax
= rmax * ( (0.5*
M_PI
>=anglestart&&0.5*
M_PI
<=angleend) ? 1.0 : std::max(sinanglestart,sinangleend) );
64
float
ymin
= rmax * ( (1.5*
M_PI
>=anglestart&&1.5*
M_PI
<=angleend) ? -1.0 : std::min(sinanglestart,sinangleend) );
65
float
xmax
= rmax * ( (anglestart <= 0.0 || angleend >= 2*
M_PI
) ? 1.0 : std::max(cosanglestart,cosangleend) );
66
float
xmin
= rmax * ( (
M_PI
>=anglestart&&
M_PI
<=angleend) ? -1.0 : std::min(cosanglestart,cosangleend) );
67
68
//Not only the bounds of the arc - also of the lines to the center:
69
if
(dphi >= 0.5*
M_PI
|| rmin==0.0f ) {
70
//(0,0) is included
71
if
(
ymax
<0.0)
ymax
= 0.0;
72
if
(
ymin
>0.0)
ymin
= 0.0;
73
if
(
xmax
<0.0)
xmax
= 0.0;
74
if
(
xmin
>0.0)
xmin
= 0.0;
75
}
else
{
76
//The two inner "corners" must be included
77
double
x1 = rmin*cosanglestart;
78
double
y1 = rmin*sinanglestart;
79
double
x2 = rmin*cosangleend;
80
double
y2 = rmin*sinangleend;
81
if
(
xmax
<x1)
xmax
= x1;
82
if
(
xmax
<x2)
xmax
= x2;
83
if
(
xmin
>x1)
xmin
= x1;
84
if
(
xmin
>x2)
xmin
= x2;
85
if
(
ymax
<y1)
ymax
= y1;
86
if
(
ymax
<y2)
ymax
= y2;
87
if
(
ymin
>y1)
ymin
= y1;
88
if
(
ymin
>y2)
ymin
= y2;
89
}
90
SbVec3f vmin(
xmin
,
ymin
,zmin), vmax(
xmax
,
ymax
, zmax);
91
center.setValue(0.5*(
xmin
+
xmax
),0.5*(
ymin
+
ymax
),0.5*(zmin+zmax));
92
box.setBounds(vmin,vmax);
93
}
94
}
95
96
97
//Fixme: Add common code to deal with complexity here.
98
};
99
100
#endif
M_PI
#define M_PI
Definition
ActiveFraction.h:14
RevolutionSurfaceUtil
Definition
RevolutionSurfaceUtil.h:11
RevolutionSurfaceUtil::setBBoxPars
static void setBBoxPars(const float &sphi, const float &dphi, const float &rmin, const float &rmax, const float &zmin, const float &zmax, SbBox3f &box, SbVec3f ¢er)
Definition
RevolutionSurfaceUtil.h:40
RevolutionSurfaceUtil::nphiDivisions
static int nphiDivisions(const float &dphi, const float &complexity, int OverrideNPhi=0)
Definition
RevolutionSurfaceUtil.h:21
xmax
double xmax
Definition
listroot.cxx:61
ymin
double ymin
Definition
listroot.cxx:63
xmin
double xmin
Definition
listroot.cxx:60
ymax
double ymax
Definition
listroot.cxx:64
Generated on
for ATLAS Offline Software by
1.17.0