19#include "BDSExtentGlobal.hh"
20#include "BDSTiltOffset.hh"
21#include "BDSUtilities.hh"
24#include "G4ThreeVector.hh"
25#include "G4Transform3D.hh"
26#include "G4TwoVector.hh"
33#include "CLHEP/Geometry/Point3D.h"
37 transform(G4Transform3D()),
47 const G4Transform3D& transformIn):
49 transform(G4Transform3D(transformIn))
54 std::vector<G4ThreeVector> tBPS;
55 for (
const auto& point : bps)
56 {tBPS.emplace_back(transform * (HepGeom::Point3D<G4double>)point);}
68 for (
const auto& point : tBPS)
91 std::vector<G4ThreeVector> result;
135 out << static_cast<const BDSExtent&>(ext);
137 out <<
"Transform: " << ext.transform.getRotation()
138 << ext.transform.getTranslation() << G4endl;
139 out <<
"In Global frame: " << G4endl;
151 return *std::max_element(exts.begin(), exts.end());
158 G4ThreeVector point = G4ThreeVector(x,y,z);
163 G4ThreeVector edge01 = p[1] - p[0];
164 G4ThreeVector edge03 = p[3] - p[0];
165 G4ThreeVector edge04 = p[4] - p[0];
168 G4ThreeVector axX = edge04.cross(edge03);
169 G4ThreeVector axY = edge04.cross(edge01);
170 G4ThreeVector axZ = edge01.cross(edge03);
176 G4double pxp = axX.dot(point);
177 G4double pyp = axY.dot(point);
178 G4double pzp = axZ.dot(point);
179 G4bool insideX = (pxp > axX.dot(p[0])) && (pxp < axX.dot(p[1]));
180 G4bool insideY = (pyp > axY.dot(p[0])) && (pyp < axY.dot(p[3]));
181 G4bool insideZ = (pzp > axZ.dot(p[0])) && (pzp < axZ.dot(p[4]));
183 return insideX && insideY && insideZ;
194 return insideX && insideY && insideZ;
199 G4bool encompassesAllBeamlines =
true;
202 for (
const auto& ext : otherExtents)
205 {encompassesAllBeamlines =
false;}
207 return encompassesAllBeamlines;
213 for (
int i = 0; i < 3; i++)
Holder for +- extents in 3 dimensions with a rotation and translation.
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.
std::pair< G4double, G4double > ExtentXGlobal() const
Accessor.
BDSExtentGlobal ExpandToEncompass(const BDSExtentGlobal &other) const
Return a copy of this extent but expanded to encompass another global extent.
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.
BDSExtentGlobal()
Default constructor gives 0 in all extents - typically unphysical.
virtual ~BDSExtentGlobal()
std::vector< G4ThreeVector > AllBoundaryPointsGlobal() const
All 8 boundary points of the bounding box.
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.
std::vector< G4ThreeVector > AllBoundaryPoints() const
All 8 boundary points of the bounding box.