19#include "BDSBeamPipeFactoryRhombus.hh"
20#include "BDSBeamPipeFactoryPoints.hh"
22#include "G4TwoVector.hh"
29BDSBeamPipeFactoryRhombus::BDSBeamPipeFactoryRhombus()
35 G4double cornerRadius,
38 G4double frac = cornerRadius / std::max(std::abs(x1), std::abs(y1));
45 G4double alpha = std::atan2(std::abs(x1), std::abs(y1));
46 G4double halfAngle = CLHEP::halfpi - alpha;
47 std::vector<G4TwoVector> topBit;
48 G4double nPointsTopDouble = (2*halfAngle/CLHEP::twopi) * pointsPerTwoPi;
49 G4int nPointsTop = std::max(4, (G4int)std::ceil(nPointsTopDouble));
50 G4double currentAngle = -halfAngle;
51 G4double dAngle = 2*halfAngle / (G4double)nPointsTop;
52 G4TwoVector rotationPointTop(0, y1-cornerRadius);
53 for (G4int i = 0; i <= nPointsTop; i++)
55 G4TwoVector r(0, cornerRadius);
56 r.rotate(-currentAngle);
57 topBit.push_back(rotationPointTop + r);
58 currentAngle += dAngle;
61 std::vector<G4TwoVector> rightBit;
62 G4double nPointsRightDouble = (2*alpha/CLHEP::twopi) * pointsPerTwoPi;
63 G4int nPointsRight = std::max(4, (G4int)std::ceil(nPointsRightDouble));
64 currentAngle = -alpha;
65 dAngle = 2*alpha / (G4double)nPointsRight;
66 G4TwoVector rotationPointRight(x1-cornerRadius, 0);
67 for (G4int i = 0; i <= nPointsRight; i++)
69 G4TwoVector r(cornerRadius, 0);
70 r.rotate(-currentAngle);
71 topBit.push_back(rotationPointRight + r);
72 currentAngle += dAngle;
75 for (
const auto& p : topBit)
77 for (
const auto& p : rightBit)
79 for (
const auto& p : topBit)
80 {vec.emplace_back(-p.x(), -p.y());}
81 for (
const auto& p : rightBit)
82 {vec.emplace_back(-p.x(), -p.y());}
83 std::reverse(vec.begin(), vec.end());
87 AppendPoint(vec, x1, 0);
88 AppendPoint(vec, 0, -y1);
89 AppendPoint(vec, -x1, 0);
90 AppendPoint(vec, 0, y1);
99 G4double a1 = aper1 + distance;
100 G4double a2 = aper2 + distance;
101 G4double a3 = aper3 > 0 ? aper3 + distance : aper3;
111 G4double beamPipeThickness,
112 G4int pointsPerTwoPi)
132 G4double beamPipeThickness)
136 G4double result = std::max(aper1 + dThickness, aper2 + dThickness);
std::vector< G4TwoVector > containerSubtractionEdge
Vector of x,y coordinates for the container subtraction volume.
std::vector< G4TwoVector > beamPipeInnerEdge
Vector of x,y coordinates for beam pipe inner edge.
G4double extentY
Extents prepared by GeneratePoints function as only it knows the extents.
G4double extentX
Extents prepared by GeneratePoints function as only it knows the extents.
std::vector< G4TwoVector > vacuumEdge
Vector of x,y coordinates for vacuum extruded solid edge.
std::vector< G4TwoVector > containerEdge
Vector of x,y coordinates for the container volume.
std::vector< G4TwoVector > beamPipeOuterEdge
Vector of x,y coordinates for beam pipe outer edge.
BDS::ThreePoints ExpandRhombus(G4double aper1, G4double aper2, G4double aper3, G4double distance)
Expand the rhombus as needed.
void GenerateRhombus(std::vector< G4TwoVector > &vec, G4double x1, G4double y1, G4double cornerRadius, G4int pointsPerTwoPi)
Generate either 4 points or set of points with curved edges.
virtual void GeneratePoints(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness, G4int pointsPerTwoPi=40)
Generate all the sets of required points for each surface.
virtual G4double CalculateIntersectionRadius(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness)
Calculate the radius of the solid used for intersection for angled faces.
G4double lengthSafetyLarge
Cache of global constants variable.