Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:29

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Surfaces/ConvexPolygonBounds.hpp"
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/detail/BoundaryCheckHelper.hpp"
0014 
0015 #include <optional>
0016 #include <ostream>
0017 
0018 namespace Acts {
0019 
0020 std::ostream& ConvexPolygonBoundsBase::toStream(std::ostream& sl) const {
0021   std::vector<Vector2> vtxs = vertices();
0022   sl << "Acts::ConvexPolygonBounds<" << vtxs.size() << ">: vertices: [x, y]\n";
0023   for (std::size_t i = 0; i < vtxs.size(); i++) {
0024     const auto& vtx = vtxs[i];
0025     if (i > 0) {
0026       sl << ",";
0027       sl << "\n";
0028     }
0029     sl << "[" << vtx.x() << ", " << vtx.y() << "]";
0030   }
0031   return sl;
0032 }
0033 
0034 std::vector<double> ConvexPolygonBoundsBase::values() const {
0035   std::vector<double> values;
0036   for (const auto& vtx : vertices()) {
0037     values.push_back(vtx.x());
0038     values.push_back(vtx.y());
0039   }
0040   return values;
0041 }
0042 
0043 ConvexPolygonBounds<PolygonDynamic>::ConvexPolygonBounds(
0044     const std::vector<Vector2>& vertices)
0045     : m_vertices(vertices.begin(), vertices.end()),
0046       m_boundingBox(makeBoundingBox(vertices)) {}
0047 
0048 bool ConvexPolygonBounds<PolygonDynamic>::inside(
0049     const Vector2& lposition,
0050     const BoundaryTolerance& boundaryTolerance) const {
0051   return detail::insidePolygon(
0052       std::span<const Vector2>(m_vertices.data(), m_vertices.size()),
0053       boundaryTolerance, lposition, std::nullopt);
0054 }
0055 
0056 std::vector<Vector2> ConvexPolygonBounds<PolygonDynamic>::vertices(
0057     unsigned int /*lseg*/) const {
0058   return {m_vertices.begin(), m_vertices.end()};
0059 }
0060 
0061 const RectangleBounds& ConvexPolygonBounds<PolygonDynamic>::boundingBox()
0062     const {
0063   return m_boundingBox;
0064 }
0065 
0066 void ConvexPolygonBounds<PolygonDynamic>::checkConsistency() const
0067     noexcept(false) {
0068   convex_impl(m_vertices);
0069 }
0070 
0071 }  // namespace Acts