Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:40

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Surfaces/ConvexPolygonBounds.hpp"
0010 
0011 #include <algorithm>
0012 #include <ostream>
0013 
0014 std::ostream& Acts::ConvexPolygonBoundsBase::toStream(std::ostream& sl) const {
0015   std::vector<Vector2> vtxs = vertices();
0016   sl << "Acts::ConvexPolygonBounds<" << vtxs.size() << ">: vertices: [x, y]\n";
0017   for (std::size_t i = 0; i < vtxs.size(); i++) {
0018     const auto& vtx = vtxs[i];
0019     if (i > 0) {
0020       sl << ",";
0021       sl << "\n";
0022     }
0023     sl << "[" << vtx.x() << ", " << vtx.y() << "]";
0024   }
0025   return sl;
0026 }
0027 
0028 std::vector<double> Acts::ConvexPolygonBoundsBase::values() const {
0029   std::vector<double> values;
0030   for (const auto& vtx : vertices()) {
0031     values.push_back(vtx.x());
0032     values.push_back(vtx.y());
0033   }
0034   return values;
0035 }
0036 
0037 Acts::ConvexPolygonBounds<Acts::PolygonDynamic>::ConvexPolygonBounds(
0038     const std::vector<Vector2>& vertices)
0039     : m_vertices(vertices.begin(), vertices.end()),
0040       m_boundingBox(makeBoundingBox(vertices)) {}
0041 
0042 Acts::SurfaceBounds::BoundsType
0043 Acts::ConvexPolygonBounds<Acts::PolygonDynamic>::type() const {
0044   return SurfaceBounds::eConvexPolygon;
0045 }
0046 
0047 bool Acts::ConvexPolygonBounds<Acts::PolygonDynamic>::inside(
0048     const Acts::Vector2& lposition, const Acts::BoundaryCheck& bcheck) const {
0049   return bcheck.isInside(lposition, m_vertices);
0050 }
0051 
0052 std::vector<Acts::Vector2> Acts::ConvexPolygonBounds<
0053     Acts::PolygonDynamic>::vertices(unsigned int /*lseg*/) const {
0054   return {m_vertices.begin(), m_vertices.end()};
0055 }
0056 
0057 const Acts::RectangleBounds&
0058 Acts::ConvexPolygonBounds<Acts::PolygonDynamic>::boundingBox() const {
0059   return m_boundingBox;
0060 }
0061 
0062 void Acts::ConvexPolygonBounds<Acts::PolygonDynamic>::checkConsistency() const
0063     noexcept(false) {
0064   convex_impl(m_vertices);
0065 }