Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-15 07:37:40

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 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/Volume.hpp"
0013 #include "Acts/Geometry/VolumeBounds.hpp"
0014 
0015 #include <array>
0016 #include <cstddef>
0017 #include <ostream>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 class IVisualization3D;
0023 
0024 /// Volume bounds described by eight arbitrary cuboid vertices.
0025 class GenericCuboidVolumeBounds : public VolumeBounds {
0026  public:
0027   /// @brief  This struct helps to symmetrize with the
0028   /// the other volume bounds classes
0029   struct BoundValues {
0030     /// Number of boundary values for cuboid volume bounds
0031     static constexpr std::size_t eSize = 24;
0032   };
0033 
0034   GenericCuboidVolumeBounds() = delete;
0035 
0036   /// Constructor from a set of vertices
0037   ///
0038   /// @param vertices The set of input vertices
0039   ///
0040   /// The ordering is considered to be:
0041   /// - the first 4 vertices are the "top" face
0042   /// - the second 4 vertices are the "bottom" face
0043   /// - both faces are given in counter clock wise order
0044   explicit GenericCuboidVolumeBounds(
0045       const std::array<Acts::Vector3, 8>& vertices) noexcept(false);
0046 
0047   /// Constructor from a fixed size array
0048   ///
0049   /// @param values The input values
0050   explicit GenericCuboidVolumeBounds(
0051       const std::array<double, BoundValues::eSize>& values) noexcept(false);
0052 
0053   ~GenericCuboidVolumeBounds() override = default;
0054 
0055   VolumeBounds::BoundsType type() const final {
0056     return VolumeBounds::eGenericCuboid;
0057   }
0058 
0059   /// Return the bound values as dynamically sized vector
0060   ///
0061   /// @return this returns a copy of the internal values
0062   std::vector<double> values() const final;
0063 
0064   /// Checking if position given in volume frame is inside
0065   ///
0066   /// @param gpos is the global position to be checked
0067   /// @param tol is the tolerance applied for the inside check
0068   ///
0069   /// @return boolean indicating if the position is inside
0070   bool inside(const Vector3& gpos, double tol = 0.) const override;
0071 
0072   /// Oriented surfaces, i.e. the decomposed boundary surfaces and the
0073   /// according navigation direction into the volume given the normal
0074   /// vector on the surface
0075   ///
0076   /// @param transform is the 3D transform to be applied to the boundary
0077   /// surfaces to position them in 3D space
0078   ///
0079   /// It will throw an exception if the orientation prescription is not adequate
0080   ///
0081   /// @return a vector of surfaces bounding this volume
0082   std::vector<OrientedSurface> orientedSurfaces(
0083       const Transform3& transform = Transform3::Identity()) const override;
0084 
0085   /// Construct bounding box for this shape
0086   /// @param trf Optional transform
0087   /// @param envelope Optional envelope to add / subtract from min/max
0088   /// @param entity Entity to associate this bounding box with
0089   /// @return Constructed bounding box
0090   Volume::BoundingBox boundingBox(const Transform3* trf = nullptr,
0091                                   const Vector3& envelope = {0, 0, 0},
0092                                   const Volume* entity = nullptr) const final;
0093 
0094   /// Get the canonical direction values, i.e. the axis directions
0095   /// that fully describe the shape's extent
0096   ///
0097   /// @return vector of canonical binning values
0098   std::vector<AxisDirection> canonicalAxes() const override {
0099     using enum AxisDirection;
0100     return {AxisX, AxisY, AxisZ};
0101   };
0102 
0103   /// @param sl is the output stream to be written into
0104   /// @return The output stream
0105   std::ostream& toStream(std::ostream& sl) const override;
0106 
0107   /// Draw this shape using a visualization helper
0108   /// @param helper The visualizatin helper
0109   /// @param transform Optional transformation matrix
0110   ///
0111   void draw(IVisualization3D& helper,
0112             const Transform3& transform = Transform3::Identity()) const;
0113 
0114  private:
0115   std::array<Vector3, 8> m_vertices{};
0116   std::array<Vector3, 6> m_normals{};
0117 
0118   /// Private helper method to construct the Volume bounds
0119   /// to be called by the constructors, from the ordered input vertices
0120   void construct() noexcept(false);
0121 };
0122 
0123 }  // namespace Acts