18#include "BDSExtentGlobal.hh"
19#include "BDSTiltOffset.hh"
20#include "BDSUtilities.hh"
23#include "G4ThreeVector.hh"
24#include "G4Transform3D.hh"
25#include "G4TwoVector.hh"
32#include "CLHEP/Geometry/Point3D.h"
36 transform(G4Transform3D()),
46 const G4Transform3D& transformIn):
48 transform(G4Transform3D(transformIn))
53 std::vector<G4ThreeVector> tBPS;
54 for (
const auto& point : bps)
55 {tBPS.emplace_back(transform * (HepGeom::Point3D<G4double>)point);}
67 for (
const auto& point : tBPS)
90 std::vector<G4ThreeVector> result;
134 out << static_cast<const BDSExtent&>(ext);
136 out <<
"Transform: " << ext.transform.getRotation()
137 << ext.transform.getTranslation() << G4endl;
138 out <<
"In Global frame: " << G4endl;
150 return *std::max_element(exts.begin(), exts.end());
157 G4ThreeVector point = G4ThreeVector(x,y,z);
162 G4ThreeVector edge01 = p[1] - p[0];
163 G4ThreeVector edge03 = p[3] - p[0];
164 G4ThreeVector edge04 = p[4] - p[0];
167 G4ThreeVector axX = edge04.cross(edge03);
168 G4ThreeVector axY = edge04.cross(edge01);
169 G4ThreeVector axZ = edge01.cross(edge03);
175 G4double pxp = axX.dot(point);
176 G4double pyp = axY.dot(point);
177 G4double pzp = axZ.dot(point);
178 G4bool insideX = (pxp > axX.dot(p[0])) && (pxp < axX.dot(p[1]));
179 G4bool insideY = (pyp > axY.dot(p[0])) && (pyp < axY.dot(p[3]));
180 G4bool insideZ = (pzp > axZ.dot(p[0])) && (pzp < axZ.dot(p[4]));
182 return insideX && insideY && insideZ;
193 return insideX && insideY && insideZ;
198 G4bool encompassesAllBeamlines =
true;
201 for (
const auto& ext : otherExtents)
204 {encompassesAllBeamlines =
false;}
206 return encompassesAllBeamlines;
212 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.