Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-05 08:17:49

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/Visualization/EventDataView3D.hpp"
0013 #include "Acts/Visualization/IVisualization3D.hpp"
0014 #include "Acts/Visualization/ViewConfig.hpp"
0015 
0016 #include <array>
0017 #include <filesystem>
0018 #include <iostream>
0019 #include <map>
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// This helper produces output for Python visualization. Note that colors are
0026 /// not supported in this implementation.
0027 ///
0028 class VisualizationBuffer : public IVisualization3D {
0029  public:
0030   /// Stored value type, should be double or float
0031   using ValueType = double;
0032 
0033   /// Type of a vertex based on the value type
0034   using VertexType = Eigen::Matrix<ValueType, 3, 1>;
0035 
0036   /// Type of a line
0037   using LineType = std::pair<std::size_t, std::size_t>;
0038 
0039   /// Constructor
0040   explicit VisualizationBuffer(unsigned int /*prec*/, double /*scale*/) {}
0041 
0042   /// @copydoc Acts::IVisualization3D::vertex()
0043   void vertex(const Vector3& vtx, Color color = s_defaultColor) override;
0044 
0045   /// @copydoc Acts::IVisualization3D::line()
0046   void line(const Vector3& a, const Vector3& b,
0047             Color color = s_defaultColor) override;
0048 
0049   // overload to allow for lineThickness argument to be accepted
0050   /// @copydoc Acts::IVisualization3D::line()
0051   /// @param lineThickness optional parameter to define the thickness of the line
0052   void line(const Vector3& a, const Vector3& b, const double lineThickness,
0053             Color color = s_defaultColor);
0054 
0055   /// This implementation does not support face
0056   void face(const std::vector<Vector3>& /*vtxs*/, Color /*color*/) override {
0057     throw std::logic_error("face() is not supported for this type");
0058   }
0059 
0060   /// @param vtxs The vertices that make up the faceS
0061   /// @param color The color of the face
0062   void faces(const std::vector<Vector3>& vtxs,
0063              const std::vector<FaceType>& /*faces*/,
0064              Color color = s_defaultColor) override;
0065 
0066   /// @note This implementation does not support write
0067   void write(const std::filesystem::path& /*path*/) const override {
0068     throw std::logic_error("write() is not supported for this type");
0069   }
0070 
0071   /// @note This implementation does not support write
0072   void write(std::ostream& /*os*/) const override {
0073     throw std::logic_error("write() is not supported for this type");
0074   }
0075 
0076   /// Write the object and the material file
0077   /// @note Not supported in this implementation
0078   void write(std::ostream& /*os*/, std::ostream& /*mos*/) const {
0079     throw std::logic_error("write() is not supported for this type");
0080   }
0081 
0082   ///  @copydoc Acts::IVisualization3D::clear()
0083   void clear() override {}
0084 
0085   /// @note Start a new object context with a name
0086   void object(const std::string& /*name*/) override {}
0087 
0088   /// @return vector of 3D vertices
0089   const std::vector<Vector3>& vertices3D() const { return m_vertices; }
0090 
0091   /// All vertices that make up a surface are collected in a vector
0092   /// All of these vectors are again stored as a vector which can be understood
0093   /// as a vector of surfaces
0094   /// @return vector of surfaces
0095   const std::vector<std::vector<Vector3>>& surfaces() const {
0096     return m_surfaces;
0097   }
0098 
0099   /// Two vertices that form a line segment are collected in a vector
0100   /// All of these vectors are again stored as a vector which can be understood
0101   /// as the whole line
0102   /// @return vector of line segments
0103   const std::vector<std::vector<Vector3>>& segments() const {
0104     return m_segments;
0105   }
0106 
0107   /// Vector that contains the colors of a set of faces forming a surface
0108   /// @return vector of Color objects belonging to a face
0109   const std::vector<Color>& faceColors() const { return m_facecolors; }
0110 
0111   /// Vector that contains the colors of a set of line segments forming a line
0112   /// @return vector of Color objects belonging to a line segment
0113   const std::vector<Color>& lineColors() const { return m_linecolors; }
0114 
0115   /// Vector that contains the line thickness of a set of line segments forming
0116   /// a line
0117   /// @return vector of doubles that define the line thckness of a line segment
0118   const std::vector<double>& lineThickness() const { return m_linethickness; }
0119 
0120   /// Vector that contains the colors of vertices
0121   /// @return vector of Color objects belonging to a vertex
0122   const std::vector<Color>& vertexColors() const { return m_vertexcolors; }
0123 
0124  private:
0125   std::vector<Vector3> m_vertices;
0126   std::vector<std::vector<Vector3>> m_surfaces;
0127   std::vector<std::vector<Vector3>> m_segments;
0128   std::vector<Color> m_facecolors;
0129   std::vector<Color> m_vertexcolors;
0130   std::vector<Color> m_linecolors;
0131   std::vector<double> m_linethickness;
0132 };
0133 
0134 }  // namespace Acts