BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSExtentGlobal.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSEXTENTGLOBAL_H
20#define BDSEXTENTGLOBAL_H
21
22#include "BDSExtent.hh"
23
24#include <ostream>
25#include <utility> // for pair and pair relational operators
26#include <vector>
27
28#include "globals.hh" // geant4 types / globals
29#include "G4ThreeVector.hh"
30#include "G4Transform3D.hh"
31
32class BDSTiltOffset;
33
44{
45public:
48
51 explicit BDSExtentGlobal(const BDSExtent& extentIn,
52 const G4Transform3D& transformIn = G4Transform3D::Identity);
53
56 /*
57 BDSExtentGlobal(G4double extXNegIn, G4double extXPosIn,
58 G4double extYNegIn, G4double extYPosIn,
59 G4double extZNegIn, G4double extZPosIn,
60 const G4Transform3D& transformIn);
61 */
62
63 virtual ~BDSExtentGlobal();
64
66 inline std::pair<G4double, G4double> ExtentXGlobal() const {return std::make_pair(extXNegG, extXPosG);}
67 inline std::pair<G4double, G4double> ExtentYGlobal() const {return std::make_pair(extYNegG, extYPosG);}
68 inline std::pair<G4double, G4double> ExtentZGlobal() const {return std::make_pair(extZNegG, extZPosG);}
69
70 inline G4double XNegGlobal() const {return extXNegG;}
71 inline G4double XPosGlobal() const {return extXPosG;}
72 inline G4double YNegGlobal() const {return extYNegG;}
73 inline G4double YPosGlobal() const {return extYPosG;}
74 inline G4double ZNegGlobal() const {return extZNegG;}
75 inline G4double ZPosGlobal() const {return extZPosG;}
76
77 inline G4ThreeVector ExtentPositiveGlobal() const
78 {return G4ThreeVector(extXPosG, extYPosG, extZPosG);}
79
80 inline G4ThreeVector ExtentNegativeGlobal() const
81 {return G4ThreeVector(extXNegG, extYNegG, extZNegG);}
82
84 std::vector<G4ThreeVector> AllBoundaryPointsGlobal() const;
86
87 G4bool Overlaps(const BDSExtentGlobal& other) const;
88
90 inline G4double DXGlobal() const {return extXPosG - extXNegG;}
91 inline G4double DYGlobal() const {return extYPosG - extYNegG;}
92 inline G4double DZGlobal() const {return extZPosG - extZNegG;}
94
96 inline G4bool TransverselyLessThanGlobal(const BDSExtentGlobal& r) const;
97 inline G4bool TransverselyGreaterThanGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyLessThanGlobal(r));}
98 inline G4bool TransverselyLessEqualsGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyGreaterThanGlobal(r));}
99 inline G4bool TransverselyGreaterEqualsGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyLessThanGlobal(r));}
101
103 G4bool EncompassesGlobal(G4double x,
104 G4double y,
105 G4double z) const;
106
108 G4bool Encompasses(const BDSExtentGlobal& otherExtent);
109
111 G4bool Encompasses(const std::vector<BDSExtentGlobal>& otherExtents);
112
114 G4ThreeVector GetMaximumExtentAbsolute() const;
115
117 BDSExtentGlobal TranslateGlobal(G4ThreeVector offset) const
118 {return TranslateGlobal(offset.x(), offset.y(), offset.z());}
119 BDSExtentGlobal TranslateGlobal(G4double dx, G4double dy, G4double dz) const;
121
124
126 friend std::ostream& operator<< (std::ostream &out, BDSExtentGlobal const &ext);
127
129 G4double MaximumAbsGlobal() const;
130
131private:
132 G4Transform3D transform;
133
135 G4double extXNegG;
136 G4double extXPosG;
137 G4double extYNegG;
138 G4double extYPosG;
139 G4double extZNegG;
140 G4double extZPosG;
142};
143
145{
146 G4bool xOK = (extXNegG > r.extXNegG) && (extXPosG < r.extXPosG);
147 G4bool yOK = (extYNegG > r.extYNegG) && (extYPosG < r.extYPosG);
148 return xOK && yOK;
149}
150
151#endif
Holder for +- extents in 3 dimensions with a rotation and translation.
G4double YNegGlobal() const
Accessor.
G4double extYNegG
Extent.
std::pair< G4double, G4double > ExtentZGlobal() const
Accessor.
G4bool EncompassesGlobal(G4double x, G4double y, G4double z) const
Return whether the extent encompasses the point. Similar, but with separate x,y,z coordinates.
G4bool TransverselyLessEqualsGlobal(const BDSExtentGlobal &r) const
Comparison operator for x,y only. Ignores z (length).
std::pair< G4double, G4double > ExtentXGlobal() const
Accessor.
G4double DZGlobal() const
The difference in a dimension.
BDSExtentGlobal ExpandToEncompass(const BDSExtentGlobal &other) const
Return a copy of this extent but expanded to encompass another global extent.
G4double ZPosGlobal() const
Accessor.
BDSExtentGlobal TranslateGlobal(G4ThreeVector offset) const
Provide a new copy of this extent with an offset applied.
std::pair< G4double, G4double > ExtentYGlobal() const
Accessor.
G4ThreeVector GetMaximumExtentAbsolute() const
Get the maximum extent absolute in each dimension.
G4double YPosGlobal() const
Accessor.
BDSExtentGlobal()
Default constructor gives 0 in all extents - typically unphysical.
G4double XPosGlobal() const
Accessor.
virtual ~BDSExtentGlobal()
friend std::ostream & operator<<(std::ostream &out, BDSExtentGlobal const &ext)
Output stream.
std::vector< G4ThreeVector > AllBoundaryPointsGlobal() const
All 8 boundary points of the bounding box.
G4double extXPosG
Extent.
G4bool TransverselyGreaterThanGlobal(const BDSExtentGlobal &r) const
Comparison operator for x,y only. Ignores z (length).
G4double extXNegG
Extent.
G4double DXGlobal() const
The difference in a dimension.
G4bool TransverselyGreaterEqualsGlobal(const BDSExtentGlobal &r) const
Comparison operator for x,y only. Ignores z (length).
G4double XNegGlobal() const
Accessor.
G4double ZNegGlobal() const
Accessor.
G4double extYPosG
Extent.
G4double extZNegG
Extent.
G4double DYGlobal() const
The difference in a dimension.
G4double extZPosG
Extent.
G4bool TransverselyLessThanGlobal(const BDSExtentGlobal &r) const
Comparison operator for x,y only. Ignores z (length).
G4bool Encompasses(const BDSExtentGlobal &otherExtent)
Return whether the extent encompasses another extent.
G4ThreeVector ExtentPositiveGlobal() const
Accessor.
G4ThreeVector ExtentNegativeGlobal() const
Accessor.
G4double MaximumAbsGlobal() const
Return the maximum absolute value considering all dimensions.
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.