-
Notifications
You must be signed in to change notification settings - Fork 157
/
Volume.hpp
126 lines (100 loc) · 4.26 KB
/
Volume.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// This file is part of the Acts project.
//
// Copyright (C) 2016-2018 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Geometry/GeometryContext.hpp"
#include "Acts/Geometry/GeometryObject.hpp"
#include "Acts/Utilities/BinningType.hpp"
#include "Acts/Utilities/BoundingBox.hpp"
#include <iosfwd>
#include <memory>
#include <optional>
namespace Acts {
class VolumeBounds;
/// @class Volume
///
/// It inherits from GeometryObject for geometry identification
///
/// Base class for all volumes inside the tracking realm, it defines the
/// interface for inherited Volume classes regarding the geometrical
/// information.
class Volume : public GeometryObject {
public:
using BoundingBox = AxisAlignedBoundingBox<Volume, ActsScalar, 3>;
/// Explicit constructor with shared arguments
///
/// @param transform is the transform to position the volume in 3D space
/// @param volbounds is the volume boundary definitions
Volume(const Transform3& transform,
std::shared_ptr<const VolumeBounds> volbounds);
/// Copy Constructor - with optional shift
///
/// @param vol is the source volume for the copy
/// @param shift is the optional shift applied as : shift * vol.transform()
Volume(const Volume& vol, const Transform3& shift = Transform3::Identity());
Volume() = delete;
virtual ~Volume() = default;
/// Assignment operator
///
/// @param vol is the source volume to be copied
Volume& operator=(const Volume& vol);
/// Return methods for geometry transform
const Transform3& transform() const;
/// Returns the inverted transform of this volume.
const Transform3& itransform() const;
void setTransform(const Transform3& transform);
/// returns the center of the volume
const Vector3& center() const;
/// Returns const reference to the volume bounds
const VolumeBounds& volumeBounds() const;
/// Returns shared pointer to the volume bounds
std::shared_ptr<const VolumeBounds> volumeBoundsPtr() const;
/// Set volume bounds and update volume bounding boxes implicitly
/// @param volbounds The volume bounds to be assigned
void assignVolumeBounds(std::shared_ptr<const VolumeBounds> volbounds);
/// Set the volume bounds and optionally also update the volume transform
/// @param volbounds The volume bounds to be assigned
/// @param transform The transform to be assigned, can be optional
virtual void update(std::shared_ptr<const VolumeBounds> volbounds,
std::optional<Transform3> transform = std::nullopt);
/// Construct bounding box for this shape
/// @param envelope Optional envelope to add / subtract from min/max
/// @return Constructed bounding box pointing to this volume
BoundingBox boundingBox(const Vector3& envelope = {0, 0, 0}) const;
/// Construct oriented bounding box for this shape
/// @note This will build an oriented bounding box with an
/// envelope value of (0.05, 0.05, 0.05)mm
/// @return Constructed oriented bounding box pointing to this volume
BoundingBox orientedBoundingBox() const;
/// Inside() method for checks
///
/// @param gpos is the position to be checked
/// @param tol is the tolerance parameter
///
/// @return boolean indicator if the position is inside
bool inside(const Vector3& gpos, ActsScalar tol = 0.) const;
/// The binning position method
/// - as default the center is given, but may be overloaded
///
/// @param gctx The current geometry context object, e.g. alignment
/// @param bValue is the binning value schema
///
/// @return vector 3D that can be used for the binning
Vector3 binningPosition(const GeometryContext& gctx,
BinningValue bValue) const override;
bool operator==(const Volume& other) const;
bool operator!=(const Volume& other) const;
protected:
Transform3 m_transform;
Transform3 m_itransform;
Vector3 m_center;
std::shared_ptr<const VolumeBounds> m_volumeBounds;
};
/**Overload of << operator for std::ostream for debug output*/
std::ostream& operator<<(std::ostream& sl, const Volume& vol);
} // namespace Acts