Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
abbbccd4
Commit
abbbccd4
authored
11 years ago
by
Frank Gaede
Browse files
Options
Downloads
Patches
Plain Diff
- fixed issue with SurfaceType and setting properties
parent
e1f3b7a7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DDSurfaces/include/DDSurfaces/ISurface.h
+23
-8
23 additions, 8 deletions
DDSurfaces/include/DDSurfaces/ISurface.h
with
23 additions
and
8 deletions
DDSurfaces/include/DDSurfaces/ISurface.h
+
23
−
8
View file @
abbbccd4
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
"DDSurfaces/Vector3D.h"
#include
"DDSurfaces/Vector3D.h"
#include
<bitset>
#include
<bitset>
#include
<math.h>
namespace
DDSurfaces
{
namespace
DDSurfaces
{
...
@@ -25,7 +26,7 @@ namespace DDSurfaces {
...
@@ -25,7 +26,7 @@ namespace DDSurfaces {
virtual
~
ISurface
()
{}
virtual
~
ISurface
()
{}
/// properties of the surface encoded in Type.
/// properties of the surface encoded in Type.
virtual
SurfaceType
type
()
const
=
0
;
virtual
const
SurfaceType
&
type
()
const
=
0
;
/// Checks if the given point lies within the surface
/// Checks if the given point lies within the surface
virtual
bool
insideBounds
(
const
Vector3D
&
point
,
double
epsilon
=
1.e-4
)
const
=
0
;
virtual
bool
insideBounds
(
const
Vector3D
&
point
,
double
epsilon
=
1.e-4
)
const
=
0
;
...
@@ -67,8 +68,9 @@ namespace DDSurfaces {
...
@@ -67,8 +68,9 @@ namespace DDSurfaces {
* @version $Id: $
* @version $Id: $
* @date Apr 6 2014
* @date Apr 6 2014
*/
*/
struct
SurfaceType
{
class
SurfaceType
{
public:
/// enum for defining the bits used to decode the properties
/// enum for defining the bits used to decode the properties
enum
{
enum
{
Cylinder
=
1
,
Cylinder
=
1
,
...
@@ -109,7 +111,7 @@ namespace DDSurfaces {
...
@@ -109,7 +111,7 @@ namespace DDSurfaces {
}
}
/// set the given peorperty
/// set the given peorperty
void
setProperty
(
unsigned
prop
)
{
_bits
.
set
(
prop
)
;
}
void
setProperty
(
unsigned
prop
,
bool
val
=
true
)
{
_bits
.
set
(
prop
,
val
)
;
}
/// true if surface is sensitive
/// true if surface is sensitive
bool
isSensitive
()
const
{
return
_bits
[
SurfaceType
::
Sensitive
]
;
}
bool
isSensitive
()
const
{
return
_bits
[
SurfaceType
::
Sensitive
]
;
}
...
@@ -133,7 +135,8 @@ namespace DDSurfaces {
...
@@ -133,7 +135,8 @@ namespace DDSurfaces {
bool
isZCylinder
()
const
{
return
(
_bits
[
SurfaceType
::
Cylinder
]
&&
_bits
[
SurfaceType
::
ParallelToZ
]
)
;
}
bool
isZCylinder
()
const
{
return
(
_bits
[
SurfaceType
::
Cylinder
]
&&
_bits
[
SurfaceType
::
ParallelToZ
]
)
;
}
/// true if this is a plane parallel to Z
/// true if this is a plane parallel to Z
bool
isZPlane
()
const
{
return
(
_bits
[
SurfaceType
::
Plane
]
&&
_bits
[
SurfaceType
::
ParallelToZ
]
)
;
}
bool
isZPlane
()
const
{
return
(
_bits
[
SurfaceType
::
Plane
]
&&
_bits
[
SurfaceType
::
ParallelToZ
]
)
;
}
/// true if this is a plane orthogonal to Z
/// true if this is a plane orthogonal to Z
bool
isZDisk
()
const
{
return
(
_bits
[
SurfaceType
::
Plane
]
&&
_bits
[
SurfaceType
::
OrthogonalToZ
]
)
;
}
bool
isZDisk
()
const
{
return
(
_bits
[
SurfaceType
::
Plane
]
&&
_bits
[
SurfaceType
::
OrthogonalToZ
]
)
;
}
...
@@ -142,23 +145,35 @@ namespace DDSurfaces {
...
@@ -142,23 +145,35 @@ namespace DDSurfaces {
/** True if surface is parallel to Z with accuracy epsilon - result is cached in bit SurfaceType::ParallelToZ */
/** True if surface is parallel to Z with accuracy epsilon - result is cached in bit SurfaceType::ParallelToZ */
bool
checkParallelToZ
(
const
ISurface
&
surf
,
double
epsilon
=
1.e-6
)
const
{
bool
checkParallelToZ
(
const
ISurface
&
surf
,
double
epsilon
=
1.e-6
)
const
{
double
proj
=
std
::
abs
(
surf
.
normal
()
*
Vector3D
(
0.
,
0.
,
1.
)
)
;
double
proj
=
std
::
f
abs
(
surf
.
normal
()
*
Vector3D
(
0.
,
0.
,
1.
)
)
;
_bits
.
set
(
SurfaceType
::
ParallelToZ
,
(
std
::
abs
(
proj
-
1.
)
<
epsilon
)
)
;
_bits
.
set
(
SurfaceType
::
ParallelToZ
,
(
proj
<
epsilon
)
)
;
// std::cout << " ** checkParallelToZ() - normal : " << surf.normal() << " pojection : " << proj
// << " _bits[ SurfaceType::ParallelToZ ] = " << bool( _bits[ SurfaceType::ParallelToZ ] )
// << " ( std::fabs( proj - 1. ) < epsilon ) ) = " << ( proj < epsilon ) << std::endl ;
return
_bits
[
SurfaceType
::
ParallelToZ
]
;
return
_bits
[
SurfaceType
::
ParallelToZ
]
;
}
}
/** True if surface is orthogonal to Z with accuracy epsilon - result is cached in bit SurfaceType::OrthogonalToZ */
/** True if surface is orthogonal to Z with accuracy epsilon - result is cached in bit SurfaceType::OrthogonalToZ */
bool
checkOrthogonalToZ
(
const
ISurface
&
surf
,
double
epsilon
=
1.e-6
)
const
{
bool
checkOrthogonalToZ
(
const
ISurface
&
surf
,
double
epsilon
=
1.e-6
)
const
{
double
proj
=
std
::
abs
(
surf
.
normal
()
*
Vector3D
(
0.
,
0.
,
1.
)
)
;
double
proj
=
std
::
f
abs
(
surf
.
normal
()
*
Vector3D
(
0.
,
0.
,
1.
)
)
;
_bits
.
set
(
SurfaceType
::
OrthogonalToZ
,
(
proj
<
epsilon
)
)
;
_bits
.
set
(
SurfaceType
::
OrthogonalToZ
,
(
std
::
fabs
(
proj
-
1.
)
<
epsilon
)
)
;
// std::cout << " ** checkOrthogonalToZ() - normal : " << surf.normal() << " pojection : " << proj
// << " _bits[ SurfaceType::OrthogonalToZ ] = " << bool( _bits[ SurfaceType::OrthogonalToZ ] )
// << " ( std::fabs( proj - 1. ) < epsilon ) ) = " << ( std::fabs( proj - 1. ) < epsilon ) << std::endl ;
return
_bits
[
SurfaceType
::
OrthogonalToZ
]
;
return
_bits
[
SurfaceType
::
OrthogonalToZ
]
;
}
}
protected
:
mutable
std
::
bitset
<
32
>
_bits
;
mutable
std
::
bitset
<
32
>
_bits
;
}
;
}
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment