File indexing completed on 2025-01-18 09:11:30
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Surfaces/StrawSurface.hpp"
0010
0011 #include "Acts/Geometry/GeometryObject.hpp"
0012 #include "Acts/Geometry/Polyhedron.hpp"
0013 #include "Acts/Surfaces/LineBounds.hpp"
0014 #include "Acts/Surfaces/detail/FacesHelper.hpp"
0015 #include "Acts/Surfaces/detail/VerticesHelper.hpp"
0016
0017 #include <numbers>
0018 #include <utility>
0019 #include <vector>
0020
0021 namespace Acts {
0022
0023 StrawSurface::StrawSurface(const Transform3& transform, double radius,
0024 double halez)
0025 : GeometryObject(), LineSurface(transform, radius, halez) {}
0026
0027 StrawSurface::StrawSurface(const Transform3& transform,
0028 std::shared_ptr<const LineBounds> lbounds)
0029 : GeometryObject(), LineSurface(transform, std::move(lbounds)) {}
0030
0031 StrawSurface::StrawSurface(const std::shared_ptr<const LineBounds>& lbounds,
0032 const DetectorElementBase& detelement)
0033 : GeometryObject(), LineSurface(lbounds, detelement) {}
0034
0035 StrawSurface::StrawSurface(const StrawSurface& other)
0036 : GeometryObject(), LineSurface(other) {}
0037
0038 StrawSurface::StrawSurface(const GeometryContext& gctx,
0039 const StrawSurface& other, const Transform3& shift)
0040 : GeometryObject(), LineSurface(gctx, other, shift) {}
0041
0042 StrawSurface& StrawSurface::operator=(const StrawSurface& other) {
0043 if (this != &other) {
0044 LineSurface::operator=(other);
0045 m_bounds = other.m_bounds;
0046 }
0047 return *this;
0048 }
0049
0050 Polyhedron StrawSurface::polyhedronRepresentation(
0051 const GeometryContext& gctx, unsigned int quarterSegments) const {
0052
0053 std::vector<Vector3> vertices;
0054 std::vector<Polyhedron::FaceType> faces;
0055 std::vector<Polyhedron::FaceType> triangularMesh;
0056
0057 const Transform3& ctransform = transform(gctx);
0058
0059 if (quarterSegments > 0u) {
0060 double r = m_bounds->get(LineBounds::eR);
0061
0062 std::vector<int> sides = {-1, 1};
0063 for (auto& side : sides) {
0064
0065 auto svertices = detail::VerticesHelper::segmentVertices(
0066 {r, r}, -std::numbers::pi, std::numbers::pi, {}, quarterSegments,
0067 Vector3(0., 0., side * m_bounds->get(LineBounds::eHalfLengthZ)),
0068 ctransform);
0069 vertices.insert(vertices.end(), svertices.begin(), svertices.end());
0070 }
0071 auto facesMesh = detail::FacesHelper::cylindricalFaceMesh(vertices);
0072 faces = facesMesh.first;
0073 triangularMesh = facesMesh.second;
0074 }
0075
0076 std::size_t bvertices = vertices.size();
0077 Vector3 left(0, 0, -m_bounds->get(LineBounds::eHalfLengthZ));
0078 Vector3 right(0, 0, m_bounds->get(LineBounds::eHalfLengthZ));
0079
0080 vertices.push_back(ctransform * left);
0081 vertices.push_back(ctransform * right);
0082 faces.push_back({bvertices, bvertices + 1});
0083 vertices.push_back(ctransform * Vector3(0., 0., 0.));
0084 triangularMesh.push_back({bvertices, bvertices + 2, bvertices + 1});
0085
0086 return Polyhedron(vertices, faces, triangularMesh, false);
0087 }
0088
0089 }