Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-15 08:03:13

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