BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSExtentGlobal.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSEXTENTGLOBAL_H
19#define BDSEXTENTGLOBAL_H
20
21#include "BDSExtent.hh"
22
23#include <ostream>
24#include <utility> // for pair and pair relational operators
25#include <vector>
26
27#include "globals.hh" // geant4 types / globals
28#include "G4ThreeVector.hh"
29#include "G4Transform3D.hh"
30
31class BDSTiltOffset;
32
43{
44public:
47
50 explicit BDSExtentGlobal(const BDSExtent& extentIn,
51 const G4Transform3D& transformIn = G4Transform3D::Identity);
52
55 /*
56 BDSExtentGlobal(G4double extXNegIn, G4double extXPosIn,
57 G4double extYNegIn, G4double extYPosIn,
58 G4double extZNegIn, G4double extZPosIn,
59 const G4Transform3D& transformIn);
60 */
61
62 virtual ~BDSExtentGlobal();
63
65 inline std::pair<G4double, G4double> ExtentXGlobal() const {return std::make_pair(extXNegG, extXPosG);}
66 inline std::pair<G4double, G4double> ExtentYGlobal() const {return std::make_pair(extYNegG, extYPosG);}
67 inline std::pair<G4double, G4double> ExtentZGlobal() const {return std::make_pair(extZNegG, extZPosG);}
68
69 inline G4double XNegGlobal() const {return extXNegG;}
70 inline G4double XPosGlobal() const {return extXPosG;}
71 inline G4double YNegGlobal() const {return extYNegG;}
72 inline G4double YPosGlobal() const {return extYPosG;}
73 inline G4double ZNegGlobal() const {return extZNegG;}
74 inline G4double ZPosGlobal() const {return extZPosG;}
75
76 inline G4ThreeVector ExtentPositiveGlobal() const
77 {return G4ThreeVector(extXPosG, extYPosG, extZPosG);}
78
79 inline G4ThreeVector ExtentNegativeGlobal() const
80 {return G4ThreeVector(extXNegG, extYNegG, extZNegG);}
81
83 std::vector<G4ThreeVector> AllBoundaryPointsGlobal() const;
85
86 G4bool Overlaps(const BDSExtentGlobal& other) const;
87
89 inline G4double DXGlobal() const {return extXPosG - extXNegG;}
90 inline G4double DYGlobal() const {return extYPosG - extYNegG;}
91 inline G4double DZGlobal() const {return extZPosG - extZNegG;}
93
95 inline G4bool TransverselyLessThanGlobal(const BDSExtentGlobal& r) const;
96 inline G4bool TransverselyGreaterThanGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyLessThanGlobal(r));}
97 inline G4bool TransverselyLessEqualsGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyGreaterThanGlobal(r));}
98 inline G4bool TransverselyGreaterEqualsGlobal(const BDSExtentGlobal& r) const {return !(this->TransverselyLessThanGlobal(r));}
100
102 G4bool EncompassesGlobal(G4double x,
103 G4double y,
104 G4double z) const;
105
107 G4bool Encompasses(const BDSExtentGlobal& otherExtent);
108
110 G4bool Encompasses(const std::vector<BDSExtentGlobal>& otherExtents);
111
113 G4ThreeVector GetMaximumExtentAbsolute() const;
114
116 BDSExtentGlobal TranslateGlobal(G4ThreeVector offset) const
117 {return TranslateGlobal(offset.x(), offset.y(), offset.z());}
118 BDSExtentGlobal TranslateGlobal(G4double dx, G4double dy, G4double dz) const;
120
123
125 friend std::ostream& operator<< (std::ostream &out, BDSExtentGlobal const &ext);
126
128 G4double MaximumAbsGlobal() const;
129
130private:
131 G4Transform3D transform;
132
134 G4double extXNegG;
135 G4double extXPosG;
136 G4double extYNegG;
137 G4double extYPosG;
138 G4double extZNegG;
139 G4double extZPosG;
141};
142
144{
145 G4bool xOK = (extXNegG > r.extXNegG) && (extXPosG < r.extXPosG);
146 G4bool yOK = (extYNegG > r.extYNegG) && (extYPosG < r.extYPosG);
147 return xOK && yOK;
148}
149
150#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:38
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.